mydxftables.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2010-2011 Taneli Kalvas. All rights reserved.
6  *
7  * You can redistribute this software and/or modify it under the terms
8  * of the GNU General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this library (file "COPYING" included in the package);
19  * if not, write to the Free Software Foundation, Inc., 51 Franklin
20  * Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  * If you have questions about your rights to use or distribute this
23  * software, please contact Berkeley Lab's Technology Transfer
24  * Department at TTD@lbl.gov. Other questions, comments and bug
25  * reports should be sent directly to the author via email at
26  * taneli.kalvas@jyu.fi.
27  *
28  * NOTICE. This software was developed under partial funding from the
29  * U.S. Department of Energy. As such, the U.S. Government has been
30  * granted for itself and others acting on its behalf a paid-up,
31  * nonexclusive, irrevocable, worldwide license in the Software to
32  * reproduce, prepare derivative works, and perform publicly and
33  * display publicly. Beginning five (5) years after the date
34  * permission to assert copyright is obtained from the U.S. Department
35  * of Energy, and subject to any subsequent five (5) year renewals,
36  * the U.S. Government is granted for itself and others acting on its
37  * behalf a paid-up, nonexclusive, irrevocable, worldwide license in
38  * the Software to reproduce, prepare derivative works, distribute
39  * copies to the public, perform publicly and display publicly, and to
40  * permit others to do so.
41  */
42 
43 #ifndef MY_DXF_TABLES_HPP
44 #define MY_DXF_TABLES_HPP 1
45 
46 
47 #include <vector>
48 #include <string>
49 #include <stdint.h>
50 #include "mydxffile.hpp"
51 
52 
56 {
57 
58  std::string _handle; // 5 (for others) or 105 (for DIMSTYLE)
59  std::string _handle_to_owner; // 330
60 
61 protected:
62 
66 
69  void process_group( class MyDXFFile *dxf );
70 
73  void write_common( class MyDXFFile *dxf, std::ofstream &ostr );
74 
77  void debug_print_common( std::ostream &os ) const;
78 
79 public:
80 
83  virtual ~MyDXFTableEntry() {};
84 
87  virtual void write( class MyDXFFile *dxf, std::ofstream &ostr ) = 0;
88 
91  virtual void debug_print( std::ostream &os ) const = 0;
92 
93  friend std::ostream &operator<<( std::ostream &os, const MyDXFTableEntry &e );
94 };
95 
96 
97 
101 {
102 
103  std::string _name; // 2
104  int16_t _units; // 70
105  int8_t _explodability; // 280
106  int8_t _scalability; // 281
107  std::string _handle_to_layout; // 340
108 
109 public:
110 
114 
117  virtual ~MyDXFTableEntryBlockRecord();
118 
121  virtual void write( class MyDXFFile *dxf, std::ofstream &ostr );
122 
125  virtual void debug_print( std::ostream &os ) const;
126 };
127 
128 
129 
133 {
134 
135  std::string _name; // 2
136  std::string _linetype; // 6
137  int16_t _flags; // 70
138  int16_t _color; // 62 (negative if layer off)
139  bool _plotting; // 290
140  int8_t _lineweight; // 370
141 
142  std::string _handle_to_plot_style_name; // 390
143  std::string _handle_to_material; // 347
144 
145 public:
146 
149  MyDXFTableEntryLayer( class MyDXFFile *dxf );
150 
153  virtual ~MyDXFTableEntryLayer();
154 
157  const std::string &name( void ) const { return( _name ); }
158 
161  void set_name( const std::string &name ) { _name = name; }
162 
165  virtual void write( class MyDXFFile *dxf, std::ofstream &ostr );
166 
169  virtual void debug_print( std::ostream &os ) const;
170 };
171 
172 
173 
177 {
178  std::string _name; // 2
179  std::string _handle; // 5
180  std::string _handle_to_owner; // 330
181 
182  std::vector<MyDXFTableEntry *> _entries; // 70 (size)
183 
184 public:
185 
186  MyDXFTable( const std::string &name, class MyDXFFile *dxf );
187  ~MyDXFTable();
188 
191  uint32_t size() const { return( _entries.size() ); }
192 
195  const MyDXFTableEntry *get_entry( uint32_t a ) const { return( _entries[a] ); }
196 
199  MyDXFTableEntry *get_entry( uint32_t a ) { return( _entries[a] ); }
200 
203  void write( class MyDXFFile *dxf, std::ofstream &ostr );
204 
207  void debug_print( std::ostream &os ) const;
208 };
209 
210 
211 
217 {
218 
219  MyDXFTable *_blockrecord;
220  MyDXFTable *_layer;
221 
222 public:
223 
224  MyDXFTables( class MyDXFFile *dxf );
225  ~MyDXFTables();
226 
229  const MyDXFTable *get_layers_table( void ) const { return( _layer ); }
230 
233  MyDXFTable *get_layers_table( void ) { return( _layer ); }
234 
237  void write( class MyDXFFile *dxf, std::ofstream &ostr );
238 
241  void debug_print( std::ostream &os ) const;
242 };
243 
244 
245 
246 
247 
248 #endif
249 
250 
251 
252 
virtual ~MyDXFTableEntryBlockRecord()
Virtual destructor.
DXF tables class.
Definition: mydxftables.hpp:216
DXF table entry for block record table.
Definition: mydxftables.hpp:100
virtual void debug_print(std::ostream &os) const
Print debugging information to os.
MyDXFTableEntryLayer(class MyDXFFile *dxf)
Construct entry by reading from DXF file.
friend std::ostream & operator<<(std::ostream &os, const MyDXFTableEntry &e)
MyDXFTable(const std::string &name, class MyDXFFile *dxf)
void write(class MyDXFFile *dxf, std::ofstream &ostr)
Write dxf file to stream.
const MyDXFTableEntry * get_entry(uint32_t a) const
Return const pointer to entry a.
Definition: mydxftables.hpp:195
const MyDXFTable * get_layers_table(void) const
Return const pointer to layers table.
Definition: mydxftables.hpp:229
MyDXFTableEntry()
Constructor.
DXF File.
DXF file class.
Definition: mydxffile.hpp:68
const std::string & name(void) const
Return layer name.
Definition: mydxftables.hpp:157
MyDXFTableEntry * get_entry(uint32_t a)
Return pointer to entry a.
Definition: mydxftables.hpp:199
uint32_t size() const
Return number of table entries.
Definition: mydxftables.hpp:191
DXF table class.
Definition: mydxftables.hpp:176
DXF table entry for layer table.
Definition: mydxftables.hpp:132
DXF table entry.
Definition: mydxftables.hpp:55
virtual void debug_print(std::ostream &os) const
Print debugging information to os.
void write(class MyDXFFile *dxf, std::ofstream &ostr)
Write dxf file to stream.
MyDXFTables(class MyDXFFile *dxf)
void debug_print_common(std::ostream &os) const
Debug print common groups.
virtual void write(class MyDXFFile *dxf, std::ofstream &ostr)
Write dxf file to stream.
virtual void write(class MyDXFFile *dxf, std::ofstream &ostr)
Write dxf file to stream.
virtual ~MyDXFTableEntryLayer()
Virtual destructor.
void debug_print(std::ostream &os) const
Print debugging information to os.
virtual void debug_print(std::ostream &os) const =0
Print debugging information to os.
virtual void write(class MyDXFFile *dxf, std::ofstream &ostr)=0
Write dxf file to stream.
void set_name(const std::string &name)
Return layer name.
Definition: mydxftables.hpp:161
void debug_print(std::ostream &os) const
Print debugging information to os.
MyDXFTable * get_layers_table(void)
Return pointer to layers table.
Definition: mydxftables.hpp:233
MyDXFTableEntryBlockRecord(class MyDXFFile *dxf)
Construct entry by reading from DXF file.
virtual ~MyDXFTableEntry()
Virtual destructor.
Definition: mydxftables.hpp:83
void process_group(class MyDXFFile *dxf)
Process group not belonging to the child entry.
void write_common(class MyDXFFile *dxf, std::ofstream &ostr)
Write common groups.