casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotOptions.h
Go to the documentation of this file.
1 //# PlotOptions.h: Customization classes for plotter objects.
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 PLOTOPTIONS_H_
28 #define PLOTOPTIONS_H_
29 
30 #include <utility>
31 #include <cctype>
32 #include <vector>
33 
35 #include <casa/Containers/Record.h>
36 
37 namespace casa {
38 
39 
40 // Typedef for range, which is two doubles (min and max).
41 typedef std::pair<double, double> prange_t;
42 
43 // Typedef for size, which is two doubles (width and height).
44 typedef std::pair<double, double> psize_t;
45 
46 
47 
49 // ENUMS //
51 
55 };
56 
57 
58 // Enum for the four plot axes. If this enum is changed, PlotCanvas::allAxes()
59 // needs to be updated.
60 // Use this in contexts where one and only one side is specified.
61 // For combinations of sides, or none, use PlotAxiBitset
62 enum PlotAxis {
63  X_BOTTOM = 1, X_TOP = 2, Y_LEFT = 4, Y_RIGHT = 8
64 };
65 
66 
67 // Set of bit flags to indicate combinations of sides,
68 // used (as of this writing) for indicating which axes have visible scales.
69 // The value of a PlotSideBitset is the bitwise OR of values of PlotSide.
70 typedef unsigned int PlotAxisBitset;
71 
74 
75 
76 
77 // Enum for possible axis scales.
80  LOG10, // logarithmic scale
81  ANGLE, // display scale values as formatted angles
82  DATE_MJ_SEC, // display scale values as dates (modified julian seconds)
83  DATE_MJ_DAY // display scale values as dates (modified julian days)
84 };
85 
86 // Enum for angle formats
88  DECIMAL, // Decimal Number
89  HMS, // Hours Minutes Seconds
90  DMS // Degrees Arcminutes Arcseconds
91 };
92 
93 // Enum for cursors.
94 enum PlotCursor {
101 };
102 
103 // The canvas is composed of multiple layers, where changing/adding items from
104 // one layer will not affect the others. This is mainly used to separate items
105 // that are costly to draw (i.e. scatter plots with many points) from
106 // interaction-type items (i.e. annotations and selections). The layers share
107 // axes and are otherwise transparent to the user. If this enum is changed,
108 // PlotCanvas::allLayers() needs to be updated.
110  MAIN = 1, // "Main" or bottom layer.
111  ANNOTATION = 2 // Annotations or top layer.
112 };
113 
114 
116 // ABSTRACT CLASSES //
118 
119 // Abstract class for colors. Any implementation of color should be able to
120 // provide a hexadecimal form of the color (i.e., "000000" for black) and, if
121 // applicable, a human-readable name (i.e. "black"). In many places throughout
122 // the plotter, color and Strings are interchangeable; however implementation
123 // classes should use PlotColors where possible for additional features such as
124 // alpha blending.
125 class PlotColor {
126 public:
127  // Constructor.
128  PlotColor();
129 
130  // Destructor.
131  virtual ~PlotColor();
132 
133 
134  // ABSTRACT METHODS //
135 
136  // Returns this color's value in a hexadecimal form, i.e. "000000".
137  virtual casacore::String asHexadecimal() const = 0;
138 
139  // Returns this color's value as a human-readable name if applicable, or an
140  // empty casacore::String if inapplicable.
141  virtual casacore::String asName() const = 0;
142 
143  // If the given casacore::String is a hexadecimal value, sets the color to it.
144  // Otherwise tries to set the color as a name. If the given name is
145  // invalid, the behavior is undefined but should probably default to a
146  // sensible value.
147  virtual void setAsHexadecimalOrName(const casacore::String& str) = 0;
148 
149  // Returns this color's alpha as a value between 0 (transparent) and 1
150  // (opaque).
151  virtual double alpha() const = 0;
152 
153  // Sets this color's alpha as a value between 0 (transparent) and 1
154  // (opaque).
155  virtual void setAlpha(double a) = 0;
156 
157 
158  // CONVENIENCE METHODS //
159 
160  // Sets this color's value as a hexadecimal value.
161  virtual void setAsHexadecimal(const casacore::String& hex);
162 
163  // Set's this color's value to the given named color.
164  virtual void setAsName(const casacore::String& name);
165 
166 
167  // RECORD METHODS //
168 
169  // Gets/Sets the color as a Record.
170  // <group>
171  virtual casacore::Record toRecord() const;
172  virtual void fromRecord(const casacore::Record& record);
173  // </group>
174 
175 
176  // OPERATORS //
177 
178  // Assigns the value of the given PlotColor to this one.
179  virtual PlotColor& operator=(const PlotColor& rh);
180 
181  // Returns true if this PlotColor is equal to the given; false otherwise.
182  virtual bool operator==(const PlotColor& rh) const;
183 
184  // Returns true if this PlotColor is NOT equal to the given; false
185  // otherwise.
186  virtual bool operator!=(const PlotColor& rh) const;
187 
188 protected:
189  // casacore::Record key names.
190  // <group>
191  static const casacore::String REC_HEXADECIMAL; // String
192  static const casacore::String REC_ALPHA; // double
193  // </group>
194 };
196 
197 
198 // Abstract class for fonts. A font has a family, size, color, bold, italics,
199 // and underline properties.
200 class PlotFont {
201 public:
202  // Constructor.
203  PlotFont();
204 
205  // Destructor.
206  virtual ~PlotFont();
207 
208 
209  // ABSTRACT METHODS //
210 
211  // Returns the point size of this font, or -1 if the size was set in
212  // pixels.
213  virtual double pointSize() const = 0;
214 
215  // Sets the point size of this font to the given.
216  virtual void setPointSize(double size) = 0;
217 
218  // Returns the pixel size of this font, or -1 if the size was set in
219  // points.
220  virtual int pixelSize() const = 0;
221 
222  // Sets the pixel size of this font to the given.
223  virtual void setPixelSize(int size) = 0;
224 
225  // Returns the font family.
226  virtual casacore::String fontFamily() const = 0;
227 
228  // Sets the font family to the given.
229  virtual void setFontFamily(const casacore::String& font) = 0;
230 
231  // Returns a copy of the color for this font.
232  virtual PlotColorPtr color() const = 0;
233 
234  // Sets the color of this font to the given.
235  virtual void setColor(const PlotColor& color) = 0;
236 
237  // Gets/sets whether this font is italicized, bolded, and/or underlined,
238  // respectively.
239  // <group>
240  virtual bool italics() const = 0;
241  virtual void setItalics(bool i = true) = 0;
242  virtual bool bold() const = 0;
243  virtual void setBold(bool b = true) = 0;
244  virtual bool underline() const = 0;
245  virtual void setUnderline(bool u = true) = 0;
246  // </group>
247 
248 
249  // CONVENIENCE METHODS //
250 
251  // Convenience methods for setting color.
252  // <group>
253  virtual void setColor(const PlotColorPtr c);
254  virtual void setColor(const casacore::String& col);
255  // </group>
256 
257 
258  // RECORD METHODS //
259 
260  // Gets/Sets the color as a Record.
261  // <group>
262  virtual casacore::Record toRecord() const;
263  virtual void fromRecord(const casacore::Record& record);
264  // </group>
265 
266 
267  // OPERATORS //
268 
269  // Assigns the value of the given PlotFont to this one.
270  virtual PlotFont& operator=(const PlotFont& rh);
271 
272  // Returns true if this PlotFont is equal to the given; false otherwise.
273  virtual bool operator==(const PlotFont& rh) const;
274 
275  // Returns true if this PlotFont is NOT equal to the given; false
276  // otherwise.
277  virtual bool operator!=(const PlotFont& rh) const;
278 
279 protected:
280  // casacore::Record key names.
281  // <group>
282  static const casacore::String REC_POINTSIZE; // double
283  static const casacore::String REC_PIXELSIZE; // int
284  static const casacore::String REC_FAMILY; // String
285  static const casacore::String REC_COLOR; // Record
286  static const casacore::String REC_ITALICS; // bool
287  static const casacore::String REC_BOLD; // bool
288  static const casacore::String REC_UNDERLINE; // bool
289  // </group>
290 };
292 
293 
294 // Abstract class for area fill. An area fill consists of a color and a
295 // pattern.
297 public:
298  // Pattern enum, similar in spirit to
299  // http://doc.trolltech.com/4.3/qt.html#BrushStyle-enum .
300  enum Pattern {
302  };
303 
304  // Constructor
305  PlotAreaFill();
306 
307  // Destructor
308  virtual ~PlotAreaFill();
309 
310 
311  // ABSTRACT METHODS //
312 
313  // Returns a copy of the color in this area fill.
314  virtual PlotColorPtr color() const = 0;
315 
316  // Sets the area fill color to the given.
317  virtual void setColor(const PlotColor& color) = 0;
318 
319  // Returns the pattern for this area fill.
320  virtual Pattern pattern() const = 0;
321 
322  // Sets the pattern for this area fill to the given.
323  virtual void setPattern(Pattern pattern) = 0;
324  virtual void setPattern( const casacore::String& descriptor );
325 
326  // CONVENIENCE METHODS //
327 
328  // Convenience methods for setting color.
329  // <group>
330  virtual void setColor(const PlotColorPtr c);
331  virtual void setColor(const casacore::String& co);
332  // </group>
333 
334 
335  // RECORD METHODS //
336 
337  // Gets/Sets the color as a Record.
338  // <group>
339  virtual casacore::Record toRecord() const;
340  virtual void fromRecord(const casacore::Record& record);
341  // </group>
342 
343 
344  // OPERATORS //
345 
346  // Assigns the value of the given PlotAreaFill to this one.
347  virtual PlotAreaFill& operator=(const PlotAreaFill& rh);
348 
349  // Returns true if this PlotAreaFill is equal to the given; false
350  // otherwise.
351  virtual bool operator==(const PlotAreaFill& rh) const;
352 
353  // Returns true if this PlotAreaFill is NOT equal to the given; false
354  // otherwise.
355  virtual bool operator!=(const PlotAreaFill& rh) const;
356 
357 protected:
358  // casacore::Record key names.
359  // <group>
360  static const casacore::String REC_COLOR; // Record
361  static const casacore::String REC_PATTERN; // int
362  // </group>
363 };
365 
366 
367 // Abstract class for a line. A line has a color, style, and width.
368 class PlotLine {
369 public:
370  // Static //
371 
372  // Line styles.
373  enum Style {
375  };
376 
377 
378  // Non-Static //
379 
380  // Constructor.
381  PlotLine();
382 
383  // Destructor.
384  virtual ~PlotLine();
385 
386 
387  // ABSTRACT METHODS //
388 
389  // Returns this line's width.
390  virtual double width() const = 0;
391 
392  // Sets the width to the given.
393  virtual void setWidth(double width) = 0;
394 
395  // Returns this line's style.
396  virtual Style style() const = 0;
397 
398  // Sets the style to the given.
399  virtual void setStyle(Style style) = 0;
400 
401  // Returns a copy of the color used for this line.
402  virtual PlotColorPtr color() const = 0;
403 
404  // Sets this line's color to the given.
405  virtual void setColor(const PlotColor& color) = 0;
406 
407 
408  // CONVENIENCE METHODS //
409 
410  // Convenience methods for setting color.
411  // <group>
412  virtual void setColor(const PlotColorPtr c);
413  virtual void setColor(const casacore::String& col);
414  // </group>
415 
416 
417  // RECORD METHODS //
418 
419  // Gets/Sets the color as a Record.
420  // <group>
421  virtual casacore::Record toRecord() const;
422  virtual void fromRecord(const casacore::Record& record);
423  // </group>
424 
425 
426  // OPERATORS //
427 
428  // Assigns the value of the given PlotLine to this one.
429  virtual PlotLine& operator=(const PlotLine& rh);
430 
431  // Returns true if this PlotLine is equal to the given; false otherwise.
432  virtual bool operator==(const PlotLine& rh) const;
433 
434  // Returns true if this PlotLine is NOT equal to the given; false
435  // otherwise.
436  virtual bool operator!=(const PlotLine& rh) const;
437 
438 protected:
439  // casacore::Record key names.
440  // <group>
441  static const casacore::String REC_WIDTH; // double
442  static const casacore::String REC_STYLE; // int
443  static const casacore::String REC_COLOR; // Record
444  // </group>
445 };
447 
448 
449 // Abstract class for a symbol. A symbol has a style, size, line, and area
450 // fill.
451 class PlotSymbol {
452 public:
453  // Static //
454 
455  // Symbol style.
456  enum Symbol {
457  CHARACTER, // for char symbols
458  CIRCLE, SQUARE, DIAMOND, // standard shapes
459  PIXEL, // draw a single pixel
460  NOSYMBOL, // don't show symbols
461  AUTOSCALING // autoscaling symbol
462  };
463 
464 
465  // Non-Static //
466 
467  // Constructor.
468  PlotSymbol();
469 
470  //PlotSymbol(const PlotSymbol& copy);
471 
472  // Destructor.
473  virtual ~PlotSymbol();
474 
475 
476  // ABSTRACT METHODS //
477 
478  // Returns the size, in pixels, of this symbol. If this symbol is a
479  // character, the height corresponds to the font size (in either pixels or
480  // points, see heightIsPixel()).
481  virtual psize_t size() const = 0;
482 
483  // Sets the size of the symbol in pixels. The heightIsPixel parameter is
484  // used for character symbols and indicates whether the given height is in
485  // points or pixels.
486  virtual void setSize(double width, double height,
487  bool heightIsPixel = true) = 0;
488 
489  // Gets/Sets whether the set height is in pixels or points, ONLY for
490  // character symbols.
491  // <group>
492  virtual bool heightIsPixel() const = 0;
493  virtual void setHeightIsPixel(bool pixel = true) = 0;
494  // </group>
495 
496  // Returns the symbol style.
497  virtual Symbol symbol() const = 0;
498 
499  // Returns the character for this symbol. Invalid if the style is not
500  // CHARACTER.
501  virtual char symbolChar() const = 0;
502 
503  // Returns the character unicode for this symbol. Invalid if the style is
504  // not CHARACTER.
505  virtual unsigned short symbolUChar() const = 0;
506 
507  // Sets the symbol style to the given.
508  virtual void setSymbol(Symbol symbol) = 0;
509  virtual void setSymbol( const casacore::String& descriptor );
510 
511  // Sets the symbol character to the given. Implies setSymbol(CHARACTER).
512  virtual void setSymbol(char c) = 0;
513 
514  // Sets the symbol character unicode to the given. Implies
515  // setSymbol(CHARACTER).
516  virtual void setUSymbol(unsigned short unicode) = 0;
517 
518  // Returns a copy of the line for the outline of this symbol. Does not
519  // apply to character or pixel symbols.
520  virtual PlotLinePtr line() const = 0;
521 
522  // Sets the outline of this symbol to the given. Does not apply to
523  // character or pixel symbols.
524  virtual void setLine(const PlotLine& color) = 0;
525 
526  // Returns a copy of the area fill for this symbol. Does not apply to
527  // character or pixel symbols.
528  virtual PlotAreaFillPtr areaFill() const = 0;
529 
530  // Sets the area fill of this symbol to the given. Does not apply to
531  // character or pixel symbols.
532  virtual void setAreaFill(const PlotAreaFill& fill) = 0;
533 
534 
535  // CONVENIENCE METHODS //
536 
537  // Convenience method for setting size.
538  virtual void setSize(psize_t size);
539 
540  // Returns true if this symbol is set to a character or not.
541  virtual bool isCharacter() const;
542 
543  // Convenience methods for setting the line.
544  // <group>
545  virtual void setLine(const PlotLinePtr l);
546  virtual void setLine(const casacore::String& color,
548  double width = 1.0);
549  // </group>
550 
551  // Convenience methods for setting area fill.
552  // <group>
553  virtual void setAreaFill(const PlotAreaFillPtr a);
554  virtual void setAreaFill(const casacore::String& color,
556  // </group>
557 
558  // Convenience method for setting color of both line and area fill.
559  // <group>
560  virtual void setColor(const PlotColor& color);
561  virtual void setColor(const PlotColorPtr color);
562  virtual void setColor(const casacore::String& color);
563  casacore::String getColor() const;
564  // </group>
565 
566 
567  // RECORD METHODS //
568 
569  // Gets/Sets the color as a Record.
570  // <group>
571  virtual casacore::Record toRecord() const;
572  virtual void fromRecord(const casacore::Record& record);
573  // </group>
574 
575  // OPERATORS //
576 
577  // Assigns the value of the given PlotSymbol to this one.
578  virtual PlotSymbol& operator=(const PlotSymbol& rh);
579 
580  // Returns true if this PlotSymbol is equal to the given; false otherwise.
581  virtual bool operator==(const PlotSymbol& rh) const;
582 
583  // Returns true if this PlotSymbol is NOT equal to the given; false
584  // otherwise.
585  virtual bool operator!=(const PlotSymbol& rh) const;
586 
587 protected:
588  // casacore::Record key names.
589  // <group>
590  static const casacore::String REC_WIDTH; // double
591  static const casacore::String REC_HEIGHT; // double
592  static const casacore::String REC_HEIGHTISPIXEL; // bool
593  static const casacore::String REC_SYMBOL; // int
594  static const casacore::String REC_UCHAR; // int (no ushort in Records)
595  static const casacore::String REC_LINE; // Record
596  static const casacore::String REC_AREAFILL; // Record
597  static const casacore::String REC_COLOR; //String
598  // </group>
599 
600 private:
603 };
605 
606 
608 // CONCRETE UTILITY CLASSES //
610 
611 // casacore::Coordinate on the canvas surface (i.e., the part where the actual plots
612 // are, which doesn't include things like axes, titles, etc.). A coordinate
613 // has two values and a system.
614 class PlotCoordinate {
615 public:
616  // Static //
617 
618  // casacore::Coordinate system.
619  enum System {
620  WORLD, // in the units of the axes
621  NORMALIZED_WORLD, // [0 ... 1] value that maps to a "percentage" of
622  // world units
623  PIXEL // pixels right and below the upper left corner of
624  // the canvas
625  };
626 
627 
628  // Non-Static //
629 
630  // Default constructor.
631  PlotCoordinate();
632 
633  // Parameterized constructor.
634  PlotCoordinate(double dx, double dy, System s = WORLD);
635 
636  // Copy constructor.
637  PlotCoordinate(const PlotCoordinate& c);
638 
639  // Destructor.
640  ~PlotCoordinate();
641 
642 
643  // Accessors //
644 
645  // Returns the coordinate system.
646  System system() const;
647 
648  // Returns the x value.
649  double x() const;
650 
651  // Returns the y value.
652  double y() const;
653 
654 
655  // Operators //
656 
657  // Assigns the value of the given PlotCoordinate to this one.
658  PlotCoordinate& operator=(const PlotCoordinate& rh);
659 
660  // Returns true if this PlotCoordinate is equal to the given; false
661  // otherwise.
662  bool operator==(const PlotCoordinate& rh) const;
663 
664  // Returns true if this PlotCoordinate is NOT equal to the given; false
665  // otherwise.
666  bool operator!=(const PlotCoordinate& rh) const;
667 
668 private:
669  // casacore::Coordinate system.
670  System m_system;
671 
672  // X value.
673  double m_x;
674 
675  // Y value.
676  double m_y;
677 };
678 
679 
680 // A PlotRegion is basically just a wrapper for two PlotCoordinates: an upper
681 // left coordinate and a lower right coordinate.
682 class PlotRegion {
683 public:
684  // Default constructor.
685  PlotRegion();
686 
687  // Parameterized constructor.
688  PlotRegion(const PlotCoordinate& upperLeft,
689  const PlotCoordinate& lowerRight);
690 
691  // Copy constructor.
692  PlotRegion(const PlotRegion& copy);
693 
694  // Destructor.
695  ~PlotRegion();
696 
697 
698  // Returns the upper left coordinate.
699  const PlotCoordinate& upperLeft() const;
700 
701  // Returns the lower right coordinate.
702  const PlotCoordinate& lowerRight() const;
703 
704  // Returns the top y value.
705  double top() const;
706 
707  // Returns the bottom y value.
708  double bottom() const;
709 
710  // Returns the left x value.
711  double left() const;
712 
713  // Returns the right x value.
714  double right() const;
715 
716  // Returns true if the region is valid, false otherwise.
717  bool isValid() const;
718 
719 private:
720  // Upper-left coordinate.
721  PlotCoordinate m_upperLeft;
722 
723  // Lower-right coordinate.
724  PlotCoordinate m_lowerRight;
725 };
726 
727 
728 // A PlotAxesStack is basically a list of PlotRegions as well as axis
729 // information that provides stack functionality such as a current index, and
730 // moving up and down the stack. A valid stack has a "base" followed by zero
731 // or more PlotRegions. A stack can optionally have a limit on its length;
732 // adding to the stack after it reaches its length will remove the oldest
733 // members after the base. The smallest value this limit can be is 2, (base +
734 // 1 value).
736 public:
737  // Constructor for empty stack. Length limits with values <= 1 mean no
738  // limit.
739  PlotAxesStack(int lengthLimit = -1);
740 
741  // Destructor.
742  ~PlotAxesStack();
743 
744 
745  // Gets/Sets the length limit on this stack. Values <= 1 mean no limit.
746  // <group>
747  int lengthLimit() const;
748  void setLengthLimit(int lengthLimit);
750  // </group>
751 
752  // Returns whether the stack is valid (has size > 0) or not.
753  bool isValid() const;
754 
755  // Returns the current stack index.
756  unsigned int stackIndex() const;
757 
758  // Returns the stack size.
759  unsigned int size() const;
760 
761  // Returns a copy of the stack.
762  std::vector<PlotRegion> stack() const;
763 
764  // Returns a copy of the stack axes. The first item is for x, the second
765  // for y.
766  std::vector<std::pair<PlotAxis, PlotAxis> > stackAxes() const;
767 
768  // Resets the stack and sets the stack base to the given.
769  void setBase(const PlotRegion& base, PlotAxis xAxis, PlotAxis yAxis);
770 
771  // Adds the given region to the stack.
772  void addRegion(const PlotRegion& region, PlotAxis xAxis, PlotAxis yAxis);
773 
774  // Clears the stack, including the base if keepBase is false.
775  void clearStack(bool keepBase = false);
776 
777  // Returns the current region in the stack.
778  PlotRegion currentRegion() const;
779 
780  // Returns the x-axis for the current region in the stack.
781  PlotAxis currentXAxis() const;
782 
783  // Returns the y-axis for the current region in the stack.
784  PlotAxis currentYAxis() const;
785 
786  // Moves the stack index the given delta. If delta is negative, the index
787  // goes backwards; if delta is positive, the index goes forward. If delta
788  // is zero, the index goes to the base.
789  void move(int delta);
790 
791  // Moves the stack index the given delta (see move()) and returns the
792  // current region.
793  PlotRegion moveAndReturn(int delta);
794 
795 private:
796  // Length limit.
798 
799  // Region stack.
800  std::vector<PlotRegion> m_stack;
801 
802  // Axes stack.
803  std::vector<std::pair<PlotAxis, PlotAxis> > m_axes;
804 
805  // casacore::Stack index.
806  unsigned int m_stackIndex;
807 
808 
809  // Shrinks the region and axes stack to the given size, discarding the
810  // oldest UNLESS the stack index is in the elements to be discarded. In
811  // this case, the element referenced by the index is also kept.
812  void shrinkStacks(unsigned int n);
813 };
814 
815 
816 // PlotExportFormat contains parameters for exporting a canvas to a file.
818 public:
819  // Static //
820 
821  // The type of file/export.
822  enum Type {
825  };
826 
827  // Whether to have high resolution or not.
828  enum Resolution {
829  SCREEN, // basically a screen shot
830  HIGH // "high" resolution
831  };
832 
833  // Converts to/from a Type and its casacore::String representation.
834  // <group>
836  static Type exportFormat(casacore::String t, bool* ok = NULL);
837  // </group>
838 
839  // Gives/converts the standard extension for export types.
840  // <group>
842  static Type typeForExtension(casacore::String file, bool* ok = NULL);
843  // </group>
844 
845  // Returns all supported export formats.
846  // <group>
847  static std::vector<Type> supportedFormats();
848  static std::vector<casacore::String> supportedFormatStrings();
849  // </group>
850 
851  // Returns all supported image formats.
852  // <group>
853  static std::vector<Type> supportedImageFormats();
854  static std::vector<casacore::String> supportedImageFormatStrings();
855  // </group>
856 
857 
858  // Non-Static //
859 
860  // Sets up a format with the given type and location. Default resolution
861  // is SCREEN; default dpi is -1 (unspecified); default width and height
862  // are -1 (unspecified). Unspecified values are left up to the plotting
863  // implementation.
865 
866  // Destructor.
868 
869  // Public Members
870  // <group>
871  Type type; // export type
872  bool verbose; // verbose text export
873  casacore::String location; // export location
874  Resolution resolution; // export resolution
875  int dpi; // export dpi (if applicable)
876  int width; // export width (if applicable)
877  int height; // export height (if applicable)
878  // </group>
879 };
880 
881 
883 // SMART POINTER MACROS //
885 
886 // This is painful but necessary to have transparent smart pointers that
887 // support hierarchies and inheritance. See examples in other files.
888 // cname = class name (to declare smart pointer for),
889 // cptrname = name for pointer (usually cname + Ptr),
890 // pname = immediate parent class name
891 // pptrname = name for pointer of parent class (usually pname + Ptr),
892 // gname = "grandparent" class name (or highest smart pointer in hierarchy),
893 // gptrname = grandparent pointer name (usually gname + Ptr)
894 #define INHERITANCE_POINTER(cname, cptrname, pname, pptrname, gname, gptrname)\
895  class cptrname : public pptrname { \
896  public: \
897  cptrname () : pptrname () { } \
898  cptrname ( cname * val, bool del = true ) : pptrname() { \
899  gname * v = dynamic_cast< gname *>(val); \
900  if(v != NULL) gptrname ::operator=( gptrname (v, del)); \
901  } \
902  cptrname ( const gptrname & val ) : pptrname () { \
903  const cname * v = dynamic_cast<const cname *>( \
904  val.operator->()); \
905  if(v != NULL) gptrname ::operator=(val); \
906  } \
907  cname & operator*() { \
908  return dynamic_cast< cname &>(**(( gptrname *)this)); \
909  } \
910  cname * operator->() { \
911  return dynamic_cast< cname *>((( gptrname *)this)->operator->()); \
912  } \
913  const cname & operator*() const { \
914  return dynamic_cast<const cname &>(**(( gptrname * )this)); \
915  } \
916  const cname * operator->() const { \
917  return dynamic_cast<const cname *>( \
918  (( gptrname *)this)->operator->()); \
919  } \
920  cptrname & operator=(const gptrname & val) { \
921  const cname * v = dynamic_cast<const cname *>(val.operator->()); \
922  if(v != NULL) (( gptrname *)this)->operator=(val); \
923  return *this; \
924  } \
925  cptrname & operator=( gname * val) { \
926  cname * v = dynamic_cast< cname *>(val); \
927  if(v != NULL) (( gptrname *)this)->operator=(val); \
928  return *this; \
929  } \
930  };
931 
932 // Convenience macro.
933 #define INHERITANCE_POINTER2(cname, cptrname, pname, pptrname) \
934  INHERITANCE_POINTER(cname, cptrname, pname, pptrname, pname, pptrname)
935 
936 // Macro for when the child class is a template.
937 #define INHERITANCE_TPOINTER(cname, cptrname, pname, pptrname, gname,gptrname)\
938  template <class T> class cptrname : public pptrname { \
939  public: \
940  cptrname () : pptrname () { } \
941  cptrname ( cname <T>* val, bool del = true ) : pptrname(){ \
942  gname * v = dynamic_cast< gname *>(val); \
943  if(v != NULL) gptrname ::operator=( gptrname (v, del)); \
944  } \
945  cptrname ( const gptrname & val ) : pptrname () { \
946  const cname <T>* v = dynamic_cast<const cname <T>*>( \
947  val.operator->()); \
948  if(v != NULL) gptrname ::operator=(val); \
949  } \
950  cptrname ( const cptrname <T> & val ) : pptrname() { \
951  gptrname ::operator=((const gptrname &)val); \
952  } \
953  cname <T>& operator*() { \
954  return dynamic_cast< cname <T>&>(**(( gptrname *)this)); \
955  } \
956  cname <T>* operator->() { \
957  return dynamic_cast< cname <T>*>( \
958  (( gptrname *)this)->operator->()); \
959  } \
960  const cname <T>& operator*() const { \
961  return dynamic_cast<const cname <T>&>(**(( gptrname * )this)); \
962  } \
963  const cname <T>* operator->() const { \
964  return dynamic_cast<const cname <T>*>( \
965  (( gptrname *)this)->operator->()); \
966  } \
967  cptrname <T>& operator=(const gptrname & val) { \
968  const cname <T>* v = dynamic_cast<const cname <T>*>( \
969  val.operator->()); \
970  if(v != NULL) (( gptrname *)this)->operator=(val); \
971  return *this; \
972  } \
973  cptrname <T>& operator=( gname * val) { \
974  cname <T>* v = dynamic_cast< cname <T>*>(val); \
975  if(v != NULL) (( gptrname *)this)->operator=(val); \
976  return *this; \
977  } \
978  };
979 
980 // Convenience macro.
981 #define INHERITANCE_TPOINTER2(cname, cptrname, pname, pptrname) \
982  INHERITANCE_TPOINTER(cname, cptrname, pname, pptrname, pname, pptrname)
983 
984 }
985 
986 #endif /*PLOTOPTIONS_H_*/
virtual bool italics() const =0
Gets/sets whether this font is italicized, bolded, and/or underlined, respectively.
virtual bool isCharacter() const
Returns true if this symbol is set to a character or not.
static const casacore::String REC_PATTERN
Definition: PlotOptions.h:361
casacore::CountedPtr< PlotAreaFill > PlotAreaFillPtr
Definition: PlotOptions.h:364
virtual void setUnderline(bool u=true)=0
virtual PlotColorPtr color() const =0
Returns a copy of the color for this font.
virtual PlotColorPtr color() const =0
Returns a copy of the color used for this line.
bool isValid() const
Returns true if the region is valid, false otherwise.
static const casacore::String REC_COLOR
Definition: PlotOptions.h:443
casacore::CountedPtr< PlotColor > PlotColorPtr
Definition: PlotOptions.h:195
virtual void setColor(const PlotColor &color)=0
Sets the area fill color to the given.
PlotRegion currentRegion() const
Returns the current region in the stack.
PlotFont()
Constructor.
virtual void setWidth(double width)=0
Sets the width to the given.
virtual bool underline() const =0
StatsData< AccumType > copy(const StatsData< AccumType > &stats)
virtual void fromRecord(const casacore::Record &record)
PlotColor()
Constructor.
static const casacore::String REC_ITALICS
Definition: PlotOptions.h:286
PlotCoordinate m_upperLeft
Upper-left coordinate.
Definition: PlotOptions.h:721
virtual casacore::Record toRecord() const
RECORD METHODS //.
virtual void setPointSize(double size)=0
Sets the point size of this font to the given.
~PlotRegion()
Destructor.
static std::vector< Type > supportedFormats()
Returns all supported export formats.
static const casacore::String REC_ALPHA
Definition: PlotOptions.h:192
virtual void fromRecord(const casacore::Record &record)
casacore::CountedPtr< PlotLine > PlotLinePtr
Definition: PlotOptions.h:446
virtual int pixelSize() const =0
Returns the pixel size of this font, or -1 if the size was set in points.
virtual void setColor(const PlotColor &color)
Convenience method for setting color of both line and area fill.
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 bool operator!=(const PlotLine &rh) const
Returns true if this PlotLine is NOT equal to the given; false otherwise.
virtual PlotAreaFillPtr areaFill() const =0
Returns a copy of the area fill for this symbol.
virtual casacore::Record toRecord() const
RECORD METHODS //.
virtual void setSize(double width, double height, bool heightIsPixel=true)=0
Sets the size of the symbol in pixels.
unsigned int m_stackIndex
casacore::Stack index.
Definition: PlotOptions.h:806
static const casacore::String REC_PIXELSIZE
Definition: PlotOptions.h:283
void move(int delta)
Moves the stack index the given delta.
virtual PlotColor & operator=(const PlotColor &rh)
OPERATORS //.
virtual void setAreaFill(const PlotAreaFill &fill)=0
Sets the area fill of this symbol to the given.
PtrHolder< T > & operator=(const PtrHolder< T > &other)
LatticeExprNode operator!=(const LatticeExprNode &left, const LatticeExprNode &right)
const PlotAxisBitset all_four_sides
Definition: PlotOptions.h:72
virtual bool operator==(const PlotSymbol &rh) const
Returns true if this PlotSymbol is equal to the given; false otherwise.
static const casacore::String REC_BOLD
Definition: PlotOptions.h:287
static const casacore::String REC_HEIGHTISPIXEL
Definition: PlotOptions.h:592
virtual void setLine(const PlotLine &color)=0
Sets the outline of this symbol to the given.
Abstract class for area fill.
Definition: PlotOptions.h:296
static const casacore::String REC_POINTSIZE
casacore::Record key names.
Definition: PlotOptions.h:282
virtual bool operator!=(const PlotSymbol &rh) const
Returns true if this PlotSymbol is NOT equal to the given; false otherwise.
PlotAxis currentXAxis() const
Returns the x-axis for the current region in the stack.
Type type
Public Members.
Definition: PlotOptions.h:871
std::vector< std::pair< PlotAxis, PlotAxis > > m_axes
Axes stack.
Definition: PlotOptions.h:803
virtual PlotLine & operator=(const PlotLine &rh)
OPERATORS //.
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
virtual void setAsName(const casacore::String &name)
Set&#39;s this color&#39;s value to the given named color.
virtual bool bold() const =0
virtual PlotFont & operator=(const PlotFont &rh)
OPERATORS //.
Pattern
Pattern enum, similar in spirit to http://doc.trolltech.com/4.3/qt.html#BrushStyle-enum.
Definition: PlotOptions.h:300
static casacore::String extensionFor(Type t)
Gives/converts the standard extension for export types.
PlotLine()
Non-Static //.
virtual ~PlotFont()
Destructor.
virtual void setBold(bool b=true)=0
virtual double alpha() const =0
Returns this color&#39;s alpha as a value between 0 (transparent) and 1 (opaque).
size_t size() const
double left() const
Returns the left x value.
static const casacore::String REC_LINE
Definition: PlotOptions.h:595
static const casacore::String REC_COLOR
Definition: PlotOptions.h:285
virtual ~PlotColor()
Destructor.
PlotAreaFill()
Constructor.
virtual PlotLinePtr line() const =0
Returns a copy of the line for the outline of this symbol.
virtual bool operator==(const PlotAreaFill &rh) const
Returns true if this PlotAreaFill is equal to the given; false otherwise.
virtual casacore::Record toRecord() const
RECORD METHODS //.
TableExprNode pattern(const TableExprNode &node)
Definition: ExprNode.h:1444
unsigned int stackIndex() const
Returns the current stack index.
static const casacore::String REC_AREAFILL
Definition: PlotOptions.h:596
static const casacore::String REC_COLOR
Definition: PlotOptions.h:597
static const casacore::String REC_HEIGHT
Definition: PlotOptions.h:591
virtual void setFontFamily(const casacore::String &font)=0
Sets the font family to the given.
~PlotAxesStack()
Destructor.
virtual void setAlpha(double a)=0
Sets this color&#39;s alpha as a value between 0 (transparent) and 1 (opaque).
virtual unsigned short symbolUChar() const =0
Returns the character unicode for this symbol.
virtual void fromRecord(const casacore::Record &record)
double top() const
Returns the top y value.
virtual casacore::Record toRecord() const
RECORD METHODS //.
PlotCoordinate m_lowerRight
Lower-right coordinate.
Definition: PlotOptions.h:724
const PlotAxisBitset none_sides
Definition: PlotOptions.h:73
PlotRegion()
Default constructor.
casacore::CountedPtr< PlotSymbol > PlotSymbolPtr
Definition: PlotOptions.h:604
virtual double width() const =0
ABSTRACT METHODS //.
virtual psize_t size() const =0
ABSTRACT METHODS //.
casacore::String currentColor
Definition: PlotOptions.h:602
static Type typeForExtension(casacore::String file, bool *ok=NULL)
virtual void setAsHexadecimal(const casacore::String &hex)
CONVENIENCE METHODS //.
A PlotAxesStack is basically a list of PlotRegions as well as axis information that provides stack fu...
Definition: PlotOptions.h:735
casacore::String getColor() const
Abstract class for a line.
Definition: PlotOptions.h:368
virtual Pattern pattern() const =0
Returns the pattern for this area fill.
PlotAxis currentYAxis() const
Returns the y-axis for the current region in the stack.
static casacore::String exportFormat(Type t)
Converts to/from a Type and its casacore::String representation.
static const casacore::String REC_WIDTH
casacore::Record key names.
Definition: PlotOptions.h:590
std::vector< std::pair< PlotAxis, PlotAxis > > stackAxes() const
Returns a copy of the stack axes.
static const casacore::String REC_COLOR
casacore::Record key names.
Definition: PlotOptions.h:360
Style
Static //.
Definition: PlotOptions.h:373
virtual void setHeightIsPixel(bool pixel=true)=0
PlotCursor
Enum for cursors.
Definition: PlotOptions.h:94
virtual void setColor(const PlotColor &color)=0
Sets the color of this font to the given.
PlotAxis
Enum for the four plot axes.
Definition: PlotOptions.h:62
void shrinkStacks(unsigned int n)
Shrinks the region and axes stack to the given size, discarding the oldest UNLESS the stack index is ...
A hierarchical collection of named fields of various types.
Definition: Record.h:180
PlotExportFormat contains parameters for exporting a canvas to a file.
Definition: PlotOptions.h:817
Abstract class for a symbol.
Definition: PlotOptions.h:451
static const casacore::String REC_SYMBOL
Definition: PlotOptions.h:593
int lengthLimit() const
Gets/Sets the length limit on this stack.
PlotRegion moveAndReturn(int delta)
Moves the stack index the given delta (see move()) and returns the current region.
PlotAxesStack(int lengthLimit=-1)
Constructor for empty stack.
std::vector< PlotRegion > stack() const
Returns a copy of the stack.
virtual casacore::Record toRecord() const
RECORD METHODS //.
virtual PlotColorPtr color() const =0
ABSTRACT METHODS //.
static const casacore::String REC_FAMILY
Definition: PlotOptions.h:284
virtual void setItalics(bool i=true)=0
virtual double pointSize() const =0
ABSTRACT METHODS //.
virtual void setSymbol(Symbol symbol)=0
Sets the symbol style to the given.
virtual bool operator==(const PlotColor &rh) const
Returns true if this PlotColor is equal to the given; false otherwise.
virtual char symbolChar() const =0
Returns the character for this symbol.
virtual casacore::String asHexadecimal() const =0
ABSTRACT METHODS //.
virtual bool operator!=(const PlotAreaFill &rh) const
Returns true if this PlotAreaFill is NOT equal to the given; false otherwise.
casacore::CountedPtr< PlotFont > PlotFontPtr
Definition: PlotOptions.h:291
static const casacore::String REC_UCHAR
Definition: PlotOptions.h:594
Symbol
Static //.
Definition: PlotOptions.h:456
std::pair< double, double > prange_t
Typedef for range, which is two doubles (min and max).
Definition: PlotOptions.h:41
virtual casacore::String fontFamily() const =0
Returns the font family.
std::pair< double, double > psize_t
Typedef for size, which is two doubles (width and height).
Definition: PlotOptions.h:44
bool isValid() const
Returns whether the stack is valid (has size &gt; 0) or not.
SortDirection
Definition: PlotOptions.h:52
AngleFormat
Enum for angle formats.
Definition: PlotOptions.h:87
unsigned int size() const
Returns the stack size.
static std::vector< casacore::String > supportedFormatStrings()
virtual ~PlotSymbol()
PlotSymbol(const PlotSymbol&amp; copy);.
const Double c
Fundamental physical constants (SI units):
virtual PlotAreaFill & operator=(const PlotAreaFill &rh)
OPERATORS //.
const PlotCoordinate & upperLeft() const
Returns the upper left coordinate.
PlotSymbol()
Non-Static //.
static const casacore::String REC_WIDTH
casacore::Record key names.
Definition: PlotOptions.h:441
virtual void fromRecord(const casacore::Record &record)
virtual Symbol symbol() const =0
Returns the symbol style.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Bool operator==(const MVTime &lh, const MVTime &rh)
is equal operator, uses operator Double which returns days
Definition: MVTime.h:465
virtual void setColor(const PlotColor &color)=0
Sets this line&#39;s color to the given.
const PlotCoordinate & lowerRight() const
Returns the lower right coordinate.
virtual bool heightIsPixel() const =0
Gets/Sets whether the set height is in pixels or points, ONLY for character symbols.
void addRegion(const PlotRegion &region, PlotAxis xAxis, PlotAxis yAxis)
Adds the given region to the stack.
virtual void setPixelSize(int size)=0
Sets the pixel size of this font to the given.
std::vector< PlotRegion > m_stack
Region stack.
Definition: PlotOptions.h:800
virtual void setAsHexadecimalOrName(const casacore::String &str)=0
If the given casacore::String is a hexadecimal value, sets the color to it.
void setBase(const PlotRegion &base, PlotAxis xAxis, PlotAxis yAxis)
Resets the stack and sets the stack base to the given.
virtual ~PlotAreaFill()
Destructor.
virtual bool operator!=(const PlotFont &rh) const
Returns true if this PlotFont is NOT equal to the given; false otherwise.
virtual bool operator!=(const PlotColor &rh) const
Returns true if this PlotColor is NOT equal to the given; false otherwise.
Abstract class for fonts.
Definition: PlotOptions.h:200
static const casacore::String REC_STYLE
Definition: PlotOptions.h:442
double bottom() const
Returns the bottom y value.
casacore::String location
Definition: PlotOptions.h:873
PlotAxisScale
Enum for possible axis scales.
Definition: PlotOptions.h:78
void clearStack(bool keepBase=false)
Clears the stack, including the base if keepBase is false.
PlotExportFormat(Type t, const casacore::String &file)
Non-Static //.
virtual void setStyle(Style style)=0
Sets the style to the given.
double right() const
Returns the right x value.
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
virtual bool operator==(const PlotLine &rh) const
Returns true if this PlotLine is equal to the given; false otherwise.
A PlotRegion is basically just a wrapper for two PlotCoordinates: an upper left coordinate and a lowe...
Definition: PlotOptions.h:682
int m_lengthLimit
Length limit.
Definition: PlotOptions.h:797
static const casacore::String REC_HEXADECIMAL
casacore::Record key names.
Definition: PlotOptions.h:191
static std::vector< casacore::String > supportedImageFormatStrings()
PlotCanvasLayer
The canvas is composed of multiple layers, where changing/adding items from one layer will not affect...
Definition: PlotOptions.h:109
static std::vector< Type > supportedImageFormats()
Returns all supported image formats.
virtual PlotSymbol & operator=(const PlotSymbol &rh)
OPERATORS //.
virtual ~PlotLine()
Destructor.
static const casacore::String REC_UNDERLINE
Definition: PlotOptions.h:288
virtual void setUSymbol(unsigned short unicode)=0
Sets the symbol character unicode to the given.
~PlotExportFormat()
Destructor.
virtual bool operator==(const PlotFont &rh) const
Returns true if this PlotFont is equal to the given; false otherwise.
virtual void setPattern(Pattern pattern)=0
Sets the pattern for this area fill to the given.
const casacore::String DEFAULT_COLOR
Definition: PlotOptions.h:601
void setLengthLimit(int lengthLimit)
virtual casacore::String asName() const =0
Returns this color&#39;s value as a human-readable name if applicable, or an empty casacore::String if in...
virtual void fromRecord(const casacore::Record &record)
virtual Style style() const =0
Returns this line&#39;s style.
Defines nreal time structures used by the VLA table filler.
Definition: nreal.h:100
Resolution
Whether to have high resolution or not.
Definition: PlotOptions.h:828