casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MultiWCHolder.h
Go to the documentation of this file.
1 //# MultiWCHolder.h: Holder of multiple WorldCanvasHolders for panelling
2 //# Copyright (C) 2000,2001,2003
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_MULTIWCHOLDER_H
29 #define TRIALDISPLAY_MULTIWCHOLDER_H
30 
31 #include <list>
32 #include <casa/aips.h>
35 
36 namespace casacore{
37 
38  class String;
39 }
40 
41 namespace casa { //# NAMESPACE CASA - BEGIN
42 
43  class WorldCanvasHolder;
44  class DisplayData;
45  class AttributeBuffer;
46 
47 // <summary>
48 // A holder of WorldCanvasHolders to use for panelling applications.
49 // </summary>
50 //
51 // <use visibility=export>
52 //
53 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
54 // </reviewed>
55 //
56 // <prerequisite>
57 // <li><linkto class="WorldCanvasHolder">WorldCanvasHolder</linkto>
58 // <li><linkto class="DisplayData">DisplayData</linkto>
59 // <li><linkto class="Attribute">Attribute</linkto>
60 // <li><linkto class="AttributeBuffer">AttributeBuffer</linkto>
61 // </prerequisite>
62 //
63 // <etymology>
64 // The MultiWCHolder holds a number of WorldCanvasHolders to simplify
65 // panelling operations.
66 // </etymology>
67 //
68 // <synopsis>
69 // This class is a holder of <linkto
70 // class=WorldCanvasHolder>WorldCanvasHolder</linkto> objects. It
71 // exists to facilitate the management of multiple WorldCanvasHolders
72 // having in common a set of restrictions, which for example may be
73 // for controlling animation, and on which a common set of
74 // DisplayDatas may be registered and displayed.
75 //
76 // The basic interface to the MultiWCHolder provides methods for
77 // adding and removing individual WorldCanvasHolder objects, for
78 // globally registering and unregistering DisplayData objects for
79 // display on the WorldCanvasHolder objects, and for applying a set
80 // of restrictions to the WorldCanvasHolder objects.
81 //
82 // At a more advanced level, functions exist to distribute varying
83 // restrictions across all the WorldCanvasHolder objects. For
84 // example, the programmer can use
85 // <src>linearDistributeRestriction</src> to apply a restriction to
86 // each WorldCanvasHolder, where the value of the restriction is
87 // incremented by a fixed amount between each WorldCanvasHolder. This
88 // would be useful, for example, to easily display a set of planes
89 // from a multi-frequency image on a number of WorldCanvases whose
90 // WorldCanvasHolders have been added to a MultiWCHolder.
91 // </synopsis>
92 //
93 // <example>
94 // </example>
95 //
96 // <motivation>
97 // </motivation>
98 
99  class MultiWCHolder {
100 
101  public:
102 
103  // Constructor which makes an empty MultiWCHolder.
104  MultiWCHolder();
105 
106  // Constructor which makes a MultiWCHolder containing the single
107  // specified WorldCanvasHolder.
109 
110  // Destructor.
111  virtual ~MultiWCHolder();
112 
113  // Add or remove a WorldCanvasHolder, or remove all
114  // WorldCanvasHolders on this MultiWCHolder. <src>holder</src> is
115  // added at the end of the list. When a new WorldCanvasHolder is
116  // added, it will automatically have all registered DisplayDatas
117  // added to it.
118  // <group>
119  virtual void addWCHolder(WorldCanvasHolder& holder);
120  virtual void removeWCHolder(WorldCanvasHolder& holder);
121  virtual void removeWCHolders();
122  // </group>
123 
124  // Add or remove a DisplayData, or remove all DisplayDatas on this
125  // MultiWCHolder.
126  // <group>
127  virtual void addDisplayData(DisplayData& displaydata, int position = -1);
128  virtual void removeDisplayData(DisplayData& displaydata);
129  virtual void removeDisplayDatas();
130  // </group>
131 
132  // Install or remove a single restriction, or a buffer of
133  // restrictions, on all of the WorldCanvasHolders managed by this
134  // MultiWCHolder.
135  // <group>
136  virtual void setRestriction(const Attribute& restriction);
137  virtual void setRestrictions(const AttributeBuffer& restrictions);
138  virtual void removeRestriction(const casacore::String& name);
139  virtual void removeRestrictions();
140  // </group>
141 
142  // Incrementally distribute restrictions to all of the
143  // WorldCanvasHolders. The value of the restrictions are
144  // incremented by the given amount for each holder beyond the first
145  // one. The given restrictions may have tolerances, and the base
146  // types of each restriction and increment must be identical. That
147  // is, <src>restriction.getType() == increment.getType()</src>.
148  // Other methods to distribute restrictions in other ways are easily
149  // imagined, eg. a vector of Attributes is given. After being
150  // called, <src>restrictions</src> are equal to the values set on
151  // the final WorldCanvasHolder in the list.
152 
153  //# DK note: only this routine and removeRestriction() should be used
154  //# with the 'bIndex' restriction; none of the other restriction routines
155  //# have yet been modified to add an ID to the 'bIndex' restriction name.
156  //# (The routines are normally called simply using the unmodified name
157  //# 'bIndex').
158  virtual void setLinearRestrictions(AttributeBuffer &restrictions,
159  const AttributeBuffer &increments);
160 
161  // Hold and release response to refreshes requested with the
162  // <src>refresh()</src> member function. Multiple calls to
163  // <src>hold()</src> can be made, and refreshes will not resume
164  // until the same number of calls have been made to
165  // <src>release()</src>. Note that these functions do not affect
166  // whether internally (implicitly) generated refreshes continue to
167  // occur. That is, refresh events due to PixelCanvas resize events,
168  // or Colormap changes, for example, will continue to be acted upon.
169  // <group>
170  virtual void hold();
171  virtual void release();
172  // </group>
173 
174  // Distribute a refresh event to all the held WorldCanvasHolders.
175  virtual void refresh(const Display::RefreshReason &reason =
177 
178  virtual casacore::uInt zLength();
179 
180  // These orrespond to 'zIndex, zLength' for animator's 'blink mode'.
181  virtual casacore::Int bLength();
182  virtual casacore::Int bIndex();
183 
184  //Sets whether the viewer is in blink mode.
185  void setBlinkMode( bool blinkMode );
186 
187  // Determines which DDs will be restricted, which are always active.
188  virtual casacore::Bool isBlinkDD(DisplayData *dd);
189 
190  // Test conformance of a DD to a WCH of this MWCH (by default, test
191  // against the first one (WCH 0), which always exists).
192  // The three aspects of conformance can be selectively tested.
193  virtual casacore::Bool conforms(DisplayData* dd,
194  casacore::Bool testRstrs=true, casacore::Bool testCS=true, casacore::Bool testZ=true,
195  casacore::Int wchIndex=0);
196 
197  // Return number of WCHs (subpanels).
198  virtual casacore::Int nWCHs() {
199  return casacore::Int(itsWCHList.size( ));
200  }
201 
202  // Clear PC in MWCH's area (not implemented on this level).
203  virtual void clear() { }
204 
205  // Added to collect region statistics from MultiRectTool::update_stats( )...
206  std::list<DisplayData*> &displayDatas( ) {
207  return itsDDList;
208  }
209 
210  protected:
211 
212  // Copy constructor - construct a new MultiWCHolder from
213  // <src>other</src>.
214  // MultiWCHolder(const MultiWCHolder &other);
215 
216  // Copy assignment using copy semantics.
217  // MultiWCHolder &operator==(const MultiWCHolder &other);
218 
219  // (permanently) sets itsBIndexName (below). Called only in constructor.
220  virtual void setBIndexName();
221 
222  // Adjust name of "bIndex" Attribute (if any) to indlude ID of this MWCH.
223  virtual void adjustBIndexName(AttributeBuffer& rstrs);
224 
225 
226 
227  private:
228 
229  // The list of WorldCanvasHolders that are managed by this
230  // MultiWCHolder.
231  std::list<WorldCanvasHolder*> itsWCHList;
232 
233  // The list of DisplayDatas that are managed by this MultiWCHolder.
234  std::list<DisplayData*> itsDDList;
235 
236  // Subset of above DDs which will have blinking restrictions added
237  // (Countour plots, e.g., do not; they always display). This should
238  // actually be a casacore::Block<DisplayData*>.
240 
241  // Number of DDs above.
243 
244  // Index of DD to show in first WCH when blink mode is active (it is
245  // kept up-to-date in any case).
247 
248  // The (unchanging) name of the blink restriction: "bIndex" followed by
249  // an ID unique to this MWCH. The ID is because DDs can be registered on
250  // more than one MWCH and need a different "bIndex" restriction on each one.
251  // Note, however, that when setLinearRestrictions() is used externally to
252  // set the blink restriction onto the WCHs, it simply uses the name
253  // "bIndex".
255 
256  // The buffer of attributes which are presently installed on the
257  // registered WorldCanvasHolders.
259 
260  // The current hold count of this MultiWCHolder. Whenever new
261  // WCHolders are added, their count is increased to this value.
262  // Calls to hold() and release() modify this count as well as
263  // those per canvas.
265 
266  // The current state of whether a refresh was held up or not.
268 
269  // The reason for the held-up refresh event
271 
272  // Do we already have this WorldCanvasHolder/DisplayData registered?
273  // <group>
275  casacore::Bool isAlreadyRegistered(const DisplayData &displaydata);
276  // </group>
277 
278  // Add/remove all the DisplayDatas to/from a WorldCanvasHolder.
279  // <group>
282  const casacore::Bool& permanent = false);
283  // </group>
284 
285  // Add/remove a DisplayData to/from all WorldCanvasHolders.
286  // <group>
287  void addToAllWorldCanvasHolders(DisplayData &displaydata, int position);
288  void removeFromAllWorldCanvasHolders(DisplayData &displaydata);
289  // </group>
290 
291  // Distribute restrictions to all WorldCanvasHolders.
292  void distributeRestrictions();
293 
294  // Set restrictions on a particular WorldCanvasHolder.
296 
297 
298  };
299 
300 
301 } //# NAMESPACE CASA - END
302 
303 #endif
casacore::Bool itsRefreshHeld
The current state of whether a refresh was held up or not.
Display::RefreshReason itsHeldReason
The reason for the held-up refresh event.
int Int
Definition: aipstype.h:50
std::list< DisplayData * > & displayDatas()
Added to collect region statistics from MultiRectTool::update_stats()...
virtual casacore::Bool conforms(DisplayData *dd, casacore::Bool testRstrs=true, casacore::Bool testCS=true, casacore::Bool testZ=true, casacore::Int wchIndex=0)
Test conformance of a DD to a WCH of this MWCH (by default, test against the first one (WCH 0)...
virtual void setLinearRestrictions(AttributeBuffer &restrictions, const AttributeBuffer &increments)
Incrementally distribute restrictions to all of the WorldCanvasHolders.
virtual void addDisplayData(DisplayData &displaydata, int position=-1)
Add or remove a DisplayData, or remove all DisplayDatas on this MultiWCHolder.
AttributeBuffer itsAttributes
The buffer of attributes which are presently installed on the registered WorldCanvasHolders.
Buffer for storing Attributes.
virtual void hold()
Hold and release response to refreshes requested with the refresh() member function.
virtual void removeDisplayData(DisplayData &displaydata)
virtual void addWCHolder(WorldCanvasHolder &holder)
Add or remove a WorldCanvasHolder, or remove all WorldCanvasHolders on this MultiWCHolder.
std::list< DisplayData * > itsDDList
The list of DisplayDatas that are managed by this MultiWCHolder.
virtual casacore::uInt zLength()
MultiWCHolder()
Constructor which makes an empty MultiWCHolder.
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
Arbitrary name-value pairs used in the display classes.
Definition: Attribute.h:144
std::list< WorldCanvasHolder * > itsWCHList
The list of WorldCanvasHolders that are managed by this MultiWCHolder.
virtual void removeRestrictions()
virtual void clear()
Clear PC in MWCH&#39;s area (not implemented on this level).
virtual casacore::Int bLength()
These orrespond to &#39;zIndex, zLength&#39; for animator&#39;s &#39;blink mode&#39;.
void setBlinkMode(bool blinkMode)
Sets whether the viewer is in blink mode.
virtual void setRestriction(const Attribute &restriction)
Install or remove a single restriction, or a buffer of restrictions, on all of the WorldCanvasHolders...
virtual casacore::Int nWCHs()
Return number of WCHs (subpanels).
casacore::Block< void * > itsBlinkDDs
Subset of above DDs which will have blinking restrictions added (Countour plots, e.g., do not; they always display).
virtual void refresh(const Display::RefreshReason &reason=Display::UserCommand)
Distribute a refresh event to all the held WorldCanvasHolders.
virtual void setBIndexName()
Copy constructor - construct a new MultiWCHolder from other.
virtual casacore::Bool isBlinkDD(DisplayData *dd)
Determines which DDs will be restricted, which are always active.
virtual void removeWCHolder(WorldCanvasHolder &holder)
virtual void release()
virtual casacore::Int bIndex()
void distributeRestrictions()
Distribute restrictions to all WorldCanvasHolders.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
A holder of WorldCanvasHolders to use for panelling applications.
Definition: MultiWCHolder.h:99
virtual void removeWCHolders()
void installRestrictions(WorldCanvasHolder &holder)
Set restrictions on a particular WorldCanvasHolder.
virtual void removeDisplayDatas()
RefreshReason
Callback reasons for PCRefreshEvent and WCRefreshEvent.
Definition: DisplayEnums.h:267
casacore::Bool isAlreadyRegistered(const WorldCanvasHolder &holder)
Do we already have this WorldCanvasHolder/DisplayData registered?
void addAllDisplayDatas(WorldCanvasHolder &holder)
Add/remove all the DisplayDatas to/from a WorldCanvasHolder.
A holder to interface between DisplayDatas and a WorldCanvas.
void removeFromAllWorldCanvasHolders(DisplayData &displaydata)
casacore::Int itsHoldCount
The current hold count of this MultiWCHolder.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::String itsBIndexName
The (unchanging) name of the blink restriction: &quot;bIndex&quot; followed by an ID unique to this MWCH...
void removeAllDisplayDatas(WorldCanvasHolder &holder, const casacore::Bool &permanent=false)
virtual void adjustBIndexName(AttributeBuffer &rstrs)
Adjust name of &quot;bIndex&quot; Attribute (if any) to indlude ID of this MWCH.
casacore::Int itsBLength
Number of DDs above.
void addToAllWorldCanvasHolders(DisplayData &displaydata, int position)
Add/remove a DisplayData to/from all WorldCanvasHolders.
Base class for display objects.
Definition: DisplayData.h:317
virtual void setRestrictions(const AttributeBuffer &restrictions)
virtual ~MultiWCHolder()
Destructor.
virtual void removeRestriction(const casacore::String &name)
casacore::Int itsBIndex
Index of DD to show in first WCH when blink mode is active (it is kept up-to-date in any case)...
unsigned int uInt
Definition: aipstype.h:51
User told PixelCanvas to refresh via PixelCanvas refresh()
Definition: DisplayEnums.h:269
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42