Skip to content

Commit cbd1cf7

Browse files
committed
Override pen thickness #46
1 parent 7437cb0 commit cbd1cf7

File tree

13 files changed

+246
-145
lines changed

13 files changed

+246
-145
lines changed

dxf/circle.dxf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CIRCLE
77
20
88
100
99
39
10-
5
10+
1
1111
40
1212
50
1313
0

src/Arc.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ namespace dxfv
2121
CArc::~CArc()
2222
{
2323
}
24+
void CArc::Options(CDxf *dxf)
25+
{
26+
myPenThickOverride = dxf->penThickOverride();
27+
if (myPenThickOverride)
28+
myThick = myPenThickOverride;
29+
}
2430
void CArc::Update(cBoundingRectangle &rect)
2531
{
2632
int start_quadrant = (int)sa % 360 / 90 + 1; // the quadrant of sa
@@ -83,6 +89,9 @@ namespace dxfv
8389
draw.sa = sa;
8490
draw.ea = ea;
8591
draw.color = myColor;
92+
draw.thick = 1;
93+
if( myPenThickOverride )
94+
draw.thick = myPenThickOverride;
8695
return true;
8796
}
8897

src/Arc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class CArc : public cDXFGraphObject
2020
CArc( cCodeValue& cv );
2121
virtual ~CArc();
2222

23+
void Options(CDxf *dxf);
2324

2425
/** Update a bounding rectangle to include this
2526

src/Circle.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ namespace dxfv
1919
{
2020
}
2121

22+
void CCircle::Options(CDxf *dxf)
23+
{
24+
myPenThickOverride = dxf->penThickOverride();
25+
if (myPenThickOverride)
26+
myThick = myPenThickOverride;
27+
}
28+
2229
void CCircle::Update(cBoundingRectangle &rect)
2330
{
2431
rect.Update(x, y + r);
@@ -47,7 +54,8 @@ namespace dxfv
4754
y = atof(cvit->myValue.c_str());
4855
break;
4956
case 39:
50-
myThick = atoi(cvit->myValue.c_str());
57+
if( ! myPenThickOverride )
58+
myThick = atoi(cvit->myValue.c_str());
5159
break;
5260
case 40:
5361
r = atof(cvit->myValue.c_str());

src/Circle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class CCircle : public cDXFGraphObject
1414
CCircle();
1515
CCircle( cCodeValue& cv );
1616
virtual ~CCircle();
17+
void Options(CDxf *dxf);
1718
bool Append( std::vector<cCodeValue>::iterator& cvit );
1819
bool Read( FILE * fp, int& code, char* value );
1920

@@ -33,6 +34,7 @@ class CCircle : public cDXFGraphObject
3334
void Draw( CDxf * dxf );
3435

3536
void Adjust( double x, double y );
37+
3638
};
3739
}
3840

src/Dxf.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ namespace dxfv
128128
,
129129
myfSplineControlPointsPreferred(false) // if true and choice available, splines prefer control points
130130
,
131-
myFileVersion("n/a")
131+
myFileVersion("n/a"),
132+
myPenThickOverride( 0 )
132133
{
133134
CSolid::parser(CSolid::eParser::solid_2point);
134135
}

src/Dxf.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ namespace dxfv
211211

212212
/// default contructor
213213
cDXFGraphObject()
214-
: myColor(0x808080), myThick( 1 ), myLayer("0")
214+
: myColor(0x808080), myThick(1), myLayer("0"),
215+
myPenThickOverride(0)
215216
{
216217
}
217218

@@ -267,7 +268,7 @@ namespace dxfv
267268

268269
protected:
269270
std::string myCode;
270-
271+
int myPenThickOverride;
271272

272273
/* @brief Convert autocad color code to RGB values
273274
/// @param ai color code // http://gohtx.com/acadcolors.php
@@ -321,7 +322,6 @@ namespace dxfv
321322
class CDxf
322323
{
323324
public:
324-
325325
cBoundingRectangle myBoundingRectangle;
326326

327327
CDxf();
@@ -348,8 +348,16 @@ namespace dxfv
348348
return myFileVersion;
349349
}
350350

351-
private:
351+
void penThickOverride(int thick)
352+
{
353+
myPenThickOverride = thick;
354+
}
355+
int penThickOverride() const
356+
{
357+
return myPenThickOverride;
358+
}
352359

360+
private:
353361
bool myfwxwidgets; ///< true if using wxwidgets method for control point splines
354362
bool myfSplineControlPointsPreferred; ///< true if, given choice, splines use control rather than fit points
355363
std::vector<cCodeValue> myCodeValue;
@@ -358,6 +366,7 @@ namespace dxfv
358366
std::vector<cDXFGraphObject *> myGraphObject;
359367

360368
std::string myFileVersion;
369+
int myPenThickOverride; ///< 0: do not override
361370

362371
void UpdateBoundingRectangle();
363372
};

src/Line.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ namespace dxfv
1919
{
2020
}
2121

22+
void CLine::Options(CDxf *dxf)
23+
{
24+
myPenThickOverride = dxf->penThickOverride();
25+
if( myPenThickOverride )
26+
myThick = myPenThickOverride;
27+
}
28+
2229
bool CLine::Append(cvit_t &cvit)
2330
{
2431
while (true)
@@ -46,7 +53,8 @@ namespace dxfv
4653
y2 = atof(cvit->myValue.c_str());
4754
break;
4855
case 39:
49-
myThick = atoi(cvit->myValue.c_str());
56+
if( ! myPenThickOverride )
57+
myThick = atoi(cvit->myValue.c_str());
5058
break;
5159
case 62:
5260
AutocadColor2RGB(atoi(cvit->myValue.c_str()));

src/Line.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ class CLine : public cDXFGraphObject
1515
public:
1616
double x1,y1,x2,y2;
1717

18+
1819
CLine( cCodeValue& cv );
1920
virtual ~CLine();
2021

22+
void Options(CDxf *dxf);
2123

2224
void Update( cBoundingRectangle& rect )
2325
{

0 commit comments

Comments
 (0)