Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IDXF_DXFENTRD_HXX
21 : #define INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IDXF_DXFENTRD_HXX
22 :
23 : #include <dxfgrprd.hxx>
24 : #include <dxfvec.hxx>
25 :
26 : #include <deque>
27 :
28 : typedef std::deque< Point > DXFPointArray;
29 :
30 : enum DXFEntityType {
31 : DXF_LINE,
32 : DXF_POINT,
33 : DXF_CIRCLE,
34 : DXF_ARC,
35 : DXF_TRACE,
36 : DXF_SOLID,
37 : DXF_TEXT,
38 : DXF_SHAPE,
39 : DXF_INSERT,
40 : DXF_ATTDEF,
41 : DXF_ATTRIB,
42 : DXF_POLYLINE,
43 : DXF_VERTEX,
44 : DXF_SEQEND,
45 : DXF_3DFACE,
46 : DXF_DIMENSION,
47 : DXF_LWPOLYLINE,
48 : DXF_HATCH
49 : };
50 :
51 : // base class of an entity
52 :
53 : class DXFBasicEntity {
54 :
55 : public:
56 :
57 : DXFBasicEntity * pSucc;
58 : // pointer to next entity (in the list of DXFEntities.pFirst)
59 :
60 : DXFEntityType eType;
61 : // entity kind (line or circle or what)
62 :
63 : // properties that all entities have, each
64 : // commented with group codes:
65 : OString m_sLayer; // 8
66 : OString m_sLineType; // 6
67 : double fElevation; // 38
68 : double fThickness; // 39
69 : long nColor; // 62
70 : long nSpace; // 67
71 : DXFVector aExtrusion; // 210,220,230
72 :
73 : protected:
74 :
75 : DXFBasicEntity(DXFEntityType eThisType);
76 : // always initialize the constructors of entities with default values
77 :
78 : public:
79 :
80 : virtual ~DXFBasicEntity();
81 : void Read(DXFGroupReader & rDGR);
82 : // Reads a parameter till the next 0-group
83 :
84 : protected:
85 :
86 : virtual void EvaluateGroup(DXFGroupReader & rDGR);
87 : // This method will be called by Read() for every parameter (respectively
88 : // for every group).
89 : // As far as the group code of the entity is known, the corresponding
90 : // parameter is fetched.
91 :
92 : };
93 :
94 :
95 : // the different kinds of entities
96 :
97 0 : class DXFLineEntity : public DXFBasicEntity {
98 :
99 : public:
100 :
101 : DXFVector aP0; // 10,20,30
102 : DXFVector aP1; // 11,21,31
103 :
104 : DXFLineEntity();
105 :
106 : protected:
107 :
108 : virtual void EvaluateGroup(DXFGroupReader & rDGR) SAL_OVERRIDE;
109 : };
110 :
111 0 : class DXFPointEntity : public DXFBasicEntity {
112 :
113 : public:
114 :
115 : DXFVector aP0; // 10,20,30
116 :
117 : DXFPointEntity();
118 :
119 : protected:
120 :
121 : virtual void EvaluateGroup(DXFGroupReader & rDGR) SAL_OVERRIDE;
122 : };
123 :
124 0 : class DXFCircleEntity : public DXFBasicEntity {
125 :
126 : public:
127 :
128 : DXFVector aP0; // 10,20,30
129 : double fRadius; // 40
130 :
131 : DXFCircleEntity();
132 :
133 : protected:
134 :
135 : virtual void EvaluateGroup(DXFGroupReader & rDGR) SAL_OVERRIDE;
136 : };
137 :
138 0 : class DXFArcEntity : public DXFBasicEntity {
139 :
140 : public:
141 :
142 : DXFVector aP0; // 10,20,30
143 : double fRadius; // 40
144 : double fStart; // 50
145 : double fEnd; // 51
146 :
147 : DXFArcEntity();
148 :
149 : protected:
150 :
151 : virtual void EvaluateGroup(DXFGroupReader & rDGR) SAL_OVERRIDE;
152 : };
153 :
154 0 : class DXFTraceEntity : public DXFBasicEntity {
155 :
156 : public:
157 :
158 : DXFVector aP0; // 10,20,30
159 : DXFVector aP1; // 11,21,31
160 : DXFVector aP2; // 12,22,32
161 : DXFVector aP3; // 13,23,33
162 :
163 : DXFTraceEntity();
164 :
165 : protected:
166 :
167 : virtual void EvaluateGroup(DXFGroupReader & rDGR) SAL_OVERRIDE;
168 : };
169 :
170 0 : class DXFSolidEntity : public DXFBasicEntity {
171 :
172 : public:
173 :
174 : DXFVector aP0; // 10,20,30
175 : DXFVector aP1; // 11,21,31
176 : DXFVector aP2; // 12,22,32
177 : DXFVector aP3; // 13,23,33
178 :
179 : DXFSolidEntity();
180 :
181 : protected:
182 :
183 : virtual void EvaluateGroup(DXFGroupReader & rDGR) SAL_OVERRIDE;
184 : };
185 :
186 0 : class DXFTextEntity : public DXFBasicEntity {
187 :
188 : public:
189 :
190 : DXFVector aP0; // 10,20,30
191 : double fHeight; // 40
192 : OString m_sText; // 1
193 : double fRotAngle; // 50
194 : double fXScale; // 41
195 : double fOblAngle; // 42
196 : OString m_sStyle; // 7
197 : long nGenFlags; // 71
198 : long nHorzJust; // 72
199 : long nVertJust; // 73
200 : DXFVector aAlign; // 11,21,31
201 :
202 : DXFTextEntity();
203 :
204 : protected:
205 :
206 : virtual void EvaluateGroup(DXFGroupReader & rDGR) SAL_OVERRIDE;
207 : };
208 :
209 0 : class DXFShapeEntity : public DXFBasicEntity {
210 :
211 : public:
212 :
213 : DXFVector aP0; // 10,20,30
214 : double fSize; // 40
215 : OString m_sName; // 2
216 : double fRotAngle; // 50
217 : double fXScale; // 41
218 : double fOblAngle; // 51
219 :
220 : DXFShapeEntity();
221 :
222 : protected:
223 :
224 : virtual void EvaluateGroup(DXFGroupReader & rDGR) SAL_OVERRIDE;
225 : };
226 :
227 0 : class DXFInsertEntity : public DXFBasicEntity {
228 :
229 : public:
230 :
231 : long nAttrFlag; // 66
232 : OString m_sName; // 2
233 : DXFVector aP0; // 10,20,30
234 : double fXScale; // 41
235 : double fYScale; // 42
236 : double fZScale; // 43
237 : double fRotAngle; // 50
238 : long nColCount; // 70
239 : long nRowCount; // 71
240 : double fColSpace; // 44
241 : double fRowSpace; // 45
242 :
243 : DXFInsertEntity();
244 :
245 : protected:
246 :
247 : virtual void EvaluateGroup(DXFGroupReader & rDGR) SAL_OVERRIDE;
248 : };
249 :
250 0 : class DXFAttDefEntity : public DXFBasicEntity {
251 :
252 : public:
253 :
254 : DXFVector aP0; // 10,20,30
255 : double fHeight; // 40
256 : OString m_sDefVal; // 1
257 : OString m_sPrompt; // 3
258 : OString m_sTagStr; // 2
259 : long nAttrFlags; // 70
260 : long nFieldLen; // 73
261 : double fRotAngle; // 50
262 : double fXScale; // 41
263 : double fOblAngle; // 51
264 : OString m_sStyle; // 7
265 : long nGenFlags; // 71
266 : long nHorzJust; // 72
267 : long nVertJust; // 74
268 : DXFVector aAlign; // 11,21,31
269 :
270 : DXFAttDefEntity();
271 :
272 : protected:
273 :
274 : virtual void EvaluateGroup(DXFGroupReader & rDGR) SAL_OVERRIDE;
275 : };
276 :
277 0 : class DXFAttribEntity : public DXFBasicEntity {
278 :
279 : public:
280 :
281 : DXFVector aP0; // 10,20,30
282 : double fHeight; // 40
283 : OString m_sText; // 1
284 : OString m_sTagStr; // 2
285 : long nAttrFlags; // 70
286 : long nFieldLen; // 73
287 : double fRotAngle; // 50
288 : double fXScale; // 41
289 : double fOblAngle; // 51
290 : OString m_sStyle; // 7
291 : long nGenFlags; // 71
292 : long nHorzJust; // 72
293 : long nVertJust; // 74
294 : DXFVector aAlign; // 11,21,31
295 :
296 : DXFAttribEntity();
297 :
298 : protected:
299 :
300 : virtual void EvaluateGroup(DXFGroupReader & rDGR) SAL_OVERRIDE;
301 : };
302 :
303 0 : class DXFPolyLineEntity : public DXFBasicEntity {
304 :
305 : public:
306 :
307 : double fElevation; // 30
308 : long nFlags; // 70
309 : double fSWidth; // 40
310 : double fEWidth; // 41
311 : long nMeshMCount; // 71
312 : long nMeshNCount; // 72
313 : long nMDensity; // 73
314 : long nNDensity; // 74
315 : long nCSSType; // 75
316 :
317 : DXFPolyLineEntity();
318 :
319 : protected:
320 :
321 : virtual void EvaluateGroup(DXFGroupReader & rDGR) SAL_OVERRIDE;
322 : };
323 :
324 : class DXFLWPolyLineEntity : public DXFBasicEntity
325 : {
326 : sal_Int32 nIndex;
327 :
328 : public :
329 :
330 : sal_Int32 nCount; // 90
331 : sal_Int32 nFlags; // 70 1 = closed, 128 = plinegen
332 : double fConstantWidth; // 43 (optional - default: 0, not used if fStartWidth and/or fEndWidth is used)
333 : double fStartWidth; // 40
334 : double fEndWidth; // 41
335 :
336 : DXFVector* pP;
337 :
338 : DXFLWPolyLineEntity();
339 : virtual ~DXFLWPolyLineEntity();
340 :
341 : protected :
342 :
343 : virtual void EvaluateGroup( DXFGroupReader & rDGR ) SAL_OVERRIDE;
344 :
345 : };
346 :
347 : struct DXFEdgeType
348 : {
349 : sal_Int32 nEdgeType;
350 :
351 0 : virtual ~DXFEdgeType(){};
352 0 : virtual bool EvaluateGroup( DXFGroupReader & /*rDGR*/ ){ return true; };
353 :
354 : protected :
355 :
356 0 : DXFEdgeType( sal_Int32 EdgeType ):nEdgeType(EdgeType){};
357 : };
358 : struct DXFEdgeTypeLine : public DXFEdgeType
359 : {
360 : DXFVector aStartPoint; // 10,20
361 : DXFVector aEndPoint; // 11,21
362 : DXFEdgeTypeLine();
363 : virtual ~DXFEdgeTypeLine();
364 : virtual bool EvaluateGroup( DXFGroupReader & rDGR ) SAL_OVERRIDE;
365 : };
366 : struct DXFEdgeTypeCircularArc : public DXFEdgeType
367 : {
368 : DXFVector aCenter; // 10,20
369 : double fRadius; // 40
370 : double fStartAngle; // 50
371 : double fEndAngle; // 51
372 : sal_Int32 nIsCounterClockwiseFlag; // 73
373 : DXFEdgeTypeCircularArc();
374 : virtual ~DXFEdgeTypeCircularArc();
375 : virtual bool EvaluateGroup( DXFGroupReader & rDGR ) SAL_OVERRIDE;
376 : };
377 : struct DXFEdgeTypeEllipticalArc : public DXFEdgeType
378 : {
379 : DXFVector aCenter; // 10,20
380 : DXFVector aEndPoint; // 11,21
381 : double fLength; // 40
382 : double fStartAngle; // 50
383 : double fEndAngle; // 51
384 : sal_Int32 nIsCounterClockwiseFlag; // 73
385 :
386 : DXFEdgeTypeEllipticalArc();
387 : virtual ~DXFEdgeTypeEllipticalArc();
388 : virtual bool EvaluateGroup( DXFGroupReader & rDGR ) SAL_OVERRIDE;
389 : };
390 : struct DXFEdgeTypeSpline : public DXFEdgeType
391 : {
392 : sal_Int32 nDegree; // 94
393 : sal_Int32 nRational; // 73
394 : sal_Int32 nPeriodic; // 74
395 : sal_Int32 nKnotCount; // 75
396 : sal_Int32 nControlCount; // 76
397 :
398 : DXFEdgeTypeSpline();
399 : virtual ~DXFEdgeTypeSpline();
400 : virtual bool EvaluateGroup( DXFGroupReader & rDGR ) SAL_OVERRIDE;
401 : };
402 :
403 : typedef std::deque< DXFEdgeType* > DXFEdgeTypeArray;
404 :
405 : struct DXFBoundaryPathData
406 : {
407 : sal_Int32 nFlags; // 92
408 : sal_Int32 nHasBulgeFlag; // 72
409 : sal_Int32 nIsClosedFlag; // 73
410 : sal_Int32 nPointCount; // 93
411 : double fBulge; // 42
412 : sal_Int32 nSourceBoundaryObjects; // 97
413 : sal_Int32 nEdgeCount; // 93
414 :
415 : bool bIsPolyLine;
416 : sal_Int32 nPointIndex;
417 :
418 : DXFVector* pP;
419 : DXFEdgeTypeArray aEdges;
420 :
421 : DXFBoundaryPathData();
422 : ~DXFBoundaryPathData();
423 :
424 : bool EvaluateGroup( DXFGroupReader & rDGR );
425 : };
426 :
427 : class DXFHatchEntity : public DXFBasicEntity
428 : {
429 : bool bIsInBoundaryPathContext;
430 : sal_Int32 nCurrentBoundaryPathIndex;
431 :
432 : public :
433 :
434 : DXFVector aElevationPoint;
435 : sal_Int32 nFlags; // 70 (solid fill = 1, pattern fill = 0)
436 : sal_Int32 nAssociativityFlag; // 71 (assoiciative = 1, non-associative = 0)
437 : sal_Int32 nBoundaryPathCount; // 91
438 : sal_Int32 nHatchStyle; // 75 (odd parity = 0, outmost area = 1, entire area = 2 )
439 : sal_Int32 nHatchPatternType; // 76 (user defined = 0, predefined = 1, custom = 2)
440 : double fHatchPatternAngle; // 52 (pattern fill only)
441 : double fHatchPatternScale; // 41 (pattern fill only:scale or spacing)
442 : sal_Int32 nHatchDoubleFlag; // 77 (pattern fill only:double = 1, not double = 0)
443 : sal_Int32 nHatchPatternDefinitionLines; // 78
444 : double fPixelSize; // 47
445 : sal_Int32 nNumberOfSeedPoints; // 98
446 :
447 : DXFBoundaryPathData* pBoundaryPathData;
448 :
449 : DXFHatchEntity();
450 : virtual ~DXFHatchEntity();
451 :
452 : protected :
453 :
454 : virtual void EvaluateGroup( DXFGroupReader & rDGR ) SAL_OVERRIDE;
455 : };
456 :
457 0 : class DXFVertexEntity : public DXFBasicEntity {
458 :
459 : public:
460 :
461 : DXFVector aP0; // 10,20,30
462 : double fSWidth; // 40 (if <0.0, then one has DXFPolyLine::fSWidth)
463 : double fEWidth; // 41 (if <0.0, then one has DXFPolyLine::fEWidth)
464 : double fBulge; // 42
465 : long nFlags; // 70
466 : double fCFTDir; // 50
467 :
468 : DXFVertexEntity();
469 :
470 : protected:
471 :
472 : virtual void EvaluateGroup(DXFGroupReader & rDGR) SAL_OVERRIDE;
473 : };
474 :
475 0 : class DXFSeqEndEntity : public DXFBasicEntity {
476 :
477 : public:
478 :
479 : DXFSeqEndEntity();
480 : };
481 :
482 0 : class DXF3DFaceEntity : public DXFBasicEntity {
483 :
484 : public:
485 :
486 : DXFVector aP0; // 10,20,30
487 : DXFVector aP1; // 11,21,31
488 : DXFVector aP2; // 12,22,32
489 : DXFVector aP3; // 13,23,33
490 : long nIEFlags; // 70
491 :
492 : DXF3DFaceEntity();
493 :
494 : protected:
495 :
496 : virtual void EvaluateGroup(DXFGroupReader & rDGR) SAL_OVERRIDE;
497 : };
498 :
499 0 : class DXFDimensionEntity : public DXFBasicEntity {
500 :
501 : public:
502 :
503 : OString m_sPseudoBlock; // 2
504 :
505 : DXFDimensionEntity();
506 :
507 : protected:
508 :
509 : virtual void EvaluateGroup(DXFGroupReader & rDGR) SAL_OVERRIDE;
510 : };
511 :
512 :
513 : // read and represent the set of entities
514 : class DXFEntities {
515 :
516 : public:
517 :
518 : DXFEntities();
519 : ~DXFEntities();
520 :
521 : DXFBasicEntity * pFirst; // list of entities, READ ONLY!
522 :
523 : void Read(DXFGroupReader & rDGR);
524 : // read entities per rGDR of a DXF file until a
525 : // ENDBLK, ENDSEC oder EOF (of group 0).
526 : // (all unknown thing will be skipped)
527 :
528 : void Clear();
529 : // deletes all entities
530 : };
531 :
532 1 : inline DXFEntities::DXFEntities()
533 : {
534 1 : pFirst=NULL;
535 1 : }
536 :
537 :
538 1 : inline DXFEntities::~DXFEntities()
539 : {
540 1 : Clear();
541 1 : }
542 :
543 :
544 : #endif
545 :
546 :
547 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|