1 /****************************************************************************
2 ** $Id: dl_creationinterface.h 2397 2005-06-06 18:11:14Z andrew $
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
6 ** This file is part of the dxflib project.
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
13 ** Licensees holding valid dxflib Professional Edition licenses may use
14 ** this file in accordance with the dxflib Commercial License
15 ** Agreement provided with the Software.
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 ** See http://www.ribbonsoft.com for further details.
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
25 **********************************************************************/
27 #ifndef DL_CREATIONINTERFACE_H
28 #define DL_CREATIONINTERFACE_H
32 #include "dl_attributes.h"
34 #include "dl_entities.h"
35 #include "dl_extrusion.h"
38 * Abstract class (interface) for the creation of new entities.
39 * Inherit your class which takes care of the entities in the
40 * processed DXF file from this interface.
42 * Double arrays passed to your implementation contain 3 double
43 * values for x, y, z coordinates unless stated differently.
45 * @author Andrew Mustun
47 class DL_CreationInterface {
49 DL_CreationInterface() {
50 extrusion = new DL_Extrusion;
52 virtual ~DL_CreationInterface() {
57 * Called for every layer.
59 virtual void addLayer(const DL_LayerData& data) = 0;
62 * Called for every block. Note: all entities added after this
63 * command go into this block until endBlock() is called.
67 virtual void addBlock(const DL_BlockData& data) = 0;
69 /** Called to end the current block */
70 virtual void endBlock() = 0;
72 /** Called for every point */
73 virtual void addPoint(const DL_PointData& data) = 0;
75 /** Called for every line */
76 virtual void addLine(const DL_LineData& data) = 0;
78 /** Called for every arc */
79 virtual void addArc(const DL_ArcData& data) = 0;
81 /** Called for every circle */
82 virtual void addCircle(const DL_CircleData& data) = 0;
84 /** Called for every ellipse */
85 virtual void addEllipse(const DL_EllipseData& data) = 0;
87 /** Called for every polyline start */
88 virtual void addPolyline(const DL_PolylineData& data) = 0;
90 /** Called for every polyline vertex */
91 virtual void addVertex(const DL_VertexData& data) = 0;
93 /** Called for every spline */
94 virtual void addSpline(const DL_SplineData& data) = 0;
96 /** Called for every spline control point */
97 virtual void addControlPoint(const DL_ControlPointData& data) = 0;
99 /** Called for every spline knot value */
100 virtual void addKnot(const DL_KnotData& data) = 0;
102 /** Called for every insert. */
103 virtual void addInsert(const DL_InsertData& data) = 0;
105 /** Called for every trace start */
106 virtual void addTrace(const DL_TraceData& data) = 0;
108 /** Called for every solid start */
109 virtual void addSolid(const DL_SolidData& data) = 0;
112 /** Called for every Multi Text entity. */
113 virtual void addMText(const DL_MTextData& data) = 0;
116 * Called for additional text chunks for MTEXT entities.
117 * The chunks come at 250 character in size each. Note that
118 * those chunks come <b>before</b> the actual MTEXT entity.
120 virtual void addMTextChunk(const char* text) = 0;
122 /** Called for every Text entity. */
123 virtual void addText(const DL_TextData& data) = 0;
126 * Called for every aligned dimension entity.
128 virtual void addDimAlign(const DL_DimensionData& data,
129 const DL_DimAlignedData& edata) = 0;
131 * Called for every linear or rotated dimension entity.
133 virtual void addDimLinear(const DL_DimensionData& data,
134 const DL_DimLinearData& edata) = 0;
137 * Called for every radial dimension entity.
139 virtual void addDimRadial(const DL_DimensionData& data,
140 const DL_DimRadialData& edata) = 0;
143 * Called for every diametric dimension entity.
145 virtual void addDimDiametric(const DL_DimensionData& data,
146 const DL_DimDiametricData& edata) = 0;
149 * Called for every angular dimension (2 lines version) entity.
151 virtual void addDimAngular(const DL_DimensionData& data,
152 const DL_DimAngularData& edata) = 0;
155 * Called for every angular dimension (3 points version) entity.
157 virtual void addDimAngular3P(const DL_DimensionData& data,
158 const DL_DimAngular3PData& edata) = 0;
161 * Called for every leader start.
163 virtual void addLeader(const DL_LeaderData& data) = 0;
166 * Called for every leader vertex
168 virtual void addLeaderVertex(const DL_LeaderVertexData& data) = 0;
171 * Called for every hatch entity.
173 virtual void addHatch(const DL_HatchData& data) = 0;
176 * Called for every image entity.
178 virtual void addImage(const DL_ImageData& data) = 0;
181 * Called for every image definition.
183 virtual void linkImage(const DL_ImageDefData& data) = 0;
186 * Called for every hatch loop.
188 virtual void addHatchLoop(const DL_HatchLoopData& data) = 0;
191 * Called for every hatch edge entity.
193 virtual void addHatchEdge(const DL_HatchEdgeData& data) = 0;
196 * Called after an entity has been completed.
198 virtual void endEntity() = 0;
201 * Called for every vector variable in the DXF file (e.g. "$EXTMIN").
203 virtual void setVariableVector(const char* key,
204 double v1, double v2, double v3, int code) = 0;
207 * Called for every string variable in the DXF file (e.g. "$ACADVER").
209 virtual void setVariableString(const char* key, const char* value, int code) = 0;
212 * Called for every int variable in the DXF file (e.g. "$ACADMAINTVER").
214 virtual void setVariableInt(const char* key, int value, int code) = 0;
217 * Called for every double variable in the DXF file (e.g. "$DIMEXO").
219 virtual void setVariableDouble(const char* key, double value, int code) = 0;
222 * Called when a SEQEND occurs (when a POLYLINE or ATTRIB is done)
224 virtual void endSequence() = 0;
226 /** Sets the current attributes for entities. */
227 void setAttributes(const DL_Attributes& attrib) {
231 /** @return the current attributes used for new entities. */
232 DL_Attributes getAttributes() {
236 /** Sets the current attributes for entities. */
237 void setExtrusion(double dx, double dy, double dz, double elevation) {
238 extrusion->setDirection(dx, dy, dz);
239 extrusion->setElevation(elevation);
242 /** @return the current attributes used for new entities. */
243 DL_Extrusion* getExtrusion() {
248 DL_Attributes attributes;
249 DL_Extrusion *extrusion;