casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DSText.h
Go to the documentation of this file.
1 //# Text.h: Text implementation for "DisplayShapes"
2 //# Copyright (C) 1998,1999,2000,2001,2002
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 
28 #ifndef TRIALDISPLAY_DSTEXT_H
29 #define TRIALDISPLAY_DSTEXT_H
30 
31 #include <casa/aips.h>
32 
35 
36 #include <casa/Arrays/Matrix.h>
37 #include <casa/Arrays/Vector.h>
38 
39 namespace casa { //# NAMESPACE CASA - BEGIN
40 
41  class DParameterString;
42  class DParameterFontChoice;
43  class DParameterMapKeyChoice;
44  template <class T> class DParameterRange;
45 
46 // <summary>
47 // Implementation of text.
48 // </summary>
49 //
50 // <prerequisite>
51 // <li> <linkto class="DisplayShape">DisplayShape</linkto>
52 // </prerequisite>
53 //
54 // <etymology>
55 // DSText is a method of managing the drawing of text onto a PixelCanvas.
56 // </etymology>
57 //
58 // <synopsis>
59 // DSText is designed to have the same interface as any other 'shape'
60 // extending DisplayShape. Much of the functionality is exactly the same,
61 // and hence provides a usefull wrapper for text in an 'annotations' context.
62 //
63 // There are generally two ways to make DisplayShape(s); To create them in
64 // "one hit" by providing arguments to the constructor, or by using the
65 // default constructor and then the "setOptions" method. A simple interface
66 // for all classes inheriting from the
67 // <linkto class="DisplayShape">DisplayShape</linkto> class is provided
68 // by <linkto class="DisplayShapeInterface">DisplayShapeInterface</linkto>.
69 // </synopsis>
70 //
71 // <motivation>
72 // To create a text wrapper which behaved in the same was as any other
73 // DisplayShape
74 // </motivation>
75 //
76 // <example>
77 // <srcblock>
78 // </srcblock>
79 // </example>
80 
81 
82  class DSText : public DisplayShape {
83 
84  public:
85 
86  // Constructors and destructors
87  // <group>
88  DSText();
89  DSText(const DSText& other);
90  DSText(const casacore::Float& xPos, const casacore::Float& yPos, const casacore::String& text = "Label",
91  const casacore::Bool& hasHandles = true, const casacore::Bool& drawHandles = true);
92 
93  virtual ~DSText();
94  // </group>
95 
96  // Functions to ensure consistancy with the "DisplayShape" interface.
97  // <group>
98  virtual void draw(PixelCanvas* pix);
99  virtual void move(const casacore::Float& dX, const casacore::Float& dY);
100  virtual void rotate(const casacore::Float& angle);
101  virtual casacore::Bool inObject(const casacore::Float& xPos, const casacore::Float& yPos);
102  virtual void changePoint(const casacore::Vector<casacore::Float>& newPos);
103  virtual void changePoint(const casacore::Vector<casacore::Float>& newPos, const casacore::Int nPoint);
104  virtual void scale(const casacore::Float& scaleFactor);
105  virtual void setCenter(const casacore::Float& xPos, const casacore::Float& yPos);
107  // </group>
108 
109  // Get and set options
110  // <group>
111  virtual casacore::Record getOptions();
112  virtual casacore::Bool setOptions(const casacore::Record& settings);
113  // </group>
114 
115 
116  private:
117  // This is a bit messy, so seperate it out
118  void makeAlignmentChoice();
119 
120  // Update handle positions
121  virtual void calculateHandlePositions();
122 
123  // Cast from int to enum
124  Display::TextAlign toEnum(const casacore::Int fromInt);
125 
126  // Text Parameter
128 
129  // Angle Param
134 
135  // Rotate about a point.. overloaded but not used
144  virtual void setDefaultOptions();
145 
146 
147  };
148 
149 } //# NAMESPACE CASA - END
150 
151 #endif
152 
153 
154 
int Int
Definition: aipstype.h:50
virtual casacore::Vector< casacore::Float > getCenter()
Returns the center of the DisplayShape (x,y).
casacore::Matrix< casacore::Float > itsHandleLocation
Definition: DSText.h:142
virtual void draw(PixelCanvas *pix)
Functions to ensure consistancy with the &quot;DisplayShape&quot; interface.
DParameterString * itsString
Text Parameter.
Definition: DSText.h:127
DParameterRange< casacore::Float > * itsAngle
Angle Param.
Definition: DSText.h:130
TextAlign
Text Alignment.
Definition: DisplayEnums.h:181
casacore::Bool itsValid
Definition: DSText.h:138
Implementation of DParameterChoice to store font selection parameters.
casacore::Vector< casacore::Float > itsCenter
Rotate about a point.
Definition: DSText.h:136
virtual void rotate(const casacore::Float &angle)
Rotate the shape about its center by a set angle (angle in degrees).
void makeAlignmentChoice()
This is a bit messy, so seperate it out.
Implementation of text.
Definition: DSText.h:82
virtual void move(const casacore::Float &dX, const casacore::Float &dY)
virtual void setDefaultOptions()
Set default options.
Base class defining interface to pixel-based output devices.
Definition: PixelCanvas.h:161
Display::TextAlign itsAlign
Definition: DSText.h:143
DSText()
Constructors and destructors.
casacore::Int itsPixHeight
Definition: DSText.h:137
casacore::Float itsStringLength
Definition: DSText.h:140
The abstract base class for all &quot;DisplayShapes&quot;.
Definition: DisplayShape.h:77
DParameterFontChoice * itsFont
Definition: DSText.h:132
DParameterMapKeyChoice * itsAlignment
Definition: DSText.h:131
virtual casacore::Bool setOptions(const casacore::Record &settings)
virtual casacore::Bool inObject(const casacore::Float &xPos, const casacore::Float &yPos)
Is the supplied point within the DisplayShape?
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Bool itsValidPositions
Definition: DSText.h:139
Implementation of DisplayParameter to store casacore::String parameters.
float Float
Definition: aipstype.h:54
casacore::Bool itsHandlesMade
Definition: DSText.h:139
virtual void setCenter(const casacore::Float &xPos, const casacore::Float &yPos)
Sets the center of the DisplayShape.
virtual ~DSText()
virtual casacore::Record getOptions()
Get and set options.
Implementation of DParameterChoice to store parameter and associated key.
Display::TextAlign toEnum(const casacore::Int fromInt)
Cast from int to enum.
virtual void scale(const casacore::Float &scaleFactor)
Scale the shape about its center by the scaleFactor.
virtual void calculateHandlePositions()
Update handle positions.
casacore::Float itsStringHeight
Definition: DSText.h:141
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual void changePoint(const casacore::Vector< casacore::Float > &newPos)
Changes the closest point to the supplied location to that location.
casacore::Int itsPixWidth
Definition: DSText.h:137
DParameterRange< casacore::Int > * itsFontSize
Definition: DSText.h:133