1 /****************************************************************************** 2 ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 ** ** 4 ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 ** ** 6 ** This library is free software, licensed under the terms of the GNU ** 7 ** General Public License as published by the Free Software Foundation, ** 8 ** either version 2 of the License, or (at your option) any later version. ** 9 ** You should have received a copy of the GNU General Public License ** 10 ** along with this program. If not, see <http://www.gnu.org/licenses/>. ** 11 ******************************************************************************/ 12 13 #ifndef DRW_ENTITIES_H 14 #define DRW_ENTITIES_H 15 16 17 #include <string> 18 #include <vector> 19 #include <list> 20 #include "drw_base.h" 21 22 class dxfReader; 23 class dwgBuffer; 24 class DRW_Polyline; 25 26 namespace DRW { 27 28 //! Entity's type. 29 enum ETYPE { 30 E3DFACE, 31 // E3DSOLID, //encripted propietry data 32 // ACAD_PROXY_ENTITY, 33 ARC, 34 // ATTDEF, 35 // ATTRIB, 36 BLOCK,// and ENDBLK 37 // BODY, //encripted propietry data 38 CIRCLE, 39 DIMENSION, 40 DIMALIGNED, 41 DIMLINEAR, 42 DIMRADIAL, 43 DIMDIAMETRIC, 44 DIMANGULAR, 45 DIMANGULAR3P, 46 DIMORDINATE, 47 ELLIPSE, 48 HATCH, 49 // HELIX, 50 IMAGE, 51 INSERT, 52 LEADER, 53 // LIGHT, 54 LINE, 55 LWPOLYLINE, 56 // MESH, 57 // MLINE, 58 // MLEADERSTYLE, 59 // MLEADER, 60 MTEXT, 61 // OLEFRAME, 62 // OLE2FRAME, 63 POINT, 64 POLYLINE, 65 RAY, 66 // REGION, //encripted propietry data 67 // SECTION, 68 // SEQEND,//not needed?? used in polyline and insert/attrib and dwg 69 // SHAPE, 70 SOLID, 71 SPLINE, 72 // SUN, 73 // SURFACE, //encripted propietry data can be four types 74 // TABLE, 75 TEXT, 76 // TOLERANCE, 77 TRACE, 78 UNDERLAY, 79 VERTEX, 80 VIEWPORT, 81 // WIPEOUT, //WIPEOUTVARIABLE 82 XLINE, 83 UNKNOWN 84 }; 85 86 } 87 //only in DWG: MINSERT, 5 types of vertex, 4 types of polylines: 2d, 3d, pface & mesh 88 //shape, dictionary, MLEADER, MLEADERSTYLE 89 90 #define SETENTFRIENDS friend class dxfRW; \ 91 friend class dwgReader; 92 93 //! Base class for entities 94 /*! 95 * Base class for entities 96 * @author Rallaz 97 */ 98 class DRW_Entity { 99 SETENTFRIENDS 100 public: 101 //initializes default values DRW_Entity()102 DRW_Entity() { 103 eType = DRW::UNKNOWN; 104 handle = parentHandle = DRW::NoHandle; //no handle (0) 105 lineType = "BYLAYER"; 106 color = DRW::ColorByLayer; // default BYLAYER (256) 107 ltypeScale = 1.0; 108 visible = true; 109 layer = "0"; 110 lWeight = DRW_LW_Conv::widthByLayer; // default BYLAYER (dxf -1, dwg 29) 111 space = DRW::ModelSpace; // default ModelSpace (0) 112 haveExtrusion = false; 113 color24 = -1; //default -1 not set 114 numProxyGraph = 0; 115 shadow = DRW::CastAndReceieveShadows; 116 material = DRW::MaterialByLayer; 117 plotStyle = DRW::DefaultPlotStyle; 118 transparency = DRW::Opaque; 119 nextEntLink = prevEntLink = 0; 120 numReactors = xDictFlag = 0; 121 curr = NULL; 122 ownerHandle= false; 123 } 124 DRW_Entity(const DRW_Entity & e)125 DRW_Entity(const DRW_Entity& e) { 126 eType = e.eType; 127 handle = e.handle; 128 parentHandle = e.parentHandle; //no handle (0) 129 lineType = e.lineType; 130 color = e.color; // default BYLAYER (256) 131 ltypeScale = e.ltypeScale; 132 visible = e.visible; 133 layer = e.layer; 134 lWeight = e.lWeight; 135 space = e.space; 136 haveExtrusion = e.haveExtrusion; 137 color24 = e.color24; //default -1 not set 138 numProxyGraph = e.numProxyGraph; 139 shadow = e.shadow; 140 material = e.material; 141 plotStyle = e.plotStyle; 142 transparency = e.transparency; 143 nextEntLink = e.nextEntLink; 144 prevEntLink = e.prevEntLink; 145 numReactors = e.numReactors; 146 xDictFlag = e.xDictFlag; 147 curr = NULL; 148 ownerHandle= false; 149 // curr = e.curr; 150 for (std::vector<DRW_Variant*>::const_iterator it=e.extData.begin(); it!=e.extData.end(); ++it){ 151 extData.push_back(new DRW_Variant(*(*it))); 152 } 153 } 154 ~DRW_Entity()155 virtual ~DRW_Entity() { 156 for (std::vector<DRW_Variant*>::iterator it=extData.begin(); it!=extData.end(); ++it) 157 delete *it; 158 159 extData.clear(); 160 } 161 reset()162 void reset(){ 163 for (std::vector<DRW_Variant*>::iterator it=extData.begin(); it!=extData.end(); ++it) 164 delete *it; 165 extData.clear(); 166 } 167 168 virtual void applyExtrusion() = 0; 169 setWidthMm(double millimeters)170 void setWidthMm(double millimeters) { 171 if(millimeters < 0.0) { 172 lWeight = DRW_LW_Conv::widthByLayer; 173 return; 174 } 175 if(millimeters > 2.11) millimeters = 2.11; 176 lWeight = DRW_LW_Conv::dxfInt2lineWidth(int(floor(millimeters * 100.0))); 177 } 178 179 protected: 180 //parses dxf pair to read entity 181 bool parseCode(int code, dxfReader *reader); 182 //calculates extrusion axis (normal vector) 183 void calculateAxis(DRW_Coord extPoint); 184 //apply extrusion to @extPoint and return data in @point 185 void extrudePoint(DRW_Coord extPoint, DRW_Coord *point); 186 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0)=0; 187 //parses dwg common start part to read entity 188 bool parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer* strBuf, duint32 bs=0); 189 //parses dwg common handles part to read entity 190 bool parseDwgEntHandle(DRW::Version version, dwgBuffer *buf); 191 192 //parses dxf 102 groups to read entity 193 bool parseDxfGroups(int code, dxfReader *reader); 194 195 public: 196 enum DRW::ETYPE eType; /*!< enum: entity type, code 0 */ 197 duint32 handle; /*!< entity identifier, code 5 */ 198 std::list<std::list<DRW_Variant> > appData; /*!< list of application data, code 102 */ 199 duint32 parentHandle; /*!< Soft-pointer ID/handle to owner BLOCK_RECORD object, code 330 */ 200 DRW::Space space; /*!< space indicator, code 67*/ 201 UTF8STRING layer; /*!< layer name, code 8 */ 202 UTF8STRING lineType; /*!< line type, code 6 */ 203 duint32 material; /*!< hard pointer id to material object, code 347 */ 204 int color; /*!< entity color, code 62 */ 205 enum DRW_LW_Conv::lineWidth lWeight; /*!< entity lineweight, code 370 */ 206 double ltypeScale; /*!< linetype scale, code 48 */ 207 bool visible; /*!< entity visibility, code 60 */ 208 int numProxyGraph; /*!< Number of bytes in proxy graphics, code 92 */ 209 std::string proxyGraphics; /*!< proxy graphics bytes, code 310 */ 210 int color24; /*!< 24-bit color, code 420 */ 211 std::string colorName; /*!< color name, code 430 */ 212 int transparency; /*!< transparency, code 440 */ 213 int plotStyle; /*!< hard pointer id to plot style object, code 390 */ 214 DRW::ShadowMode shadow; /*!< shadow mode, code 284 */ 215 bool haveExtrusion; /*!< set to true if the entity have extrusion*/ 216 std::vector<DRW_Variant*> extData; /*!< FIFO list of extended data, codes 1000 to 1071*/ 217 218 protected: //only for read dwg 219 duint8 haveNextLinks; //aka nolinks //B 220 duint8 plotFlags; //presence of plot style //BB 221 duint8 ltFlags; //presence of linetype handle //BB 222 duint8 materialFlag; //presence of material handle //BB 223 duint8 shadowFlag; //presence of shadow handle ?? (in dwg may be plotflag)//RC 224 dwgHandle lTypeH; 225 dwgHandle layerH; 226 duint32 nextEntLink; 227 duint32 prevEntLink; 228 bool ownerHandle; 229 230 duint8 xDictFlag; 231 dint32 numReactors; // 232 duint32 objSize; //RL 32bits object data size in bits 233 dint16 oType; 234 235 private: 236 DRW_Coord extAxisX; 237 DRW_Coord extAxisY; 238 DRW_Variant* curr; 239 }; 240 241 242 //! Class to handle point entity 243 /*! 244 * Class to handle point entity 245 * @author Rallaz 246 */ 247 class DRW_Point : public DRW_Entity { 248 SETENTFRIENDS 249 public: DRW_Point()250 DRW_Point() { 251 eType = DRW::POINT; 252 basePoint.z = extPoint.x = extPoint.y = 0; 253 extPoint.z = 1; 254 thickness = 0; 255 } 256 applyExtrusion()257 virtual void applyExtrusion(){} 258 259 protected: 260 void parseCode(int code, dxfReader *reader); 261 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 262 263 public: 264 DRW_Coord basePoint; /*!< base point, code 10, 20 & 30 */ 265 double thickness; /*!< thickness, code 39 */ 266 DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */ 267 // TNick: we're not handling code 50 - Angle of the X axis for 268 // the UCS in effect when the point was drawn 269 }; 270 271 //! Class to handle line entity 272 /*! 273 * Class to handle line entity 274 * @author Rallaz 275 */ 276 class DRW_Line : public DRW_Point { 277 SETENTFRIENDS 278 public: DRW_Line()279 DRW_Line() { 280 eType = DRW::LINE; 281 secPoint.z = 0; 282 } 283 applyExtrusion()284 virtual void applyExtrusion(){} 285 286 protected: 287 void parseCode(int code, dxfReader *reader); 288 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 289 290 public: 291 DRW_Coord secPoint; /*!< second point, code 11, 21 & 31 */ 292 }; 293 294 //! Class to handle ray entity 295 /*! 296 * Class to handle ray entity 297 * @author Rallaz 298 */ 299 class DRW_Ray : public DRW_Line { 300 SETENTFRIENDS 301 public: DRW_Ray()302 DRW_Ray() { 303 eType = DRW::RAY; 304 } 305 protected: 306 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 307 }; 308 309 //! Class to handle xline entity 310 /*! 311 * Class to handle xline entity 312 * @author Rallaz 313 */ 314 class DRW_Xline : public DRW_Ray { 315 public: DRW_Xline()316 DRW_Xline() { 317 eType = DRW::XLINE; 318 } 319 }; 320 321 //! Class to handle circle entity 322 /*! 323 * Class to handle circle entity 324 * @author Rallaz 325 */ 326 class DRW_Circle : public DRW_Point { 327 SETENTFRIENDS 328 public: DRW_Circle()329 DRW_Circle() { 330 eType = DRW::CIRCLE; 331 } 332 333 virtual void applyExtrusion(); 334 335 protected: 336 void parseCode(int code, dxfReader *reader); 337 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 338 339 public: 340 double radious; /*!< radius, code 40 */ 341 }; 342 343 //! Class to handle arc entity 344 /*! 345 * Class to handle arc entity 346 * @author Rallaz 347 */ 348 class DRW_Arc : public DRW_Circle { 349 SETENTFRIENDS 350 public: DRW_Arc()351 DRW_Arc() { 352 eType = DRW::ARC; 353 isccw = 1; 354 } 355 356 virtual void applyExtrusion(); 357 358 //! center point in OCS center()359 const DRW_Coord & center() { return basePoint; } 360 //! the radius of the circle radius()361 double radius() { return radious; } 362 //! start angle in radians startAngle()363 double startAngle() { return staangle; } 364 //! end angle in radians endAngle()365 double endAngle() { return endangle; } 366 //! thickness thick()367 double thick() { return thickness; } 368 //! extrusion extrusion()369 const DRW_Coord & extrusion() { return extPoint; } 370 371 protected: 372 //! interpret code in dxf reading process or dispatch to inherited class 373 void parseCode(int code, dxfReader *reader); 374 //! interpret dwg data (was already determined to be part of this object) 375 virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0); 376 377 public: 378 double staangle; /*!< start angle, code 50 in radians*/ 379 double endangle; /*!< end angle, code 51 in radians */ 380 int isccw; /*!< is counter clockwise arc?, only used in hatch, code 73 */ 381 }; 382 383 //! Class to handle ellipse entity 384 /*! 385 * Class to handle ellipse and elliptic arc entity 386 * Note: start/end parameter are in radians for ellipse entity but 387 * for hatch boundary are in degrees 388 * @author Rallaz 389 */ 390 class DRW_Ellipse : public DRW_Line { 391 SETENTFRIENDS 392 public: DRW_Ellipse()393 DRW_Ellipse() { 394 eType = DRW::ELLIPSE; 395 isccw = 1; 396 } 397 398 void toPolyline(DRW_Polyline *pol, int parts = 128); 399 virtual void applyExtrusion(); 400 401 protected: 402 //! interpret code in dxf reading process or dispatch to inherited class 403 void parseCode(int code, dxfReader *reader); 404 //! interpret dwg data (was already determined to be part of this object) 405 virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0); 406 407 private: 408 void correctAxis(); 409 410 public: 411 double ratio; /*!< ratio, code 40 */ 412 double staparam; /*!< start parameter, code 41, 0.0 for full ellipse*/ 413 double endparam; /*!< end parameter, code 42, 2*PI for full ellipse */ 414 int isccw; /*!< is counter clockwise arc?, only used in hatch, code 73 */ 415 }; 416 417 //! Class to handle trace entity 418 /*! 419 * Class to handle trace entity 420 * @author Rallaz 421 */ 422 class DRW_Trace : public DRW_Line { 423 SETENTFRIENDS 424 public: DRW_Trace()425 DRW_Trace() { 426 eType = DRW::TRACE; 427 thirdPoint.z = 0; 428 fourPoint.z = 0; 429 } 430 431 virtual void applyExtrusion(); 432 433 protected: 434 void parseCode(int code, dxfReader *reader); 435 virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0); 436 437 public: 438 DRW_Coord thirdPoint; /*!< third point, code 12, 22 & 32 */ 439 DRW_Coord fourPoint; /*!< four point, code 13, 23 & 33 */ 440 }; 441 442 //! Class to handle solid entity 443 /*! 444 * Class to handle solid entity 445 * @author Rallaz 446 */ 447 class DRW_Solid : public DRW_Trace { 448 SETENTFRIENDS 449 public: DRW_Solid()450 DRW_Solid() { 451 eType = DRW::SOLID; 452 } 453 454 protected: 455 //! interpret code in dxf reading process or dispatch to inherited class 456 void parseCode(int code, dxfReader *reader); 457 //! interpret dwg data (was already determined to be part of this object) 458 virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0); 459 460 public: 461 //! first corner (2D) firstCorner()462 const DRW_Coord & firstCorner() { return basePoint; } 463 //! second corner (2D) secondCorner()464 const DRW_Coord & secondCorner() { return secPoint; } 465 //! third corner (2D) thirdCorner()466 const DRW_Coord & thirdCorner() { return thirdPoint; } 467 //! fourth corner (2D) fourthCorner()468 const DRW_Coord & fourthCorner() { return thirdPoint; } 469 //! thickness thick()470 double thick() { return thickness; } 471 //! elevation elevation()472 double elevation() { return basePoint.z; } 473 //! extrusion extrusion()474 const DRW_Coord & extrusion() { return extPoint; } 475 476 }; 477 478 //! Class to handle 3dface entity 479 /*! 480 * Class to handle 3dface entity 481 * @author Rallaz 482 */ 483 class DRW_3Dface : public DRW_Trace { 484 SETENTFRIENDS 485 public: 486 enum InvisibleEdgeFlags { 487 NoEdge = 0x00, 488 FirstEdge = 0x01, 489 SecodEdge = 0x02, 490 ThirdEdge = 0x04, 491 FourthEdge = 0x08, 492 AllEdges = 0x0F 493 }; 494 DRW_3Dface()495 DRW_3Dface() { 496 eType = DRW::E3DFACE; 497 invisibleflag = 0; 498 } 499 applyExtrusion()500 virtual void applyExtrusion(){} 501 502 //! first corner in WCS firstCorner()503 const DRW_Coord & firstCorner() { return basePoint; } 504 //! second corner in WCS secondCorner()505 const DRW_Coord & secondCorner() { return secPoint; } 506 //! third corner in WCS thirdCorner()507 const DRW_Coord & thirdCorner() { return thirdPoint; } 508 //! fourth corner in WCS fourthCorner()509 const DRW_Coord & fourthCorner() { return fourPoint; } 510 //! edge visibility flags edgeFlags()511 InvisibleEdgeFlags edgeFlags() { return (InvisibleEdgeFlags)invisibleflag; } 512 513 protected: 514 //! interpret code in dxf reading process or dispatch to inherited class 515 void parseCode(int code, dxfReader *reader); 516 //! interpret dwg data (was already determined to be part of this object) 517 virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0); 518 519 public: 520 int invisibleflag; /*!< invisible edge flag, code 70 */ 521 522 }; 523 524 //! Class to handle block entries 525 /*! 526 * Class to handle block entries 527 * @author Rallaz 528 */ 529 class DRW_Block : public DRW_Point { 530 SETENTFRIENDS 531 public: DRW_Block()532 DRW_Block() { 533 eType = DRW::BLOCK; 534 layer = "0"; 535 flags = 0; 536 name = "*U0"; 537 isEnd = false; 538 } 539 applyExtrusion()540 virtual void applyExtrusion(){} 541 542 protected: 543 void parseCode(int code, dxfReader *reader); 544 virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0); 545 546 public: 547 UTF8STRING name; /*!< block name, code 2 */ 548 int flags; /*!< block type, code 70 */ 549 private: 550 bool isEnd; //for dwg parsing 551 }; 552 553 554 //! Class to handle insert entries 555 /*! 556 * Class to handle insert entries 557 * @author Rallaz 558 */ 559 class DRW_Insert : public DRW_Point { 560 SETENTFRIENDS 561 public: DRW_Insert()562 DRW_Insert() { 563 eType = DRW::INSERT; 564 xscale = 1; 565 yscale = 1; 566 zscale = 1; 567 angle = 0; 568 colcount = 1; 569 rowcount = 1; 570 colspace = 0; 571 rowspace = 0; 572 } 573 applyExtrusion()574 virtual void applyExtrusion(){DRW_Point::applyExtrusion();} 575 576 protected: 577 void parseCode(int code, dxfReader *reader); 578 virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0); 579 580 public: 581 UTF8STRING name; /*!< block name, code 2 */ 582 double xscale; /*!< x scale factor, code 41 */ 583 double yscale; /*!< y scale factor, code 42 */ 584 double zscale; /*!< z scale factor, code 43 */ 585 double angle; /*!< rotation angle in radians, code 50 */ 586 int colcount; /*!< column count, code 70 */ 587 int rowcount; /*!< row count, code 71 */ 588 double colspace; /*!< column space, code 44 */ 589 double rowspace; /*!< row space, code 45 */ 590 public: //only for read dwg 591 dwgHandle blockRecH; 592 dwgHandle seqendH; //RLZ: on implement attrib remove this handle from obj list (see pline/vertex code) 593 }; 594 595 //! Class to handle lwpolyline entity 596 /*! 597 * Class to handle lwpolyline entity 598 * @author Rallaz 599 */ 600 class DRW_LWPolyline : public DRW_Entity { 601 SETENTFRIENDS 602 public: DRW_LWPolyline()603 DRW_LWPolyline() { 604 eType = DRW::LWPOLYLINE; 605 elevation = thickness = width = 0.0; 606 flags = 0; 607 extPoint.x = extPoint.y = 0; 608 extPoint.z = 1; 609 vertex = NULL; 610 } 611 DRW_LWPolyline(const DRW_LWPolyline & p)612 DRW_LWPolyline(const DRW_LWPolyline& p):DRW_Entity(p){ 613 this->eType = DRW::LWPOLYLINE; 614 this->elevation = p.elevation; 615 this->thickness = p.thickness; 616 this->width = p.width; 617 this->flags = p.flags; 618 this->extPoint = p.extPoint; 619 this->vertex = NULL; 620 for (unsigned i=0; i<p.vertlist.size(); i++)// RLZ ok or new 621 this->vertlist.push_back( new DRW_Vertex2D( *(p.vertlist.at(i)) ) ); 622 623 this->vertex = NULL; 624 } 625 ~DRW_LWPolyline()626 ~DRW_LWPolyline() { 627 for(DRW_Vertex2D *item : vertlist) delete item; 628 } 629 virtual void applyExtrusion(); addVertex(DRW_Vertex2D v)630 void addVertex (DRW_Vertex2D v) { 631 DRW_Vertex2D *vert = new DRW_Vertex2D(); 632 vert->x = v.x; 633 vert->y = v.y; 634 vert->stawidth = v.stawidth; 635 vert->endwidth = v.endwidth; 636 vert->bulge = v.bulge; 637 vertlist.push_back(vert); 638 } addVertex()639 DRW_Vertex2D *addVertex () { 640 DRW_Vertex2D *vert = new DRW_Vertex2D(); 641 vert->stawidth = 0; 642 vert->endwidth = 0; 643 vert->bulge = 0; 644 vertlist.push_back(vert); 645 return vert; 646 } 647 648 protected: 649 void parseCode(int code, dxfReader *reader); 650 bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0); 651 652 public: 653 int vertexnum; /*!< number of vertex, code 90 */ 654 int flags; /*!< polyline flag, code 70, default 0 */ 655 double width; /*!< constant width, code 43 */ 656 double elevation; /*!< elevation, code 38 */ 657 double thickness; /*!< thickness, code 39 */ 658 DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */ 659 DRW_Vertex2D *vertex; /*!< current vertex to add data */ 660 std::vector<DRW_Vertex2D *> vertlist; /*!< vertex list */ 661 }; 662 663 //! Class to handle insert entries 664 /*! 665 * Class to handle insert entries 666 * @author Rallaz 667 */ 668 class DRW_Text : public DRW_Line { 669 SETENTFRIENDS 670 public: 671 //! Vertical alignments. 672 enum VAlign { 673 VBaseLine = 0, /*!< Top = 0 */ 674 VBottom, /*!< Bottom = 1 */ 675 VMiddle, /*!< Middle = 2 */ 676 VTop /*!< Top = 3 */ 677 }; 678 679 //! Horizontal alignments. 680 enum HAlign { 681 HLeft = 0, /*!< Left = 0 */ 682 HCenter, /*!< Centered = 1 */ 683 HRight, /*!< Right = 2 */ 684 HAligned, /*!< Aligned = 3 (if VAlign==0) */ 685 HMiddle, /*!< middle = 4 (if VAlign==0) */ 686 HFit /*!< fit into point = 5 (if VAlign==0) */ 687 }; 688 DRW_Text()689 DRW_Text() { 690 eType = DRW::TEXT; 691 angle = 0; 692 widthscale = 1; 693 oblique = 0; 694 style = "STANDARD"; 695 textgen = 0; 696 alignH = HLeft; 697 alignV = VBaseLine; 698 } 699 applyExtrusion()700 virtual void applyExtrusion(){} //RLZ TODO 701 702 protected: 703 void parseCode(int code, dxfReader *reader); 704 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 705 706 public: 707 double height; /*!< height text, code 40 */ 708 UTF8STRING text; /*!< text string, code 1 */ 709 double angle; /*!< rotation angle in degrees (360), code 50 */ 710 double widthscale; /*!< width factor, code 41 */ 711 double oblique; /*!< oblique angle, code 51 */ 712 UTF8STRING style; /*!< style name, code 7 */ 713 int textgen; /*!< text generation, code 71 */ 714 enum HAlign alignH; /*!< horizontal align, code 72 */ 715 enum VAlign alignV; /*!< vertical align, code 73 */ 716 dwgHandle styleH; /*!< handle for text style */ 717 }; 718 719 //! Class to handle insert entries 720 /*! 721 * Class to handle insert entries 722 * @author Rallaz 723 */ 724 class DRW_MText : public DRW_Text { 725 SETENTFRIENDS 726 public: 727 //! Attachments. 728 enum Attach { 729 TopLeft = 1, 730 TopCenter, 731 TopRight, 732 MiddleLeft, 733 MiddleCenter, 734 MiddleRight, 735 BottomLeft, 736 BottomCenter, 737 BottomRight 738 }; 739 DRW_MText()740 DRW_MText() { 741 eType = DRW::MTEXT; 742 interlin = 1; 743 alignV = (VAlign)TopLeft; 744 textgen = 1; 745 haveXAxis = false; //if true needed to recalculate angle 746 } 747 748 protected: 749 void parseCode(int code, dxfReader *reader); 750 void updateAngle(); //recalculate angle if 'haveXAxis' is true 751 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 752 753 public: 754 double interlin; /*!< width factor, code 44 */ 755 private: 756 bool haveXAxis; 757 }; 758 759 //! Class to handle vertex 760 /*! 761 * Class to handle vertex for polyline entity 762 * @author Rallaz 763 */ 764 class DRW_Vertex : public DRW_Point { 765 SETENTFRIENDS 766 public: DRW_Vertex()767 DRW_Vertex() { 768 eType = DRW::VERTEX; 769 stawidth = endwidth = bulge = 0; 770 vindex1 = vindex2 = vindex3 = vindex4 = 0; 771 flags = identifier = 0; 772 } DRW_Vertex(double sx,double sy,double sz,double b)773 DRW_Vertex(double sx, double sy, double sz, double b) { 774 stawidth = endwidth = 0; 775 vindex1 = vindex2 = vindex3 = vindex4 = 0; 776 flags = identifier = 0; 777 basePoint.x = sx; 778 basePoint.y =sy; 779 basePoint.z =sz; 780 bulge = b; 781 } 782 783 protected: 784 void parseCode(int code, dxfReader *reader); 785 bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0, double el=0); 786 virtual bool parseDwg(DRW::Version version, dwgBuffer* buf, duint32 bs=0){ 787 DRW_UNUSED(version); DRW_UNUSED(buf); DRW_UNUSED(bs); return true;} 788 789 public: 790 double stawidth; /*!< Start width, code 40 */ 791 double endwidth; /*!< End width, code 41 */ 792 double bulge; /*!< bulge, code 42 */ 793 794 int flags; /*!< vertex flag, code 70, default 0 */ 795 double tgdir; /*!< curve fit tangent direction, code 50 */ 796 int vindex1; /*!< polyface mesh vertex index, code 71, default 0 */ 797 int vindex2; /*!< polyface mesh vertex index, code 72, default 0 */ 798 int vindex3; /*!< polyface mesh vertex index, code 73, default 0 */ 799 int vindex4; /*!< polyface mesh vertex index, code 74, default 0 */ 800 int identifier; /*!< vertex identifier, code 91, default 0 */ 801 }; 802 803 //! Class to handle polyline entity 804 /*! 805 * Class to handle polyline entity 806 * @author Rallaz 807 */ 808 class DRW_Polyline : public DRW_Point { 809 SETENTFRIENDS 810 public: DRW_Polyline()811 DRW_Polyline() { 812 eType = DRW::POLYLINE; 813 defstawidth = defendwidth = 0.0; 814 basePoint.x = basePoint.y = 0.0; 815 flags = vertexcount = facecount = 0; 816 smoothM = smoothN = curvetype = 0; 817 } 818 DRW_Polyline(const DRW_Polyline & p)819 DRW_Polyline(const DRW_Polyline& p) : DRW_Point(p) { 820 flags = p.flags ; 821 defstawidth = p.defstawidth; 822 defendwidth = p.defendwidth; 823 vertexcount = p.vertexcount; 824 facecount = p.facecount ; 825 smoothM = p.smoothM ; 826 smoothN = p.smoothN ; 827 curvetype = p.curvetype ; 828 for (unsigned i=0; i<p.vertlist.size(); i++)// RLZ ok or new 829 this->vertlist.push_back( new DRW_Vertex( *(p.vertlist.at(i)) ) ); 830 } 831 ~DRW_Polyline()832 ~DRW_Polyline() { 833 for(DRW_Vertex *item : vertlist) delete item; 834 } addVertex(DRW_Vertex v)835 void addVertex (DRW_Vertex v) { 836 DRW_Vertex *vert = new DRW_Vertex(); 837 vert->basePoint.x = v.basePoint.x; 838 vert->basePoint.y = v.basePoint.y; 839 vert->basePoint.z = v.basePoint.z; 840 vert->stawidth = v.stawidth; 841 vert->endwidth = v.endwidth; 842 vert->bulge = v.bulge; 843 vertlist.push_back(vert); 844 } appendVertex(DRW_Vertex * v)845 void appendVertex (DRW_Vertex *v) { 846 vertlist.push_back(v); 847 } 848 849 protected: 850 void parseCode(int code, dxfReader *reader); 851 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 852 853 public: 854 int flags; /*!< polyline flag, code 70, default 0 */ 855 double defstawidth; /*!< Start width, code 40, default 0 */ 856 double defendwidth; /*!< End width, code 41, default 0 */ 857 int vertexcount; /*!< polygon mesh M vertex or polyface vertex num, code 71, default 0 */ 858 int facecount; /*!< polygon mesh N vertex or polyface face num, code 72, default 0 */ 859 int smoothM; /*!< smooth surface M density, code 73, default 0 */ 860 int smoothN; /*!< smooth surface M density, code 74, default 0 */ 861 int curvetype; /*!< curves & smooth surface type, code 75, default 0 */ 862 863 std::vector<DRW_Vertex *> vertlist; /*!< vertex list */ 864 865 private: 866 std::list<duint32>hadlesList; //list of handles, only in 2004+ 867 duint32 firstEH; //handle of first entity, only in pre-2004 868 duint32 lastEH; //handle of last entity, only in pre-2004 869 dwgHandle seqEndH; //handle of SEQEND entity 870 }; 871 872 873 //! Class to handle spline entity 874 /*! 875 * Class to handle spline entity 876 * @author Rallaz 877 */ 878 class DRW_Spline : public DRW_Entity { 879 SETENTFRIENDS 880 public: DRW_Spline()881 DRW_Spline() { 882 eType = DRW::SPLINE; 883 flags = nknots = ncontrol = nfit = 0; 884 tolknot = tolcontrol = tolfit = 0.0000001; 885 886 } 887 DRW_Spline(const DRW_Spline & p)888 DRW_Spline(const DRW_Spline& p):DRW_Entity(p){ 889 eType = DRW::SPLINE; 890 normalVec = p.normalVec ; 891 tgStart = p.tgStart ; 892 tgEnd = p.tgEnd ; 893 flags = p.flags ; 894 degree = p.degree ; 895 nknots = p.nknots ; 896 ncontrol = p.ncontrol ; 897 nfit = p.nfit ; 898 tolknot = p.tolknot ; 899 tolcontrol = p.tolcontrol; 900 tolfit = p.tolfit ; 901 902 for(double v : p.knotslist) knotslist.push_back(v); 903 for(double v : p.weightlist) weightlist.push_back(v); 904 for(DRW_Coord *v : p.controllist) controllist.push_back(new DRW_Coord(*v)); 905 for(DRW_Coord *v : p.fitlist) fitlist.push_back(new DRW_Coord(*v)); 906 } 907 ~DRW_Spline()908 ~DRW_Spline() { 909 for(DRW_Coord *item : controllist) delete item; 910 for(DRW_Coord *item : fitlist) delete item; 911 } applyExtrusion()912 virtual void applyExtrusion(){} 913 914 protected: 915 void parseCode(int code, dxfReader *reader); 916 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 917 918 public: 919 // double ex; /*!< normal vector x coordinate, code 210 */ 920 // double ey; /*!< normal vector y coordinate, code 220 */ 921 // double ez; /*!< normal vector z coordinate, code 230 */ 922 DRW_Coord normalVec; /*!< normal vector, code 210, 220, 230 */ 923 DRW_Coord tgStart; /*!< start tangent, code 12, 22, 32 */ 924 // double tgsx; /*!< start tangent x coordinate, code 12 */ 925 // double tgsy; /*!< start tangent y coordinate, code 22 */ 926 // double tgsz; /*!< start tangent z coordinate, code 32 */ 927 DRW_Coord tgEnd; /*!< end tangent, code 13, 23, 33 */ 928 // double tgex; /*!< end tangent x coordinate, code 13 */ 929 // double tgey; /*!< end tangent y coordinate, code 23 */ 930 // double tgez; /*!< end tangent z coordinate, code 33 */ 931 int flags; /*!< spline flag, code 70 */ 932 int degree; /*!< degree of the spline, code 71 */ 933 dint32 nknots; /*!< number of knots, code 72, default 0 */ 934 dint32 ncontrol; /*!< number of control points, code 73, default 0 */ 935 dint32 nfit; /*!< number of fit points, code 74, default 0 */ 936 double tolknot; /*!< knot tolerance, code 42, default 0.0000001 */ 937 double tolcontrol; /*!< control point tolerance, code 43, default 0.0000001 */ 938 double tolfit; /*!< fit point tolerance, code 44, default 0.0000001 */ 939 940 std::vector<double> knotslist; /*!< knots list, code 40 */ 941 std::vector<double> weightlist; /*!< weight list, code 41 */ 942 std::vector<DRW_Coord *> controllist; /*!< control points list, code 10, 20 & 30 */ 943 std::vector<DRW_Coord *> fitlist; /*!< fit points list, code 11, 21 & 31 */ 944 945 private: 946 DRW_Coord *controlpoint; /*!< current control point to add data */ 947 DRW_Coord *fitpoint; /*!< current fit point to add data */ 948 }; 949 950 //! Class to handle hatch loop 951 /*! 952 * Class to handle hatch loop 953 * @author Rallaz 954 */ 955 class DRW_HatchLoop { 956 public: DRW_HatchLoop(int t)957 DRW_HatchLoop(int t) { 958 type = t; 959 numedges = 0; 960 } 961 ~DRW_HatchLoop()962 ~DRW_HatchLoop() { 963 // for(DRW_LWPolyline *item : pollist) delete item; 964 for(DRW_Entity *item : objlist) delete item; 965 } 966 update()967 void update() { 968 numedges = objlist.size(); 969 } 970 971 public: 972 int type; /*!< boundary path type, code 92, polyline=2, default=0 */ 973 int numedges; /*!< number of edges (if not a polyline), code 93 */ 974 //TODO: store lwpolylines as entities 975 // std::vector<DRW_LWPolyline *> pollist; /*!< polyline list */ 976 std::vector<DRW_Entity *> objlist; /*!< entities list */ 977 }; 978 979 //! Class to handle hatch entity 980 /*! 981 * Class to handle hatch entity 982 * @author Rallaz 983 */ 984 //TODO: handle lwpolylines, splines and ellipses 985 class DRW_Hatch : public DRW_Point { 986 SETENTFRIENDS 987 public: DRW_Hatch()988 DRW_Hatch() { 989 eType = DRW::HATCH; 990 angle = scale = 0.0; 991 basePoint.x = basePoint.y = basePoint.z = 0.0; 992 loopsnum = hstyle = associative = 0; 993 solid = hpattern = 1; 994 deflines = doubleflag = 0; 995 loop = NULL; 996 clearEntities(); 997 } 998 ~DRW_Hatch()999 ~DRW_Hatch() { 1000 for(DRW_HatchLoop *item : looplist) delete item; 1001 } 1002 appendLoop(DRW_HatchLoop * v)1003 void appendLoop (DRW_HatchLoop *v) { 1004 looplist.push_back(v); 1005 } 1006 applyExtrusion()1007 virtual void applyExtrusion(){} 1008 1009 protected: 1010 void parseCode(int code, dxfReader *reader); 1011 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 1012 1013 public: 1014 UTF8STRING name; /*!< hatch pattern name, code 2 */ 1015 int solid; /*!< solid fill flag, code 70, solid=1, pattern=0 */ 1016 int associative; /*!< associativity, code 71, associatve=1, non-assoc.=0 */ 1017 int hstyle; /*!< hatch style, code 75 */ 1018 int hpattern; /*!< hatch pattern type, code 76 */ 1019 int doubleflag; /*!< hatch pattern double flag, code 77, double=1, single=0 */ 1020 int loopsnum; /*!< namber of boundary paths (loops), code 91 */ 1021 double angle; /*!< hatch pattern angle, code 52 */ 1022 double scale; /*!< hatch pattern scale, code 41 */ 1023 int deflines; /*!< number of pattern definition lines, code 78 */ 1024 1025 std::vector<DRW_HatchLoop *> looplist; /*!< polyline list */ 1026 1027 private: clearEntities()1028 void clearEntities(){ 1029 pt = line = NULL; 1030 pline = NULL; 1031 arc = NULL; 1032 ellipse = NULL; 1033 spline = NULL; 1034 plvert = NULL; 1035 } 1036 addLine()1037 void addLine() { 1038 clearEntities(); 1039 if (loop) { 1040 pt = line = new DRW_Line; 1041 loop->objlist.push_back(line); 1042 } 1043 } 1044 addArc()1045 void addArc() { 1046 clearEntities(); 1047 if (loop) { 1048 pt = arc = new DRW_Arc; 1049 loop->objlist.push_back(arc); 1050 } 1051 } 1052 addEllipse()1053 void addEllipse() { 1054 clearEntities(); 1055 if (loop) { 1056 pt = ellipse = new DRW_Ellipse; 1057 loop->objlist.push_back(ellipse); 1058 } 1059 } 1060 addSpline()1061 void addSpline() { 1062 clearEntities(); 1063 if (loop) { 1064 pt = NULL; 1065 spline = new DRW_Spline; 1066 loop->objlist.push_back(spline); 1067 } 1068 } 1069 1070 DRW_HatchLoop *loop; /*!< current loop to add data */ 1071 DRW_Line *line; 1072 DRW_Arc *arc; 1073 DRW_Ellipse *ellipse; 1074 DRW_Spline *spline; 1075 DRW_LWPolyline *pline; 1076 DRW_Point *pt; 1077 DRW_Vertex2D *plvert; 1078 bool ispol; 1079 }; 1080 1081 //! Class to handle image entity 1082 /*! 1083 * Class to handle image entity 1084 * @author Rallaz 1085 */ 1086 class DRW_Image : public DRW_Line { 1087 SETENTFRIENDS 1088 public: DRW_Image()1089 DRW_Image() { 1090 eType = DRW::IMAGE; 1091 fade = clip = 0; 1092 brightness = contrast = 50; 1093 } 1094 1095 protected: 1096 void parseCode(int code, dxfReader *reader); 1097 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 1098 1099 public: 1100 duint32 ref; /*!< Hard reference to imagedef object, code 340 */ 1101 DRW_Coord vVector; /*!< V-vector of single pixel, x coordinate, code 12, 22 & 32 */ 1102 // double vx; /*!< V-vector of single pixel, x coordinate, code 12 */ 1103 // double vy; /*!< V-vector of single pixel, y coordinate, code 22 */ 1104 // double vz; /*!< V-vector of single pixel, z coordinate, code 32 */ 1105 double sizeu; /*!< image size in pixels, U value, code 13 */ 1106 double sizev; /*!< image size in pixels, V value, code 23 */ 1107 double dz; /*!< z coordinate, code 33 */ 1108 int clip; /*!< Clipping state, code 280, 0=off 1=on */ 1109 int brightness; /*!< Brightness value, code 281, (0-100) default 50 */ 1110 int contrast; /*!< Brightness value, code 282, (0-100) default 50 */ 1111 int fade; /*!< Brightness value, code 283, (0-100) default 0 */ 1112 1113 }; 1114 1115 1116 //! Base class for dimension entity 1117 /*! 1118 * Base class for dimension entity 1119 * @author Rallaz 1120 */ 1121 class DRW_Dimension : public DRW_Entity { 1122 SETENTFRIENDS 1123 public: DRW_Dimension()1124 DRW_Dimension() { 1125 eType = DRW::DIMENSION; 1126 type = 0; 1127 linesty = 1; 1128 linefactor = extPoint.z = 1.0; 1129 angle = oblique = rot = 0.0; 1130 align = 5; 1131 style = "STANDARD"; 1132 defPoint.z = extPoint.x = extPoint.y = 0; 1133 textPoint.z = rot = 0; 1134 clonePoint.x = clonePoint.y = clonePoint.z = 0; 1135 length = 0.0; 1136 hasActual = false; 1137 actual = 0.0; 1138 } 1139 DRW_Dimension(const DRW_Dimension & d)1140 DRW_Dimension(const DRW_Dimension& d): DRW_Entity(d) { 1141 eType = DRW::DIMENSION; 1142 type =d.type; 1143 name = d.name; 1144 defPoint = d.defPoint; 1145 textPoint = d.textPoint; 1146 text = d.text; 1147 style = d.style; 1148 align = d.align; 1149 linesty = d.linesty; 1150 linefactor = d.linefactor; 1151 rot = d.rot; 1152 extPoint = d.extPoint; 1153 clonePoint = d.clonePoint; 1154 def1 = d.def1; 1155 def2 = d.def2; 1156 angle = d.angle; 1157 oblique = d.oblique; 1158 arcPoint = d.arcPoint; 1159 circlePoint = d.circlePoint; 1160 length = d.length; 1161 hasActual = d.hasActual; 1162 actual = d.actual; 1163 //RLZ needed a def value for this: hdir = ??? 1164 } ~DRW_Dimension()1165 virtual ~DRW_Dimension() {} 1166 applyExtrusion()1167 virtual void applyExtrusion(){} 1168 1169 protected: 1170 void parseCode(int code, dxfReader *reader); 1171 bool parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *sBuf); 1172 virtual bool parseDwg(DRW::Version version, dwgBuffer* buf, duint32 bs=0){ 1173 DRW_UNUSED(version); DRW_UNUSED(buf); DRW_UNUSED(bs); return true;} 1174 1175 public: getDefPoint()1176 DRW_Coord getDefPoint() const {return defPoint;} /*!< Definition point, code 10, 20 & 30 */ setDefPoint(const DRW_Coord p)1177 void setDefPoint(const DRW_Coord p) {defPoint =p;} getTextPoint()1178 DRW_Coord getTextPoint() const {return textPoint;} /*!< Middle point of text, code 11, 21 & 31 */ setTextPoint(const DRW_Coord p)1179 void setTextPoint(const DRW_Coord p) {textPoint =p;} getStyle()1180 std::string getStyle() const {return style;} /*!< Dimension style, code 3 */ setStyle(const std::string s)1181 void setStyle(const std::string s) {style = s;} getAlign()1182 int getAlign() const { return align;} /*!< attachment point, code 71 */ setAlign(const int a)1183 void setAlign(const int a) { align = a;} getTextLineStyle()1184 int getTextLineStyle() const { return linesty;} /*!< Dimension text line spacing style, code 72, default 1 */ setTextLineStyle(const int l)1185 void setTextLineStyle(const int l) { linesty = l;} getText()1186 std::string getText() const {return text;} /*!< Dimension text explicitly entered by the user, code 1 */ setText(const std::string t)1187 void setText(const std::string t) {text = t;} getTextLineFactor()1188 double getTextLineFactor() const { return linefactor;} /*!< Dimension text line spacing factor, code 41, default 1? */ setTextLineFactor(const double l)1189 void setTextLineFactor(const double l) { linefactor = l;} getDir()1190 double getDir() const { return rot;} /*!< rotation angle of the dimension text, code 53 (optional) default 0 */ setDir(const double d)1191 void setDir(const double d) { rot = d;} 1192 getExtrusion()1193 DRW_Coord getExtrusion(){return extPoint;} /*!< extrusion, code 210, 220 & 230 */ setExtrusion(const DRW_Coord p)1194 void setExtrusion(const DRW_Coord p) {extPoint =p;} getName()1195 std::string getName(){return name;} /*!< Name of the block that contains the entities, code 2 */ setName(const std::string s)1196 void setName(const std::string s) {name = s;} 1197 // int getType(){ return type;} /*!< Dimension type, code 70 */ hasActualMeasurement()1198 bool hasActualMeasurement() const { return hasActual; } setActualMeasurement(double value)1199 void setActualMeasurement(double value) { hasActual = true; actual = value; } getActualMeasurement()1200 double getActualMeasurement() const { return actual; } 1201 1202 protected: getPt2()1203 DRW_Coord getPt2() const {return clonePoint;} setPt2(const DRW_Coord p)1204 void setPt2(const DRW_Coord p) {clonePoint= p;} getPt3()1205 DRW_Coord getPt3() const {return def1;} setPt3(const DRW_Coord p)1206 void setPt3(const DRW_Coord p) {def1= p;} getPt4()1207 DRW_Coord getPt4() const {return def2;} setPt4(const DRW_Coord p)1208 void setPt4(const DRW_Coord p) {def2= p;} getPt5()1209 DRW_Coord getPt5() const {return circlePoint;} setPt5(const DRW_Coord p)1210 void setPt5(const DRW_Coord p) {circlePoint= p;} getPt6()1211 DRW_Coord getPt6() const {return arcPoint;} setPt6(const DRW_Coord p)1212 void setPt6(const DRW_Coord p) {arcPoint= p;} getAn50()1213 double getAn50() const {return angle;} /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */ setAn50(const double d)1214 void setAn50(const double d) {angle = d;} getOb52()1215 double getOb52() const {return oblique;} /*!< oblique angle, code 52 */ setOb52(const double d)1216 void setOb52(const double d) {oblique = d;} getRa40()1217 double getRa40() const {return length;} /*!< Leader length, code 40 */ setRa40(const double d)1218 void setRa40(const double d) {length = d;} 1219 public: 1220 int type; /*!< Dimension type, code 70 */ 1221 private: 1222 std::string name; /*!< Name of the block that contains the entities, code 2 */ 1223 DRW_Coord defPoint; /*!< definition point, code 10, 20 & 30 (WCS) */ 1224 DRW_Coord textPoint; /*!< Middle point of text, code 11, 21 & 31 (OCS) */ 1225 UTF8STRING text; /*!< Dimension text explicitly entered by the user, code 1 */ 1226 UTF8STRING style; /*!< Dimension style, code 3 */ 1227 int align; /*!< attachment point, code 71 */ 1228 int linesty; /*!< Dimension text line spacing style, code 72, default 1 */ 1229 double linefactor; /*!< Dimension text line spacing factor, code 41, default 1? (value range 0.25 to 4.00*/ 1230 double rot; /*!< rotation angle of the dimension text, code 53 */ 1231 DRW_Coord extPoint; /*!< extrusion normal vector, code 210, 220 & 230 */ 1232 1233 double hdir; /*!< horizontal direction for the dimension, code 51, default ? */ 1234 DRW_Coord clonePoint; /*!< Insertion point for clones (Baseline & Continue), code 12, 22 & 32 (OCS) */ 1235 DRW_Coord def1; /*!< Definition point 1for linear & angular, code 13, 23 & 33 (WCS) */ 1236 DRW_Coord def2; /*!< Definition point 2, code 14, 24 & 34 (WCS) */ 1237 double angle; /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */ 1238 double oblique; /*!< oblique angle, code 52 */ 1239 1240 DRW_Coord circlePoint; /*!< Definition point for diameter, radius & angular dims code 15, 25 & 35 (WCS) */ 1241 DRW_Coord arcPoint; /*!< Point defining dimension arc, x coordinate, code 16, 26 & 36 (OCS) */ 1242 double length; /*!< Leader length, code 40 */ 1243 bool hasActual; /*!< Actual measurement has been read, code 42 */ 1244 double actual; /*!< Actual measurement (optional; read-only value), code 42 */ 1245 1246 protected: 1247 dwgHandle dimStyleH; 1248 dwgHandle blockH; 1249 }; 1250 1251 1252 //! Class to handle aligned dimension entity 1253 /*! 1254 * Class to handle aligned dimension entity 1255 * @author Rallaz 1256 */ 1257 class DRW_DimAligned : public DRW_Dimension { 1258 SETENTFRIENDS 1259 public: DRW_DimAligned()1260 DRW_DimAligned(){ 1261 eType = DRW::DIMALIGNED; 1262 type = 1; 1263 } DRW_DimAligned(const DRW_Dimension & d)1264 DRW_DimAligned(const DRW_Dimension& d): DRW_Dimension(d) { 1265 eType = DRW::DIMALIGNED; 1266 } 1267 getClonepoint()1268 DRW_Coord getClonepoint() const {return getPt2();} /*!< Insertion for clones (Baseline & Continue), 12, 22 & 32 */ setClonePoint(DRW_Coord c)1269 void setClonePoint(DRW_Coord c){setPt2(c);} 1270 getDimPoint()1271 DRW_Coord getDimPoint() const {return getDefPoint();} /*!< dim line location point, code 10, 20 & 30 */ setDimPoint(const DRW_Coord p)1272 void setDimPoint(const DRW_Coord p){setDefPoint(p);} getDef1Point()1273 DRW_Coord getDef1Point() const {return getPt3();} /*!< Definition point 1, code 13, 23 & 33 */ setDef1Point(const DRW_Coord p)1274 void setDef1Point(const DRW_Coord p) {setPt3(p);} getDef2Point()1275 DRW_Coord getDef2Point() const {return getPt4();} /*!< Definition point 2, code 14, 24 & 34 */ setDef2Point(const DRW_Coord p)1276 void setDef2Point(const DRW_Coord p) {setPt4(p);} 1277 1278 protected: 1279 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 1280 }; 1281 1282 //! Class to handle linear or rotated dimension entity 1283 /*! 1284 * Class to handle linear or rotated dimension entity 1285 * @author Rallaz 1286 */ 1287 class DRW_DimLinear : public DRW_DimAligned { 1288 public: DRW_DimLinear()1289 DRW_DimLinear() { 1290 eType = DRW::DIMLINEAR; 1291 type = 0; 1292 } DRW_DimLinear(const DRW_Dimension & d)1293 DRW_DimLinear(const DRW_Dimension& d): DRW_DimAligned(d) { 1294 eType = DRW::DIMLINEAR; 1295 } 1296 getAngle()1297 double getAngle() const {return getAn50();} /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */ setAngle(const double d)1298 void setAngle(const double d) {setAn50(d);} getOblique()1299 double getOblique() const {return getOb52();} /*!< oblique angle, code 52 */ setOblique(const double d)1300 void setOblique(const double d) {setOb52(d);} 1301 }; 1302 1303 //! Class to handle radial dimension entity 1304 /*! 1305 * Class to handle aligned, linear or rotated dimension entity 1306 * @author Rallaz 1307 */ 1308 class DRW_DimRadial : public DRW_Dimension { 1309 SETENTFRIENDS 1310 public: DRW_DimRadial()1311 DRW_DimRadial() { 1312 eType = DRW::DIMRADIAL; 1313 type = 4; 1314 } DRW_DimRadial(const DRW_Dimension & d)1315 DRW_DimRadial(const DRW_Dimension& d): DRW_Dimension(d) { 1316 eType = DRW::DIMRADIAL; 1317 } 1318 getCenterPoint()1319 DRW_Coord getCenterPoint() const {return getDefPoint();} /*!< center point, code 10, 20 & 30 */ setCenterPoint(const DRW_Coord p)1320 void setCenterPoint(const DRW_Coord p){setDefPoint(p);} getDiameterPoint()1321 DRW_Coord getDiameterPoint() const {return getPt5();} /*!< Definition point for radius, code 15, 25 & 35 */ setDiameterPoint(const DRW_Coord p)1322 void setDiameterPoint(const DRW_Coord p){setPt5(p);} getLeaderLength()1323 double getLeaderLength() const {return getRa40();} /*!< Leader length, code 40 */ setLeaderLength(const double d)1324 void setLeaderLength(const double d) {setRa40(d);} 1325 1326 protected: 1327 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 1328 }; 1329 1330 //! Class to handle radial dimension entity 1331 /*! 1332 * Class to handle aligned, linear or rotated dimension entity 1333 * @author Rallaz 1334 */ 1335 class DRW_DimDiametric : public DRW_Dimension { 1336 SETENTFRIENDS 1337 public: DRW_DimDiametric()1338 DRW_DimDiametric() { 1339 eType = DRW::DIMDIAMETRIC; 1340 type = 3; 1341 } DRW_DimDiametric(const DRW_Dimension & d)1342 DRW_DimDiametric(const DRW_Dimension& d): DRW_Dimension(d) { 1343 eType = DRW::DIMDIAMETRIC; 1344 } 1345 getDiameter1Point()1346 DRW_Coord getDiameter1Point() const {return getPt5();} /*!< First definition point for diameter, code 15, 25 & 35 */ setDiameter1Point(const DRW_Coord p)1347 void setDiameter1Point(const DRW_Coord p){setPt5(p);} getDiameter2Point()1348 DRW_Coord getDiameter2Point() const {return getDefPoint();} /*!< Oposite point for diameter, code 10, 20 & 30 */ setDiameter2Point(const DRW_Coord p)1349 void setDiameter2Point(const DRW_Coord p){setDefPoint(p);} getLeaderLength()1350 double getLeaderLength() const {return getRa40();} /*!< Leader length, code 40 */ setLeaderLength(const double d)1351 void setLeaderLength(const double d) {setRa40(d);} 1352 1353 protected: 1354 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 1355 }; 1356 1357 //! Class to handle angular dimension entity 1358 /*! 1359 * Class to handle angular dimension entity 1360 * @author Rallaz 1361 */ 1362 class DRW_DimAngular : public DRW_Dimension { 1363 SETENTFRIENDS 1364 public: DRW_DimAngular()1365 DRW_DimAngular() { 1366 eType = DRW::DIMANGULAR; 1367 type = 2; 1368 } DRW_DimAngular(const DRW_Dimension & d)1369 DRW_DimAngular(const DRW_Dimension& d): DRW_Dimension(d) { 1370 eType = DRW::DIMANGULAR; 1371 } 1372 getFirstLine1()1373 DRW_Coord getFirstLine1() const {return getPt3();} /*!< Definition point line 1-1, code 13, 23 & 33 */ setFirstLine1(const DRW_Coord p)1374 void setFirstLine1(const DRW_Coord p) {setPt3(p);} getFirstLine2()1375 DRW_Coord getFirstLine2() const {return getPt4();} /*!< Definition point line 1-2, code 14, 24 & 34 */ setFirstLine2(const DRW_Coord p)1376 void setFirstLine2(const DRW_Coord p) {setPt4(p);} getSecondLine1()1377 DRW_Coord getSecondLine1() const {return getPt5();} /*!< Definition point line 2-1, code 15, 25 & 35 */ setSecondLine1(const DRW_Coord p)1378 void setSecondLine1(const DRW_Coord p) {setPt5(p);} getSecondLine2()1379 DRW_Coord getSecondLine2() const {return getDefPoint();} /*!< Definition point line 2-2, code 10, 20 & 30 */ setSecondLine2(const DRW_Coord p)1380 void setSecondLine2(const DRW_Coord p){setDefPoint(p);} getDimPoint()1381 DRW_Coord getDimPoint() const {return getPt6();} /*!< Dimension definition point, code 16, 26 & 36 */ setDimPoint(const DRW_Coord p)1382 void setDimPoint(const DRW_Coord p) {setPt6(p);} 1383 1384 protected: 1385 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 1386 }; 1387 1388 1389 //! Class to handle angular 3p dimension entity 1390 /*! 1391 * Class to handle angular 3p dimension entity 1392 * @author Rallaz 1393 */ 1394 class DRW_DimAngular3p : public DRW_Dimension { 1395 SETENTFRIENDS 1396 public: DRW_DimAngular3p()1397 DRW_DimAngular3p() { 1398 eType = DRW::DIMANGULAR3P; 1399 type = 5; 1400 } DRW_DimAngular3p(const DRW_Dimension & d)1401 DRW_DimAngular3p(const DRW_Dimension& d): DRW_Dimension(d) { 1402 eType = DRW::DIMANGULAR3P; 1403 } 1404 getFirstLine()1405 DRW_Coord getFirstLine() const {return getPt3();} /*!< Definition point line 1, code 13, 23 & 33 */ setFirstLine(const DRW_Coord p)1406 void setFirstLine(const DRW_Coord p) {setPt3(p);} getSecondLine()1407 DRW_Coord getSecondLine() const {return getPt4();} /*!< Definition point line 2, code 14, 24 & 34 */ setSecondLine(const DRW_Coord p)1408 void setSecondLine(const DRW_Coord p) {setPt4(p);} getVertexPoint()1409 DRW_Coord getVertexPoint() const {return getPt5();} /*!< Vertex point, code 15, 25 & 35 */ SetVertexPoint(const DRW_Coord p)1410 void SetVertexPoint(const DRW_Coord p) {setPt5(p);} getDimPoint()1411 DRW_Coord getDimPoint() const {return getDefPoint();} /*!< Dimension definition point, code 10, 20 & 30 */ setDimPoint(const DRW_Coord p)1412 void setDimPoint(const DRW_Coord p) {setDefPoint(p);} 1413 1414 protected: 1415 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 1416 }; 1417 1418 //! Class to handle ordinate dimension entity 1419 /*! 1420 * Class to handle ordinate dimension entity 1421 * @author Rallaz 1422 */ 1423 class DRW_DimOrdinate : public DRW_Dimension { 1424 SETENTFRIENDS 1425 public: DRW_DimOrdinate()1426 DRW_DimOrdinate() { 1427 eType = DRW::DIMORDINATE; 1428 type = 6; 1429 } DRW_DimOrdinate(const DRW_Dimension & d)1430 DRW_DimOrdinate(const DRW_Dimension& d): DRW_Dimension(d) { 1431 eType = DRW::DIMORDINATE; 1432 } 1433 getOriginPoint()1434 DRW_Coord getOriginPoint() const {return getDefPoint();} /*!< Origin definition point, code 10, 20 & 30 */ setOriginPoint(const DRW_Coord p)1435 void setOriginPoint(const DRW_Coord p) {setDefPoint(p);} getFirstLine()1436 DRW_Coord getFirstLine() const {return getPt3();} /*!< Feature location point, code 13, 23 & 33 */ setFirstLine(const DRW_Coord p)1437 void setFirstLine(const DRW_Coord p) {setPt3(p);} getSecondLine()1438 DRW_Coord getSecondLine() const {return getPt4();} /*!< Leader end point, code 14, 24 & 34 */ setSecondLine(const DRW_Coord p)1439 void setSecondLine(const DRW_Coord p) {setPt4(p);} 1440 1441 protected: 1442 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 1443 }; 1444 1445 1446 //! Class to handle leader entity 1447 /*! 1448 * Class to handle leader entity 1449 * @author Rallaz 1450 */ 1451 class DRW_Leader : public DRW_Entity { 1452 SETENTFRIENDS 1453 public: DRW_Leader()1454 DRW_Leader() { 1455 eType = DRW::LEADER; 1456 flag = 3; 1457 hookflag = vertnum = leadertype = 0; 1458 extrusionPoint.x = extrusionPoint.y = 0.0; 1459 arrow = 1; 1460 extrusionPoint.z = 1.0; 1461 } ~DRW_Leader()1462 ~DRW_Leader() { 1463 for(DRW_Coord *item : vertexlist) delete item; 1464 } 1465 applyExtrusion()1466 virtual void applyExtrusion(){} 1467 1468 protected: 1469 void parseCode(int code, dxfReader *reader); 1470 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 1471 1472 public: 1473 UTF8STRING style; /*!< Dimension style name, code 3 */ 1474 int arrow; /*!< Arrowhead flag, code 71, 0=Disabled; 1=Enabled */ 1475 int leadertype; /*!< Leader path type, code 72, 0=Straight line segments; 1=Spline */ 1476 int flag; /*!< Leader creation flag, code 73, default 3 */ 1477 int hookline; /*!< Hook line direction flag, code 74, default 1 */ 1478 int hookflag; /*!< Hook line flag, code 75 */ 1479 double textheight; /*!< Text annotation height, code 40 */ 1480 double textwidth; /*!< Text annotation width, code 41 */ 1481 int vertnum; /*!< Number of vertices, code 76 */ 1482 int coloruse; /*!< Color to use if leader's DIMCLRD = BYBLOCK, code 77 */ 1483 duint32 annotHandle; /*!< Hard reference to associated annotation, code 340 */ 1484 DRW_Coord extrusionPoint; /*!< Normal vector, code 210, 220 & 230 */ 1485 DRW_Coord horizdir; /*!< "Horizontal" direction for leader, code 211, 221 & 231 */ 1486 DRW_Coord offsetblock; /*!< Offset of last leader vertex from block, code 212, 222 & 232 */ 1487 DRW_Coord offsettext; /*!< Offset of last leader vertex from annotation, code 213, 223 & 233 */ 1488 1489 std::vector<DRW_Coord *> vertexlist; /*!< vertex points list, code 10, 20 & 30 */ 1490 1491 private: 1492 DRW_Coord *vertexpoint; /*!< current control point to add data */ 1493 dwgHandle dimStyleH; 1494 dwgHandle AnnotH; 1495 }; 1496 1497 //! Class to handle viewport entity 1498 /*! 1499 * Class to handle viewport entity 1500 * @author Rallaz 1501 */ 1502 class DRW_Viewport : public DRW_Point { 1503 SETENTFRIENDS 1504 public: DRW_Viewport()1505 DRW_Viewport() { 1506 eType = DRW::VIEWPORT; 1507 vpstatus = 0; 1508 pswidth = 205; 1509 psheight = 156; 1510 centerPX = 128.5; 1511 centerPY = 97.5; 1512 } 1513 applyExtrusion()1514 virtual void applyExtrusion(){} 1515 1516 protected: 1517 void parseCode(int code, dxfReader *reader); 1518 virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); 1519 1520 public: 1521 double pswidth; /*!< Width in paper space units, code 40 */ 1522 double psheight; /*!< Height in paper space units, code 41 */ 1523 int vpstatus; /*!< Viewport status, code 68 */ 1524 int vpID; /*!< Viewport ID, code 69 */ 1525 double centerPX; /*!< view center point X, code 12 */ 1526 double centerPY; /*!< view center point Y, code 22 */ 1527 double snapPX; /*!< Snap base point X, code 13 */ 1528 double snapPY; /*!< Snap base point Y, code 23 */ 1529 double snapSpPX; /*!< Snap spacing X, code 14 */ 1530 double snapSpPY; /*!< Snap spacing Y, code 24 */ 1531 //TODO: complete in dxf 1532 DRW_Coord viewDir; /*!< View direction vector, code 16, 26 & 36 */ 1533 DRW_Coord viewTarget; /*!< View target point, code 17, 27, 37 */ 1534 double viewLength; /*!< Perspective lens length, code 42 */ 1535 double frontClip; /*!< Front clip plane Z value, code 43 */ 1536 double backClip; /*!< Back clip plane Z value, code 44 */ 1537 double viewHeight; /*!< View height in model space units, code 45 */ 1538 double snapAngle; /*!< Snap angle, code 50 */ 1539 double twistAngle; /*!< view twist angle, code 51 */ 1540 1541 private: 1542 duint32 frozenLyCount; 1543 };//RLZ: missing 15,25, 72, 331, 90, 340, 1, 281, 71, 74, 110, 120, 130, 111, 121,131, 112,122, 132, 345,346, and more... 1544 1545 //used //DRW_Coord basePoint; /*!< base point, code 10, 20 & 30 */ 1546 1547 //double thickness; /*!< thickness, code 39 */ 1548 //DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */ 1549 //enum DRW::ETYPE eType; /*!< enum: entity type, code 0 */ 1550 //duint32 handle; /*!< entity identifier, code 5 */ 1551 //std::list<std::list<DRW_Variant> > appData; /*!< list of application data, code 102 */ 1552 //duint32 parentHandle; /*!< Soft-pointer ID/handle to owner BLOCK_RECORD object, code 330 */ 1553 //DRW::Space space; /*!< space indicator, code 67*/ 1554 //UTF8STRING layer; /*!< layer name, code 8 */ 1555 //UTF8STRING lineType; /*!< line type, code 6 */ 1556 //duint32 material; /*!< hard pointer id to material object, code 347 */ 1557 //int color; /*!< entity color, code 62 */ 1558 //enum DRW_LW_Conv::lineWidth lWeight; /*!< entity lineweight, code 370 */ 1559 //double ltypeScale; /*!< linetype scale, code 48 */ 1560 //bool visible; /*!< entity visibility, code 60 */ 1561 //int numProxyGraph; /*!< Number of bytes in proxy graphics, code 92 */ 1562 //std::string proxyGraphics; /*!< proxy graphics bytes, code 310 */ 1563 //int color24; /*!< 24-bit color, code 420 */ 1564 //std::string colorName; /*!< color name, code 430 */ 1565 //int transparency; /*!< transparency, code 440 */ 1566 //int plotStyle; /*!< hard pointer id to plot style object, code 390 */ 1567 //DRW::ShadowMode shadow; /*!< shadow mode, code 284 */ 1568 //bool haveExtrusion; /*!< set to true if the entity have extrusion*/ 1569 1570 #endif 1571 1572 // EOF 1573