casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TBView.h
Go to the documentation of this file.
1 //# TBView.h: Current "view" or state of the browser that can be serialized.
2 //# Copyright (C) 2005
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 TBVIEW_H_
28 #define TBVIEW_H_
29 
30 #include <vector>
31 
32 #include <xercesc/dom/DOM.hpp>
33 
34 #include <casa/BasicSL/String.h>
35 
36 using namespace xercesc;
37 
38 namespace casa {
39 
40 //# Forward Declarations
41 class TBFilterRuleSequence;
42 class TBFormat;
43 class QFontColor;
44 
45 // <summary>
46 // Current "view" or state of a single table.
47 // </summary>
48 //
49 // <synopsis>
50 // The TBTableView defines the state of an opened table and includes: the
51 // location, whether the table is the currently selected table, which
52 // columns are hidden, the visual index of each column, the loaded rows, the
53 // row filter (if any), the field formats (if any), and the sort order (if any).
54 // </synopsis>
55 
56 class TBTableView {
57 public:
58  // Default Constructor.
59  TBTableView();
60 
61  ~TBTableView();
62 
63 
64  // Location of the table.
66 
67  // Whether the table is currently selected.
68  bool selected;
69 
70  // Whether each column is hidden (true) or not (false).
71  std::vector<bool> hidden;
72 
73  // The visual index of each column in case they were moved.
74  std::vector<int> visInd;
75 
76  // The starting number of the loaded rows.
78 
79  // The number of loaded rows.
80  int loadedNum;
81 
82  // Row filter, or NULL if there is none.
84 
85  // The format for each field, or NULL if that field has none.
86  std::vector<TBFormat*> formats;
87 
88  // The current sort order, or an empty list if there is none.
89  std::vector<std::pair<casacore::String, bool> > sort;
90 
91  // Whether this table is from a TaQL command or not.
92  bool taql;
93 };
94 
95 // <summary>
96 // Current "view" or state of the browser that can be serialized.
97 // </summary>
98 //
99 // <synopsis>
100 // The TBView defines the state of the browser and includes: the last opened
101 // directory, and the TBTableViews of all currently opened tables. TBView
102 // has methods to save to and load from a file on disk.
103 // </synopsis>
104 
105 class TBView {
106 public:
107  // Default Constructor.
108  TBView();
109 
110  ~TBView();
111 
112 
113  // Adds the given table view to this view.
114  void addTableView(TBTableView* view);
115 
116  // Returns the list of table views in this view.
117  std::vector<TBTableView*>* getTableViews();
118 
119  // Sets the last opened directory for this view.
120  void setLastOpenedDirectory(casacore::String str);
121 
122  // Returns the last opened directory for this view.
123  casacore::String getLastOpenedDirectory();
124 
125  // Gets/Sets the file chooser history limit.
126  // <group>
127  int chooserHistoryLimit() const;
128  void setChooserHistoryLimit(int histLimit);
129  // </group>
130 
131 
132  // Saves this view in XML format to the given file.
133  bool saveToFile(casacore::String file);
134 
135  // Equivalent to saveToFile(defaultFile()).
136  bool saveToDefaultFile();
137 
138 
139  // Loads the view saved in the given file and returns it. If the file
140  // is invalid or there are other problems, NULL is returned.
141  static TBView* loadFromFile(casacore::String file);
142 
143  // Equivalent to loadFromFile(defaultFile()).
144  static TBView* loadFromDefaultFile();
145 
146  // Returns the default location to save and load a view:
147  // TBConstants::dotCasapyDir() + TBConstants::VIEW_SAVE_LOC.
148  static casacore::String defaultFile();
149 
150 private:
151  // Last opened directory.
153 
154  // casacore::File chooser history limit.
156 
157  // casacore::Table views.
158  std::vector<TBTableView*> views;
159 
160 
161  // Creates an XML element based upon the given QFontColor.
162  static void fontElem(DOMElement* elem, QFontColor* font);
163 
164  // Creates a QFontColor based upon the given XML element.
165  static QFontColor* fontElem(DOMElement* elem);
166 };
167 
202 }
203 
204 #endif /* TBVIEW_H_ */
int loadedFrom
The starting number of the loaded rows.
Definition: TBView.h:77
casacore::String lastOpenedDir
Last opened directory.
Definition: TBView.h:152
Current &quot;view&quot; or state of a single table.
Definition: TBView.h:56
Current &quot;view&quot; or state of the browser that can be serialized.
Definition: TBView.h:105
std::vector< TBTableView * > views
casacore::Table views.
Definition: TBView.h:158
int histLimit
casacore::File chooser history limit.
Definition: TBView.h:155
std::vector< bool > hidden
Whether each column is hidden (true) or not (false).
Definition: TBView.h:71
TBFilterRuleSequence * filter
Row filter, or NULL if there is none.
Definition: TBView.h:83
std::vector< int > visInd
The visual index of each column in case they were moved.
Definition: TBView.h:74
bool selected
Whether the table is currently selected.
Definition: TBView.h:68
A sequence of TBFilterRules that can be used to filter rows.
std::vector< TBFormat * > formats
The format for each field, or NULL if that field has none.
Definition: TBView.h:86
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::String location
Location of the table.
Definition: TBView.h:65
std::vector< std::pair< casacore::String, bool > > sort
The current sort order, or an empty list if there is none.
Definition: TBView.h:89
bool taql
Whether this table is from a TaQL command or not.
Definition: TBView.h:92
QFont color is a convenience class containing a QFont and a QColor.
Definition: TBFormat.qo.h:47
int loadedNum
The number of loaded rows.
Definition: TBView.h:80
Defines nreal time structures used by the VLA table filler.
Definition: nreal.h:100