casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WorldCanvasHolder.h
Go to the documentation of this file.
1 //# WorldCanvasHolder.h: Interface between DisplayDatas and a WorldCanvas
2 //# Copyright (C) 1996,1997,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_WORLDCANVASHOLDER_H
29 #define TRIALDISPLAY_WORLDCANVASHOLDER_H
30 
31 #include <casa/aips.h>
32 #include <list>
40 
41 namespace casacore{
42 
43  class String;
44 }
45 
46 namespace casa { //# NAMESPACE CASA - BEGIN
47 
48  class Attribute;
49  class DisplayData;
50 
51 // <summary>
52 // A holder to interface between DisplayDatas and a WorldCanvas
53 // </summary>
54 //
55 // <use visibility=export>
56 //
57 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
58 // </reviewed>
59 //
60 // <prerequisite>
61 // <li> Attribute
62 // <li> AttributeBuffer
63 // <li> WorldCanvas
64 // <li> DisplayData
65 // </prerequisite>
66 //
67 // <etymology>
68 // The WorldCanvasHolder "holds" a WorldCanvas and some number of
69 // DisplayDatas which are "registered" on the WorldCanvas. It actually
70 // registers itself to handle the WC events, and passes the events on to
71 // the DDs.
72 // </etymology>
73 //
74 // <synopsis>
75 // </synopsis>
76 //
77 // <example>
78 // </example>
79 //
80 // <motivation>
81 // </motivation>
82 
84  public WCMotionEH,
85  public WCPositionEH,
86  public WCSizeControlHandler,
87  public WCCoordinateHandler {
88 
89  public:
90 
91  // Constructor. A WorldCanvas must be provided for the constructed
92  // WorldCanvasHolder to "hold".
94 
95  // Destructor.
96  virtual ~WorldCanvasHolder();
97 
98  // Return the WorldCanvas which is held by this WorldCanvasHolder.
99  virtual WorldCanvas *worldCanvas() const {
100  return itsWorldCanvas;
101  }
102 
103  // Add a DisplayData object to the list of DisplayDatas registered
104  // on the held WorldCanvas by this WorldCanvasHolder.
105  virtual void addDisplayData(DisplayData *dData, int position);
106 
107  // Remove a DisplayData from the list of DisplayDatas which are
108  // registered by this WorldCanvasHolder for display on the held
109  // WorldCanvas. <src>ignoreRefresh</src> tells the DD not to refresh
110  // just to clean up DMs
111  virtual void removeDisplayData(DisplayData& dData,
112  casacore::Bool ignoreRefresh = false);
113 
114  // How many DisplayDatas are registered?
115  virtual casacore::uInt nDisplayDatas() const;
116 
117  // Install a single restriction, or a buffer of restrictions, on the
118  // WorldCanvasHolder which DisplayData must match in order that they
119  // be allowed to draw themselves.
120  // <group>
121  void setRestriction(const Attribute& restriction) {
122  std::cout<<"World canvas holder restriction="
123  <<restriction.getName().c_str()
124  << " value=" << restriction.getType() << std::endl;
125 
126  itsWorldCanvas->setRestriction(restriction);
127  }
128  void setRestrictions(const AttributeBuffer& resBuff) {
130  }
131  // </group>
132 
133  // Check if a named restriction exists.
135  return itsWorldCanvas->existRestriction(name);
136  }
137 
138  //Set whether or not the viewer is in blink mode
139  void setBlinkMode( bool mode ) {
140  blinkMode = mode;
141  }
142 
143  // Remove the named restriction, or all restrictions, from the
144  // WorldCanvasHolder.
145  // <group>
146  void removeRestriction(const casacore::String& restrictionName) {
147  itsWorldCanvas->removeRestriction(restrictionName);
148  }
151  }
152  // </group>
153 
154  // Determine whether the restrictions installed on the
155  // WorldCanvasHolder match the given restriction or buffer of
156  // restrictions.
157  // <group>
158  casacore::Bool matchesRestriction(const Attribute& restriction) const {
159  return itsWorldCanvas->matchesRestriction(restriction);
160  }
162  return itsWorldCanvas->matchesRestrictions(buffer);
163  }
164  // </group>
165 
166  // Return the buffer of restrictions installed on this
167  // WorldCanvasHolder.
170  }
171 
172  // Invoke a refresh on the WorldCanvas, ie. this is a shorthand for
173  // WorldCanvasHolder->worldCanvas()->refresh(reason);.
174  virtual void refresh(const Display::RefreshReason &reason =
176  const casacore::Bool &explicitrequest = true);
177 
178  // Handle size control requests originating from the WorldCanvas.
180 
181  // Distribute a WCPositionEvent originating from the held
182  // WorldCanvas over the DisplayDatas.
183  virtual void operator()(const WCPositionEvent &ev);
184 
185  // Distribute a WCRefreshEvent originating from the held WorldCanvas
186  // over the DisplayDatas.
187  virtual void operator()(const WCRefreshEvent &ev);
188 
189  // Distribute a WCMotionEvent originating from the held WorldCanvas
190  // over the DisplayDatas.
191  virtual void operator()(const WCMotionEvent &ev);
192 
193  // Handle other, generic types of events. As with the handlers above,
194  // WCH handles these new events by simply passing them on to the
195  // DisplayDatas registered on it. WorldCanvasHolder inherits this
196  // new-style event handling interface from DisplayEH, via WCRefreshEH.
197  virtual void handleEvent(DisplayEvent& ev);
198 
199  // casacore::Coordinate conversion routines, handled for the WorldCanvas.
200  // In future, they should be handled on the WC itself, via its own CS.
201  // At present, these requests are forwarded to the CSmaster DD, which
202  // should be equivalent in most cases.
203  // <group>
206 
207  //# (these latter two are merely to stop a compiler whine...)
210  return WCCoordinateHandler::linToWorld(world, failures, lin);
211  }
212 
214  const casacore::Matrix<casacore::Double> & world) {
215  return WCCoordinateHandler::worldToLin(lin, failures, world);
216  }
217  // </group>
218 
219  // Return the number of world axes, which is hard-wired to 2.
220  virtual casacore::uInt nWorldAxes() const {
221  return 2;
222  }
223 
224  // Maximum number of animation frames of all registered
225  // DDs which are valid for the WC's current CS state.
226  virtual casacore::uInt nelements();
227 
228  // Force a cleanup of all the DisplayDatas which are registered with
229  // this WorldCanvasHolder.
230  virtual void cleanup();
231 
232  // The DD in charge of setting WC coordinate state (0 if none).
233  const DisplayData* csMaster() const {
234  return itsWorldCanvas->csMaster( );
235  }
236 
237  // Is the specified DisplayData the one in charge of WC state?
238  // (During DD::sizeControl() execution, it means instead that the
239  // DD has permission to become CSmaster, if it can).
241  return itsWorldCanvas->isCSmaster(dd);
242  }
243  void clearCSMasterSettings( WorldCanvas* wCanvas, bool clearZoom = true );
244 
245  // Was the passed DD the last CS master (or, if no DD passed, was
246  // there any CS master)? For convenience of the DDs during the next
247  // sizeControl execution, in determining whether a CS master change is
248  // occurring, and whether anyone was master before. This affects
249  // whether any old zoom window is retained or completely reset.
251  return (dd==0)? itsLastCSmaster!=0 : itsLastCSmaster==dd;
252  }
253 
254  // used by PanelDisplay on new WCHs to keep a consistent CS master on
255  // all its main display WC[H]s. Sets [default] CS master dd to that of
256  // passed wch (if that dd is registered here), and gets it to reset WC
257  // coordinate state.
258  virtual casacore::Bool syncCSmaster(const WorldCanvasHolder* wch);
259  bool setCSMaster( DisplayData* dd );
260 
261  const std::list<DisplayData*> &displaylist( ) const {
262  return itsDisplayList;
263  }
264 
270 
272 
273  std::string errorMessage( ) const { return error_string; }
274 
275  private:
276  //true if the viewer is in blink mode.
277  bool blinkMode;
278 
279  // The WorldCanvas that is held by this WorldCanvasHolder.
281 
282  // A list containing the DisplayDatas that are registered on this
283  // WorldCanvasHolder.
284  std::list<DisplayData*> itsDisplayList;
286 
287  // The CS master in effect after executeSizeControl was last run (0 if none).
288  // For determining (via wasCSmaster(), above) whether a CS master change is
289  // occurring, and whether anyone was master before. This affects whether
290  // the old zoom window is retained or completely reset.
291  // (Note void*, rather than DD*, type: it is not intended to be dereferenced,
292  // just compared for equality. The original DD may not even exist by the
293  // time it is used).
296 
301  void labelAxes( const casacore::Vector<casacore::Bool>& conforms, const WCRefreshEvent &ev);
302  void labelAxesBlink( const casacore::Vector<casacore::Bool>& conforms, const WCRefreshEvent & ev );
303  void labelAxesNormal( const casacore::Vector<casacore::Bool>& conforms, const WCRefreshEvent & ev );
305  void clearSubstituteTitles( );
307  std::string error_string;
308  };
309 
310 } //# NAMESPACE CASA - END
311 
312 #endif
AttValue::ValueType getType() const
Return the DataType of the value of the Attribute.
virtual void cleanup()
Force a cleanup of all the DisplayDatas which are registered with this WorldCanvasHolder.
const DisplayData * csMaster() const
The DD in charge of setting WC coordinate state (0 if none).
std::string errorMessage() const
virtual casacore::Bool worldToLin(casacore::Vector< casacore::Double > &lin, const casacore::Vector< casacore::Double > &world)
transform the world point (N-dimensional) into a lin coordinate (2-dimensional), returning false if t...
Class which stores WorldCanvas refresh event information.
casacore::Vector< casacore::Bool > getConformance() const
virtual casacore::uInt nWorldAxes() const
Return the number of world axes, which is hard-wired to 2.
virtual WorldCanvas * worldCanvas() const
Return the WorldCanvas which is held by this WorldCanvasHolder.
casacore::Float getDrawUnit() const
Returns the current pgp draw unit, which depends on the x-range of the data currently being displayed...
Base class defining the interface to controlling the WorldCanvas size.
const DisplayData * csMaster() const
The DD in charge of setting WC coordinate state (0 if none).
Definition: WorldCanvas.h:1052
WorldCanvasHolder(WorldCanvas *canvas)
Constructor.
virtual casacore::Bool worldToLin(casacore::Vector< casacore::Double > &lin, const casacore::Vector< casacore::Double > &world)=0
transform the world point (N-dimensional) into a lin coordinate (2-dimensional), returning false if t...
const AttributeBuffer * restrictionBuffer() const
Return the buffer of restrictions installed on this WorldCanvasHolder.
void removeRestriction(const casacore::String &restrictionName)
Remove the named restriction, or all restrictions, from the WorldCanvasHolder.
Base class defining a set of transformations for WorldCanvas coordinates.
Buffer for storing Attributes.
Base class for handling WorldCanvas motion events.
Definition: WCMotionEH.h:70
virtual void refresh(const Display::RefreshReason &reason=Display::UserCommand, const casacore::Bool &explicitrequest=true)
Invoke a refresh on the WorldCanvas, ie.
virtual void operator()(const WCPositionEvent &ev)
Distribute a WCPositionEvent originating from the held WorldCanvas over the DisplayDatas.
casacore::String getTitleDDName(const casacore::Vector< casacore::Bool > &conforms) const
void labelAxes(const casacore::Vector< casacore::Bool > &conforms, const WCRefreshEvent &ev)
virtual void addDisplayData(DisplayData *dData, int position)
Add a DisplayData object to the list of DisplayDatas registered on the held WorldCanvas by this World...
void setRestriction(const Attribute &restriction)
Install a single restriction, or a buffer of restrictions, on the WorldCanvas which DisplayData must ...
casacore::Bool wasCSmaster(DisplayData *dd=0) const
Was the passed DD the last CS master (or, if no DD passed, was there any CS master)? For convenience of the DDs during the next sizeControl execution, in determining whether a CS master change is occurring, and whether anyone was master before.
casacore::Bool isCSmaster(const DisplayData *dd) const
Is the specified DisplayData the one in charge of WC state? (During DD::sizeControl() execution...
void setRestrictions(const AttributeBuffer &resBuff)
bool blinkMode
true if the viewer is in blink mode.
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
void clearCSMasterSettings(WorldCanvas *wCanvas, bool clearZoom=true)
virtual void removeDisplayData(DisplayData &dData, casacore::Bool ignoreRefresh=false)
Remove a DisplayData from the list of DisplayDatas which are registered by this WorldCanvasHolder for...
Arbitrary name-value pairs used in the display classes.
Definition: Attribute.h:144
casacore::Bool isCSmaster(const DisplayData *dd) const
Is the specified DisplayData the one in charge of WC state? (During DD::sizeControl() execution...
Definition: WorldCanvas.h:1062
virtual casacore::Bool syncCSmaster(const WorldCanvasHolder *wch)
used by PanelDisplay on new WCHs to keep a consistent CS master on all its main display WC[H]s...
Base class for handling WorldCanvas refresh events.
Definition: WCRefreshEH.h:95
casacore::Bool existRestriction(const casacore::String &name) const
Check if a named restriction exists.
void setRestrictions(const AttributeBuffer &resBuff)
virtual casacore::Bool linToWorld(casacore::Vector< casacore::Double > &world, const casacore::Vector< casacore::Double > &lin)=0
transform the lin point (2-dimensional) into a world coordinate (N-dimensional), returning false if t...
casacore::Bool matchesRestrictions(const AttributeBuffer &buffer) const
virtual ~WorldCanvasHolder()
Destructor.
casacore::Bool matchesRestriction(const Attribute &restriction) const
Determine whether the restrictions installed on the WorldCanvas match the given restriction or buffer...
WorldCanvas * itsWorldCanvas
The WorldCanvas that is held by this WorldCanvasHolder.
void removeRestrictions()
Class which stores WorldCanvas motion event information.
Definition: WCMotionEvent.h:79
casacore::Bool existRestriction(const casacore::String &name) const
Check if a named restriction exists.
const std::list< DisplayData * > & displaylist() const
casacore::Bool matchesRestriction(const Attribute &restriction) const
Determine whether the restrictions installed on the WorldCanvasHolder match the given restriction or ...
const Char * c_str() const
Get char array.
Definition: String.h:555
Class describing the most basic event information in the display classes.
Definition: DisplayEvent.h:82
bool setCSMaster(DisplayData *dd)
virtual casacore::Bool linToWorld(casacore::Matrix< casacore::Double > &world, casacore::Vector< casacore::Bool > &failures, const casacore::Matrix< casacore::Double > &lin)
Batch transformation where each row of lin is a coordinate that is transformed into each row of world...
void setBlinkMode(bool mode)
Set whether or not the viewer is in blink mode.
void setControllingTitle(const casacore::Vector< casacore::Bool > &conforms)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual casacore::Bool executeSizeControl(WorldCanvas *wCanvas)
Handle size control requests originating from the WorldCanvas.
casacore::String getName() const
Return the name of the Attribute.
casacore::Bool matchesRestrictions(const AttributeBuffer &buffer) const
float Float
Definition: aipstype.h:54
void * itsLastCSmaster
The CS master in effect after executeSizeControl was last run (0 if none).
DisplayData * getTitleDDBlink(const casacore::Vector< casacore::Bool > &conforms) const
RefreshReason
Callback reasons for PCRefreshEvent and WCRefreshEvent.
Definition: DisplayEnums.h:267
Class which stores WorldCanvas position event information.
A holder to interface between DisplayDatas and a WorldCanvas.
void labelAxesBlink(const casacore::Vector< casacore::Bool > &conforms, const WCRefreshEvent &ev)
Implementation of drawing in world coordinates on top of a PixelCanvas.
Definition: WorldCanvas.h:204
void removeRestriction(const casacore::String &restrictionName)
Remove the named restriction, or all restrictions, from the WorldCanvas.
casacore::String getTitle(DisplayData *dd) const
void labelAxesNormal(const casacore::Vector< casacore::Bool > &conforms, const WCRefreshEvent &ev)
std::list< DisplayData * > itsDisplayList
A list containing the DisplayDatas that are registered on this WorldCanvasHolder. ...
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void setRestriction(const Attribute &restriction)
Install a single restriction, or a buffer of restrictions, on the WorldCanvasHolder which DisplayData...
virtual casacore::uInt nDisplayDatas() const
How many DisplayDatas are registered?
virtual casacore::uInt nelements()
Maximum number of animation frames of all registered DDs which are valid for the WC&#39;s current CS stat...
virtual void handleEvent(DisplayEvent &ev)
Handle other, generic types of events.
Base class for handling WorldCanvas position events.
Definition: WCPositionEH.h:75
Base class for display objects.
Definition: DisplayData.h:317
virtual casacore::Bool linToWorld(casacore::Vector< casacore::Double > &world, const casacore::Vector< casacore::Double > &lin)
casacore::Coordinate conversion routines, handled for the WorldCanvas.
static const casacore::String BLINK_MODE
DisplayData * getTitleDDNormal(const casacore::Vector< casacore::Bool > &conforms) const
const AttributeBuffer * restrictionBuffer() const
Return the buffer of restrictions installed on this WorldCanvas.
unsigned int uInt
Definition: aipstype.h:51
User told PixelCanvas to refresh via PixelCanvas refresh()
Definition: DisplayEnums.h:269
virtual casacore::Bool worldToLin(casacore::Matrix< casacore::Double > &lin, casacore::Vector< casacore::Bool > &failures, const casacore::Matrix< casacore::Double > &world)
Batch transformation where each row of world is a coordinate that is transformed into each row of lin...
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42