Branch data 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 _DXFENTRD_HXX
21 : : #define _DXFENTRD_HXX
22 : :
23 : : #include <dxfgrprd.hxx>
24 : : #include <dxfvec.hxx>
25 : :
26 : : #include <deque>
27 : :
28 : : typedef std::deque< Point > DXFPointArray;
29 : :
30 : : //------------------------------------------------------------------------------
31 : : //------------------------- Art eines Entity -----------------------------------
32 : : //------------------------------------------------------------------------------
33 : :
34 : : enum DXFEntityType {
35 : : DXF_LINE,
36 : : DXF_POINT,
37 : : DXF_CIRCLE,
38 : : DXF_ARC,
39 : : DXF_TRACE,
40 : : DXF_SOLID,
41 : : DXF_TEXT,
42 : : DXF_SHAPE,
43 : : DXF_INSERT,
44 : : DXF_ATTDEF,
45 : : DXF_ATTRIB,
46 : : DXF_POLYLINE,
47 : : DXF_VERTEX,
48 : : DXF_SEQEND,
49 : : DXF_3DFACE,
50 : : DXF_DIMENSION,
51 : : DXF_LWPOLYLINE,
52 : : DXF_HATCH
53 : : };
54 : :
55 : : //------------------------------------------------------------------------------
56 : : //---------------------- Basisklasse fuer ein Entity ---------------------------
57 : : //------------------------------------------------------------------------------
58 : :
59 : : class DXFBasicEntity {
60 : :
61 : : public:
62 : :
63 : : DXFBasicEntity * pSucc;
64 : : // Zeiger auf naechstes Entity (in der Liste DXFEntities.pFirst)
65 : :
66 : : DXFEntityType eType;
67 : : // Art des Entitys (Linie oder Kreis oder was)
68 : :
69 : : // Eigenschaftenm, die alle Entities besitzen, jeweils
70 : : // durch den Gruppencode kommentiert:
71 : : char sLayer[DXF_MAX_STRING_LEN+1]; // 8
72 : : char sLineType[DXF_MAX_STRING_LEN+1]; // 6
73 : : double fElevation; // 38
74 : : double fThickness; // 39
75 : : long nColor; // 62
76 : : long nSpace; // 67
77 : : DXFVector aExtrusion; // 210,220,230
78 : :
79 : : protected:
80 : :
81 : : DXFBasicEntity(DXFEntityType eThisType);
82 : : // Konstruktoren der Entities initialiseren immer mit Defaultwerten.
83 : :
84 : : public:
85 : :
86 : : virtual ~DXFBasicEntity();
87 : : virtual void Read(DXFGroupReader & rDGR);
88 : : // Liest die Prameter ein, bis zur naechten 0-Gruppe
89 : :
90 : : protected:
91 : :
92 : : virtual void EvaluateGroup(DXFGroupReader & rDGR);
93 : : // Diese Methode wird durch Read() fuer jeden Parameter (bzw. fuer jede
94 : : // Gruppe) aufgerufen.
95 : : // Sofern der Gruppencode dem Entity bekannt ist, wird der entsprechende
96 : : // Parameter geholt.
97 : :
98 : : };
99 : :
100 : : //------------------------------------------------------------------------------
101 : : //---------------- die verschiedenen Arten von Entyties ------------------------
102 : : //------------------------------------------------------------------------------
103 : :
104 : : //--------------------------Line------------------------------------------------
105 : :
106 : 0 : class DXFLineEntity : public DXFBasicEntity {
107 : :
108 : : public:
109 : :
110 : : DXFVector aP0; // 10,20,30
111 : : DXFVector aP1; // 11,21,31
112 : :
113 : : DXFLineEntity();
114 : :
115 : : protected:
116 : :
117 : : virtual void EvaluateGroup(DXFGroupReader & rDGR);
118 : : };
119 : :
120 : : //--------------------------Point-----------------------------------------------
121 : :
122 : 0 : class DXFPointEntity : public DXFBasicEntity {
123 : :
124 : : public:
125 : :
126 : : DXFVector aP0; // 10,20,30
127 : :
128 : : DXFPointEntity();
129 : :
130 : : protected:
131 : :
132 : : virtual void EvaluateGroup(DXFGroupReader & rDGR);
133 : : };
134 : :
135 : : //--------------------------Circle----------------------------------------------
136 : :
137 : 0 : class DXFCircleEntity : public DXFBasicEntity {
138 : :
139 : : public:
140 : :
141 : : DXFVector aP0; // 10,20,30
142 : : double fRadius; // 40
143 : :
144 : : DXFCircleEntity();
145 : :
146 : : protected:
147 : :
148 : : virtual void EvaluateGroup(DXFGroupReader & rDGR);
149 : : };
150 : :
151 : : //--------------------------Arc-------------------------------------------------
152 : :
153 : 0 : class DXFArcEntity : public DXFBasicEntity {
154 : :
155 : : public:
156 : :
157 : : DXFVector aP0; // 10,20,30
158 : : double fRadius; // 40
159 : : double fStart; // 50
160 : : double fEnd; // 51
161 : :
162 : : DXFArcEntity();
163 : :
164 : : protected:
165 : :
166 : : virtual void EvaluateGroup(DXFGroupReader & rDGR);
167 : : };
168 : :
169 : : //--------------------------Trace-----------------------------------------------
170 : :
171 : 0 : class DXFTraceEntity : public DXFBasicEntity {
172 : :
173 : : public:
174 : :
175 : : DXFVector aP0; // 10,20,30
176 : : DXFVector aP1; // 11,21,31
177 : : DXFVector aP2; // 12,22,32
178 : : DXFVector aP3; // 13,23,33
179 : :
180 : : DXFTraceEntity();
181 : :
182 : : protected:
183 : :
184 : : virtual void EvaluateGroup(DXFGroupReader & rDGR);
185 : : };
186 : :
187 : : //--------------------------Solid-----------------------------------------------
188 : :
189 : 0 : class DXFSolidEntity : public DXFBasicEntity {
190 : :
191 : : public:
192 : :
193 : : DXFVector aP0; // 10,20,30
194 : : DXFVector aP1; // 11,21,31
195 : : DXFVector aP2; // 12,22,32
196 : : DXFVector aP3; // 13,23,33
197 : :
198 : : DXFSolidEntity();
199 : :
200 : : protected:
201 : :
202 : : virtual void EvaluateGroup(DXFGroupReader & rDGR);
203 : : };
204 : :
205 : : //--------------------------Text------------------------------------------------
206 : :
207 : 0 : class DXFTextEntity : public DXFBasicEntity {
208 : :
209 : : public:
210 : :
211 : : DXFVector aP0; // 10,20,30
212 : : double fHeight; // 40
213 : : char sText[DXF_MAX_STRING_LEN+1]; // 1
214 : : double fRotAngle; // 50
215 : : double fXScale; // 41
216 : : double fOblAngle; // 42
217 : : char sStyle[DXF_MAX_STRING_LEN+1]; // 7
218 : : long nGenFlags; // 71
219 : : long nHorzJust; // 72
220 : : long nVertJust; // 73
221 : : DXFVector aAlign; // 11,21,31
222 : :
223 : : DXFTextEntity();
224 : :
225 : : protected:
226 : :
227 : : virtual void EvaluateGroup(DXFGroupReader & rDGR);
228 : : };
229 : :
230 : : //--------------------------Shape-----------------------------------------------
231 : :
232 : 0 : class DXFShapeEntity : public DXFBasicEntity {
233 : :
234 : : public:
235 : :
236 : : DXFVector aP0; // 10,20,30
237 : : double fSize; // 40
238 : : char sName[DXF_MAX_STRING_LEN+1]; // 2
239 : : double fRotAngle; // 50
240 : : double fXScale; // 41
241 : : double fOblAngle; // 51
242 : :
243 : : DXFShapeEntity();
244 : :
245 : : protected:
246 : :
247 : : virtual void EvaluateGroup(DXFGroupReader & rDGR);
248 : : };
249 : :
250 : : //--------------------------Insert----------------------------------------------
251 : :
252 : 0 : class DXFInsertEntity : public DXFBasicEntity {
253 : :
254 : : public:
255 : :
256 : : long nAttrFlag; // 66
257 : : char sName[DXF_MAX_STRING_LEN+1]; // 2
258 : : DXFVector aP0; // 10,20,30
259 : : double fXScale; // 41
260 : : double fYScale; // 42
261 : : double fZScale; // 43
262 : : double fRotAngle; // 50
263 : : long nColCount; // 70
264 : : long nRowCount; // 71
265 : : double fColSpace; // 44
266 : : double fRowSpace; // 45
267 : :
268 : : DXFInsertEntity();
269 : :
270 : : protected:
271 : :
272 : : virtual void EvaluateGroup(DXFGroupReader & rDGR);
273 : : };
274 : :
275 : : //--------------------------AttDef----------------------------------------------
276 : :
277 : 0 : class DXFAttDefEntity : public DXFBasicEntity {
278 : :
279 : : public:
280 : :
281 : : DXFVector aP0; // 10,20,30
282 : : double fHeight; // 40
283 : : char sDefVal[DXF_MAX_STRING_LEN+1]; // 1
284 : : char sPrompt[DXF_MAX_STRING_LEN+1]; // 3
285 : : char sTagStr[DXF_MAX_STRING_LEN+1]; // 2
286 : : long nAttrFlags; // 70
287 : : long nFieldLen; // 73
288 : : double fRotAngle; // 50
289 : : double fXScale; // 41
290 : : double fOblAngle; // 51
291 : : char sStyle[DXF_MAX_STRING_LEN+1]; // 7
292 : : long nGenFlags; // 71
293 : : long nHorzJust; // 72
294 : : long nVertJust; // 74
295 : : DXFVector aAlign; // 11,21,31
296 : :
297 : : DXFAttDefEntity();
298 : :
299 : : protected:
300 : :
301 : : virtual void EvaluateGroup(DXFGroupReader & rDGR);
302 : : };
303 : :
304 : : //--------------------------Attrib----------------------------------------------
305 : :
306 : 0 : class DXFAttribEntity : public DXFBasicEntity {
307 : :
308 : : public:
309 : :
310 : : DXFVector aP0; // 10,20,30
311 : : double fHeight; // 40
312 : : char sText[DXF_MAX_STRING_LEN+1]; // 1
313 : : char sTagStr[DXF_MAX_STRING_LEN+1]; // 2
314 : : long nAttrFlags; // 70
315 : : long nFieldLen; // 73
316 : : double fRotAngle; // 50
317 : : double fXScale; // 41
318 : : double fOblAngle; // 51
319 : : char sStyle[DXF_MAX_STRING_LEN+1]; // 7
320 : : long nGenFlags; // 71
321 : : long nHorzJust; // 72
322 : : long nVertJust; // 74
323 : : DXFVector aAlign; // 11,21,31
324 : :
325 : : DXFAttribEntity();
326 : :
327 : : protected:
328 : :
329 : : virtual void EvaluateGroup(DXFGroupReader & rDGR);
330 : : };
331 : :
332 : : //--------------------------PolyLine--------------------------------------------
333 : :
334 : 0 : class DXFPolyLineEntity : public DXFBasicEntity {
335 : :
336 : : public:
337 : :
338 : : double fElevation; // 30
339 : : long nFlags; // 70
340 : : double fSWidth; // 40
341 : : double fEWidth; // 41
342 : : long nMeshMCount; // 71
343 : : long nMeshNCount; // 72
344 : : long nMDensity; // 73
345 : : long nNDensity; // 74
346 : : long nCSSType; // 75
347 : :
348 : : DXFPolyLineEntity();
349 : :
350 : : protected:
351 : :
352 : : virtual void EvaluateGroup(DXFGroupReader & rDGR);
353 : : };
354 : :
355 : : class DXFLWPolyLineEntity : public DXFBasicEntity
356 : : {
357 : : sal_Int32 nIndex;
358 : :
359 : : public :
360 : :
361 : : sal_Int32 nCount; // 90
362 : : sal_Int32 nFlags; // 70 1 = closed, 128 = plinegen
363 : : double fConstantWidth; // 43 (optional - default: 0, not used if fStartWidth and/or fEndWidth is used)
364 : : double fStartWidth; // 40
365 : : double fEndWidth; // 41
366 : :
367 : : DXFVector* pP;
368 : :
369 : : DXFLWPolyLineEntity();
370 : : ~DXFLWPolyLineEntity();
371 : :
372 : : protected :
373 : :
374 : : virtual void EvaluateGroup( DXFGroupReader & rDGR );
375 : :
376 : : };
377 : :
378 : : //-------------------------- Hatch ---------------------------------------------
379 : :
380 : : struct DXFEdgeType
381 : : {
382 : : sal_Int32 nEdgeType;
383 : :
384 : 0 : virtual ~DXFEdgeType(){};
385 : 0 : virtual sal_Bool EvaluateGroup( DXFGroupReader & /*rDGR*/ ){ return sal_True; };
386 : :
387 : : protected :
388 : :
389 : 0 : DXFEdgeType( sal_Int32 EdgeType ):nEdgeType(EdgeType){};
390 : : };
391 : : struct DXFEdgeTypeLine : public DXFEdgeType
392 : : {
393 : : DXFVector aStartPoint; // 10,20
394 : : DXFVector aEndPoint; // 11,21
395 : : DXFEdgeTypeLine();
396 : : virtual ~DXFEdgeTypeLine();
397 : : virtual sal_Bool EvaluateGroup( DXFGroupReader & rDGR );
398 : : };
399 : : struct DXFEdgeTypeCircularArc : public DXFEdgeType
400 : : {
401 : : DXFVector aCenter; // 10,20
402 : : double fRadius; // 40
403 : : double fStartAngle; // 50
404 : : double fEndAngle; // 51
405 : : sal_Int32 nIsCounterClockwiseFlag; // 73
406 : : DXFEdgeTypeCircularArc();
407 : : virtual ~DXFEdgeTypeCircularArc();
408 : : virtual sal_Bool EvaluateGroup( DXFGroupReader & rDGR );
409 : : };
410 : : struct DXFEdgeTypeEllipticalArc : public DXFEdgeType
411 : : {
412 : : DXFVector aCenter; // 10,20
413 : : DXFVector aEndPoint; // 11,21
414 : : double fLength; // 40
415 : : double fStartAngle; // 50
416 : : double fEndAngle; // 51
417 : : sal_Int32 nIsCounterClockwiseFlag; // 73
418 : :
419 : : DXFEdgeTypeEllipticalArc();
420 : : virtual ~DXFEdgeTypeEllipticalArc();
421 : : virtual sal_Bool EvaluateGroup( DXFGroupReader & rDGR );
422 : : };
423 : : struct DXFEdgeTypeSpline : public DXFEdgeType
424 : : {
425 : : sal_Int32 nDegree; // 94
426 : : sal_Int32 nRational; // 73
427 : : sal_Int32 nPeriodic; // 74
428 : : sal_Int32 nKnotCount; // 75
429 : : sal_Int32 nControlCount; // 76
430 : :
431 : : DXFEdgeTypeSpline();
432 : : virtual ~DXFEdgeTypeSpline();
433 : : virtual sal_Bool EvaluateGroup( DXFGroupReader & rDGR );
434 : : };
435 : :
436 : : typedef std::deque< DXFEdgeType* > DXFEdgeTypeArray;
437 : :
438 : : struct DXFBoundaryPathData
439 : : {
440 : : sal_Int32 nFlags; // 92
441 : : sal_Int32 nHasBulgeFlag; // 72
442 : : sal_Int32 nIsClosedFlag; // 73
443 : : sal_Int32 nPointCount; // 93
444 : : double fBulge; // 42
445 : : sal_Int32 nSourceBoundaryObjects; // 97
446 : : sal_Int32 nEdgeCount; // 93
447 : :
448 : : sal_Bool bIsPolyLine;
449 : : sal_Int32 nPointIndex;
450 : :
451 : : DXFVector* pP;
452 : : DXFEdgeTypeArray aEdges;
453 : :
454 : : DXFBoundaryPathData();
455 : : ~DXFBoundaryPathData();
456 : :
457 : : sal_Bool EvaluateGroup( DXFGroupReader & rDGR );
458 : : };
459 : :
460 : : class DXFHatchEntity : public DXFBasicEntity
461 : : {
462 : : sal_Bool bIsInBoundaryPathContext;
463 : : sal_Int32 nCurrentBoundaryPathIndex;
464 : :
465 : : public :
466 : :
467 : : DXFVector aElevationPoint;
468 : : sal_Int32 nFlags; // 70 (solid fill = 1, pattern fill = 0)
469 : : sal_Int32 nAssociativityFlag; // 71 (assoiciative = 1, non-associative = 0)
470 : : sal_Int32 nBoundaryPathCount; // 91
471 : : sal_Int32 nHatchStyle; // 75 (odd parity = 0, outmost area = 1, entire area = 2 )
472 : : sal_Int32 nHatchPatternType; // 76 (user defined = 0, predefined = 1, custom = 2)
473 : : double fHatchPatternAngle; // 52 (pattern fill only)
474 : : double fHatchPatternScale; // 41 (pattern fill only:scale or spacing)
475 : : sal_Int32 nHatchDoubleFlag; // 77 (pattern fill only:double = 1, not double = 0)
476 : : sal_Int32 nHatchPatternDefinitionLines; // 78
477 : : double fPixelSize; // 47
478 : : sal_Int32 nNumberOfSeedPoints; // 98
479 : :
480 : : DXFBoundaryPathData* pBoundaryPathData;
481 : :
482 : : DXFHatchEntity();
483 : : ~DXFHatchEntity();
484 : :
485 : : protected :
486 : :
487 : : virtual void EvaluateGroup( DXFGroupReader & rDGR );
488 : : };
489 : :
490 : :
491 : : //--------------------------Vertex----------------------------------------------
492 : :
493 : 0 : class DXFVertexEntity : public DXFBasicEntity {
494 : :
495 : : public:
496 : :
497 : : DXFVector aP0; // 10,20,30
498 : : double fSWidth; // 40 (Wenn <0.0, dann gilt DXFPolyLine::fSWidth)
499 : : double fEWidth; // 41 (Wenn <0.0, dann gilt DXFPolyLine::fEWidth)
500 : : double fBulge; // 42
501 : : long nFlags; // 70
502 : : double fCFTDir; // 50
503 : :
504 : : DXFVertexEntity();
505 : :
506 : : protected:
507 : :
508 : : virtual void EvaluateGroup(DXFGroupReader & rDGR);
509 : : };
510 : :
511 : : //--------------------------SeqEnd----------------------------------------------
512 : :
513 : 0 : class DXFSeqEndEntity : public DXFBasicEntity {
514 : :
515 : : public:
516 : :
517 : : DXFSeqEndEntity();
518 : : };
519 : :
520 : : //--------------------------3DFace----------------------------------------------
521 : :
522 : 0 : class DXF3DFaceEntity : public DXFBasicEntity {
523 : :
524 : : public:
525 : :
526 : : DXFVector aP0; // 10,20,30
527 : : DXFVector aP1; // 11,21,31
528 : : DXFVector aP2; // 12,22,32
529 : : DXFVector aP3; // 13,23,33
530 : : long nIEFlags; // 70
531 : :
532 : : DXF3DFaceEntity();
533 : :
534 : : protected:
535 : :
536 : : virtual void EvaluateGroup(DXFGroupReader & rDGR);
537 : : };
538 : :
539 : : //--------------------------Dimension-------------------------------------------
540 : :
541 : 0 : class DXFDimensionEntity : public DXFBasicEntity {
542 : :
543 : : public:
544 : :
545 : : char sPseudoBlock[DXF_MAX_STRING_LEN+1]; // 2
546 : :
547 : : DXFDimensionEntity();
548 : :
549 : : protected:
550 : :
551 : : virtual void EvaluateGroup(DXFGroupReader & rDGR);
552 : : };
553 : :
554 : : //------------------------------------------------------------------------------
555 : : //----------- Eine Menge von Entities lesen und repraesentieren ----------------
556 : : //------------------------------------------------------------------------------
557 : :
558 : : class DXFEntities {
559 : :
560 : : public:
561 : :
562 : : DXFEntities();
563 : : ~DXFEntities();
564 : :
565 : : DXFBasicEntity * pFirst; // Liste von Entities, READ ONLY!
566 : :
567 : : void Read(DXFGroupReader & rDGR);
568 : : // Liest Entitis per rGDR aus einer DXF-Datei bis zu
569 : : // einem ENDBLK, ENDSEC oder EOF (der Gruppe 0).
570 : : // (Alle unbekannten Dinge werden uebersprungen)
571 : :
572 : : void Clear();
573 : : // Loescht alle Entities
574 : : };
575 : :
576 : : //------------------------------------------------------------------------------
577 : : //--------------------------------- inlines ------------------------------------
578 : : //------------------------------------------------------------------------------
579 : :
580 : 0 : inline DXFEntities::DXFEntities()
581 : : {
582 : 0 : pFirst=NULL;
583 : 0 : }
584 : :
585 : :
586 : 0 : inline DXFEntities::~DXFEntities()
587 : : {
588 : 0 : Clear();
589 : 0 : }
590 : :
591 : :
592 : : #endif
593 : :
594 : :
595 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|