1 | /****************************************************************************** |
---|
2 | * Program: GlobalCoordinatesToFileMapper |
---|
3 | * Module: FileInfo.cpp |
---|
4 | * Authors: Nicholas Schwarz, schwarz@evl.uic.edu |
---|
5 | * Date: 21 September 2004 |
---|
6 | * |
---|
7 | * Copyright (C) 2004 Electronic Visualization Laboratory, |
---|
8 | * University of Illinois at Chicago |
---|
9 | * |
---|
10 | * All rights reserved. |
---|
11 | * |
---|
12 | * Redistribution and use in source and binary forms, with or without |
---|
13 | * modification, are permitted provided that the following conditions are met: |
---|
14 | * |
---|
15 | * * Redistributions of source code must retain the above copyright |
---|
16 | * notice, this list of conditions and the following disclaimer. |
---|
17 | * * Redistributions in binary form must reproduce the above |
---|
18 | * copyright notice, this list of conditions and the following disclaimer |
---|
19 | * in the documentation and/or other materials provided with the distribution. |
---|
20 | * * Neither the name of the University of Illinois at Chicago nor |
---|
21 | * the names of its contributors may be used to endorse or promote |
---|
22 | * products derived from this software without specific prior written permission. |
---|
23 | * |
---|
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
27 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
---|
28 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
---|
29 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
30 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
---|
31 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
---|
32 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
---|
33 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
35 | * |
---|
36 | * Direct questions, comments etc to schwarz@evl.uic.edu or |
---|
37 | * http://www.evl.uic.edu/cavern/forum/ |
---|
38 | * |
---|
39 | *****************************************************************************/ |
---|
40 | |
---|
41 | |
---|
42 | // Include header file for this class |
---|
43 | #include "FileInfo.h" |
---|
44 | |
---|
45 | |
---|
46 | //----------------------------------------------------------------------------- |
---|
47 | FileInfo::FileInfo() |
---|
48 | { |
---|
49 | this -> Dimensions[0] = 0; |
---|
50 | this -> Dimensions[1] = 0; |
---|
51 | this -> FileName = NULL; |
---|
52 | this -> Extent[0] = 0; |
---|
53 | this -> Extent[1] = 0; |
---|
54 | this -> Extent[2] = 0; |
---|
55 | this -> Extent[3] = 0; |
---|
56 | this -> LocalPosition[0] = 0; |
---|
57 | this -> LocalPosition[1] = 0; |
---|
58 | } |
---|
59 | |
---|
60 | |
---|
61 | //----------------------------------------------------------------------------- |
---|
62 | void FileInfo::GetDimensions(long* w, long* h) |
---|
63 | { |
---|
64 | *w = this -> Dimensions[0]; |
---|
65 | *h = this -> Dimensions[1]; |
---|
66 | |
---|
67 | return; |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | //----------------------------------------------------------------------------- |
---|
72 | void FileInfo::GetExtent(long* x, long* y, |
---|
73 | long* w, long* h) |
---|
74 | { |
---|
75 | *x = this -> Extent[0]; |
---|
76 | *y = this -> Extent[1]; |
---|
77 | *w = this -> Extent[2]; |
---|
78 | *h = this -> Extent[3]; |
---|
79 | |
---|
80 | return; |
---|
81 | } |
---|
82 | |
---|
83 | |
---|
84 | //----------------------------------------------------------------------------- |
---|
85 | const char* FileInfo::GetFileName() |
---|
86 | { |
---|
87 | return this -> FileName; |
---|
88 | } |
---|
89 | |
---|
90 | |
---|
91 | //----------------------------------------------------------------------------- |
---|
92 | void FileInfo::GetLocalPosition(long* col, long* row) |
---|
93 | { |
---|
94 | *col = this -> LocalPosition[0]; |
---|
95 | *row = this -> LocalPosition[1]; |
---|
96 | |
---|
97 | return; |
---|
98 | } |
---|
99 | |
---|
100 | |
---|
101 | //----------------------------------------------------------------------------- |
---|
102 | void FileInfo::PrintSelf(ostream& os) |
---|
103 | { |
---|
104 | |
---|
105 | os << "File Info Start --------------------------------------------\n"; |
---|
106 | |
---|
107 | os << "Dimensions: " |
---|
108 | << this -> Dimensions[0] << " " |
---|
109 | << this -> Dimensions[1] << "\n"; |
---|
110 | |
---|
111 | if (this -> FileName != NULL) |
---|
112 | os << "File Name: " << this -> FileName << "\n"; |
---|
113 | else |
---|
114 | os << "File Name: null\n"; |
---|
115 | |
---|
116 | os << "Extent: " |
---|
117 | << this -> Extent[0] << " " |
---|
118 | << this -> Extent[1] << " " |
---|
119 | << this -> Extent[2] << " " |
---|
120 | << this -> Extent[3] << "\n"; |
---|
121 | |
---|
122 | os << "Local Position: " |
---|
123 | << this -> LocalPosition[0] << " " |
---|
124 | << this -> LocalPosition[1] << "\n"; |
---|
125 | |
---|
126 | os << "File Info End ----------------------------------------------" << endl; |
---|
127 | |
---|
128 | return; |
---|
129 | } |
---|
130 | |
---|
131 | |
---|
132 | //----------------------------------------------------------------------------- |
---|
133 | void FileInfo::SetDimensions(long w, long h) |
---|
134 | { |
---|
135 | this -> Dimensions[0] = w; |
---|
136 | this -> Dimensions[1] = h; |
---|
137 | |
---|
138 | return; |
---|
139 | } |
---|
140 | |
---|
141 | |
---|
142 | //----------------------------------------------------------------------------- |
---|
143 | void FileInfo::SetExtent(long x, long y, |
---|
144 | long w, long h) |
---|
145 | { |
---|
146 | this -> Extent[0] = x; |
---|
147 | this -> Extent[1] = y; |
---|
148 | this -> Extent[2] = w; |
---|
149 | this -> Extent[3] = h; |
---|
150 | |
---|
151 | return; |
---|
152 | } |
---|
153 | |
---|
154 | |
---|
155 | //----------------------------------------------------------------------------- |
---|
156 | void FileInfo::SetExtentX(long x) |
---|
157 | { |
---|
158 | this -> Extent[0] = x; |
---|
159 | } |
---|
160 | |
---|
161 | |
---|
162 | //----------------------------------------------------------------------------- |
---|
163 | void FileInfo::SetExtentY(long y) |
---|
164 | { |
---|
165 | this -> Extent[1] = y; |
---|
166 | } |
---|
167 | |
---|
168 | |
---|
169 | //----------------------------------------------------------------------------- |
---|
170 | void FileInfo::SetExtentW(long w) |
---|
171 | { |
---|
172 | this -> Extent[2] = w; |
---|
173 | } |
---|
174 | |
---|
175 | |
---|
176 | //----------------------------------------------------------------------------- |
---|
177 | void FileInfo::SetExtentH(long h) |
---|
178 | { |
---|
179 | this -> Extent[3] = h; |
---|
180 | } |
---|
181 | |
---|
182 | |
---|
183 | //----------------------------------------------------------------------------- |
---|
184 | void FileInfo::SetFileName(const char* name) |
---|
185 | { |
---|
186 | if (this -> FileName != NULL) |
---|
187 | { |
---|
188 | delete [] this -> FileName; |
---|
189 | } |
---|
190 | |
---|
191 | if (name != NULL) |
---|
192 | { |
---|
193 | this -> FileName = new char[strlen(name) + 1]; |
---|
194 | strcpy(this -> FileName, name); |
---|
195 | } |
---|
196 | else { |
---|
197 | this -> FileName = NULL; |
---|
198 | } |
---|
199 | |
---|
200 | return; |
---|
201 | } |
---|
202 | |
---|
203 | |
---|
204 | //----------------------------------------------------------------------------- |
---|
205 | void FileInfo::SetLocalPosition(long col, long row) |
---|
206 | { |
---|
207 | this -> LocalPosition[0] = col; |
---|
208 | this -> LocalPosition[1] = row; |
---|
209 | |
---|
210 | return; |
---|
211 | } |
---|
212 | |
---|
213 | |
---|
214 | //----------------------------------------------------------------------------- |
---|
215 | FileInfo::~FileInfo() |
---|
216 | { |
---|
217 | if (this -> FileName != NULL) |
---|
218 | { |
---|
219 | delete [] this -> FileName; |
---|
220 | } |
---|
221 | } |
---|