Debian Codegraph @

libs/qCC_io/extern/dxflib/examples/readwrite/test_creationclass.cpp

raw
1 /*
2 * @file test_creationclass.cpp
3 */
4
5 /*****************************************************************************
6 ** $Id: test_creationclass.cpp 8865 2008-02-04 18:54:02Z andrew $
7 **
8 ** This is part of the dxflib library
9 ** Copyright (C) 2001 Andrew Mustun
10 **
11 ** This program is free software; you can redistribute it and/or modify
12 ** it under the terms of the GNU Library General Public License as
13 ** published by the Free Software Foundation.
14 **
15 ** This program is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ** GNU Library General Public License for more details.
19 **
20 ** You should have received a copy of the GNU Library General Public License
21 ** along with this program; if not, write to the Free Software
22 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 ******************************************************************************/
24
25 #include "test_creationclass.h"
26
27 #include <iostream>
28 #include <stdio.h>
29
30
31 /**
32 * Default constructor.
33 */
34 Test_CreationClass::Test_CreationClass() {}
35
36
37 /**
38 * Sample implementation of the method which handles layers.
39 */
40 void Test_CreationClass::addLayer(const DL_LayerData& data) {
41 printf("LAYER: %s flags: %d\n", data.name.c_str(), data.flags);
42 printAttributes();
43 }
44
45 /**
46 * Sample implementation of the method which handles point entities.
47 */
48 void Test_CreationClass::addPoint(const DL_PointData& data) {
49 printf("POINT (%6.3f, %6.3f, %6.3f)\n",
50 data.x, data.y, data.z);
51 printAttributes();
52 }
53
54 /**
55 * Sample implementation of the method which handles line entities.
56 */
57 void Test_CreationClass::addLine(const DL_LineData& data) {
58 printf("LINE (%6.3f, %6.3f, %6.3f) (%6.3f, %6.3f, %6.3f)\n",
59 data.x1, data.y1, data.z1, data.x2, data.y2, data.z2);
60 printAttributes();
61 }
62
63 /**
64 * Sample implementation of the method which handles arc entities.
65 */
66 void Test_CreationClass::addArc(const DL_ArcData& data) {
67 printf("ARC (%6.3f, %6.3f, %6.3f) %6.3f, %6.3f, %6.3f\n",
68 data.cx, data.cy, data.cz,
69 data.radius, data.angle1, data.angle2);
70 printAttributes();
71 }
72
73 /**
74 * Sample implementation of the method which handles circle entities.
75 */
76 void Test_CreationClass::addCircle(const DL_CircleData& data) {
77 printf("CIRCLE (%6.3f, %6.3f, %6.3f) %6.3f\n",
78 data.cx, data.cy, data.cz,
79 data.radius);
80 printAttributes();
81 }
82
83
84 /**
85 * Sample implementation of the method which handles polyline entities.
86 */
87 void Test_CreationClass::addPolyline(const DL_PolylineData& data) {
88 printf("POLYLINE \n");
89 printf("flags: %d\n", (int)data.flags);
90 printAttributes();
91 }
92
93
94 /**
95 * Sample implementation of the method which handles vertices.
96 */
97 void Test_CreationClass::addVertex(const DL_VertexData& data) {
98 printf("VERTEX (%6.3f, %6.3f, %6.3f) %6.3f\n",
99 data.x, data.y, data.z,
100 data.bulge);
101 printAttributes();
102 }
103
104
105 void Test_CreationClass::add3dFace(const DL_3dFaceData& data) {
106 printf("3DFACE\n");
107 for (int i=0; i<4; i++) {
108 printf(" corner %d: %6.3f %6.3f %6.3f\n",
109 i, data.x[i], data.y[i], data.z[i]);
110 }
111 printAttributes();
112 }
113
114
115 void Test_CreationClass::printAttributes() {
116 printf(" Attributes: Layer: %s, ", attributes.getLayer().c_str());
117 printf(" Color: ");
118 if (attributes.getColor()==256) {
119 printf("BYLAYER");
120 } else if (attributes.getColor()==0) {
121 printf("BYBLOCK");
122 } else {
123 printf("%d", attributes.getColor());
124 }
125 printf(" Width: ");
126 if (attributes.getWidth()==-1) {
127 printf("BYLAYER");
128 } else if (attributes.getWidth()==-2) {
129 printf("BYBLOCK");
130 } else if (attributes.getWidth()==-3) {
131 printf("DEFAULT");
132 } else {
133 printf("%d", attributes.getWidth());
134 }
135 printf(" Type: %s\n", attributes.getLinetype().c_str());
136 }
137
138
139
140 // EOF