diff --git a/bazaar/DXF/DXF.cpp b/bazaar/DXF/DXF.cpp index 5b094d196..fa48cef5e 100644 --- a/bazaar/DXF/DXF.cpp +++ b/bazaar/DXF/DXF.cpp @@ -46,20 +46,26 @@ double DXF::NormalizeAngle(double a) } // Add a block definition -DXFBlock *DXF::AddBlock(String const &name) +DXFBlock &DXF::AddBlock(String const &name) { int idx = blocks.blocks.Find(name); if(idx >= 0) - return &blocks.blocks[idx]; + return blocks.blocks[idx]; blocks.blocks.Add(name, new DXFBlock(this)); - return &blocks.blocks.Top(); + return blocks.blocks.Top(); } +// checks if a block is present +bool DXF::HasBlock(String const &name) const +{ + return blocks.blocks.Find(name) >= 0; +} + // gets a block by name -DXFBlock *DXF::GetBlock(String const &name) +DXFBlock &DXF::GetBlock(String const &name) { int idx = blocks.blocks.Find(name); if(idx >= 0) - return &blocks.blocks[idx]; - return NULL; + return blocks.blocks[idx]; + return *(DXFBlock *)NULL; } diff --git a/bazaar/DXF/DXF.h b/bazaar/DXF/DXF.h index 8d294bee2..69a74ce68 100644 --- a/bazaar/DXF/DXF.h +++ b/bazaar/DXF/DXF.h @@ -70,10 +70,13 @@ class DXF : public DXFBlock static double NormalizeAngle(double a); // Add a block definition - DXFBlock *AddBlock(String const &name); + DXFBlock &AddBlock(String const &name); + + // checks if a block is present + bool HasBlock(String const &name) const; // gets a block by name - DXFBlock *GetBlock(String const &name); + DXFBlock &GetBlock(String const &name); // sets insertion scale option DXF &SetScaleInsertions(bool i = true) { scaleInsertions = i; return *this; } diff --git a/bazaar/DXF/Tables.cpp b/bazaar/DXF/Tables.cpp index ca897b68d..abeebb1d9 100644 --- a/bazaar/DXF/Tables.cpp +++ b/bazaar/DXF/Tables.cpp @@ -197,7 +197,7 @@ uint64 DXFTables::GetNextHandle(void) // adds a layer -DXFLayer *DXFTables::AddLayer(String const &name, int color, String const &lType) +DXFLayer &DXFTables::AddLayer(String const &name, int color, String const &lType) { for(int i = 0; i < layers.GetCount(); i++) { @@ -206,18 +206,18 @@ DXFLayer *DXFTables::AddLayer(String const &name, int color, String const &lType { lay.color = color; lay.lineType = lType; - return &lay; + return lay; } } DXFLayer &lay = layers.Add(new DXFLayer(this)); lay.name = name; lay.color = color; lay.lineType = lType; - return &lay; + return lay; } // adds a linetype -DXFLineType *DXFTables::AddLineType(String const &name, Vector const &elements) +DXFLineType &DXFTables::AddLineType(String const &name, Vector const &elements) { for(int i = 0; i < lineTypes.GetCount(); i++) { @@ -225,16 +225,16 @@ DXFLineType *DXFTables::AddLineType(String const &name, Vector const &el if(ToUpper(lt.name == name)) { lt.elements <<= elements; - return < + return lt; } } DXFLineType < = lineTypes.Add(new DXFLineType(this)); lt.name = name; lt.elements <<= elements; - return < + return lt; } -DXFLineType *DXFTables::AddLineType(String const &name, double e1, double e2, double e3, double e4, double e5, double e6, double e7, double e8) +DXFLineType &DXFTables::AddLineType(String const &name, double e1, double e2, double e3, double e4, double e5, double e6, double e7, double e8) { Vector elements; elements << e1 << e2; diff --git a/bazaar/DXF/Tables.h b/bazaar/DXF/Tables.h index 7a5ce5787..d23537772 100644 --- a/bazaar/DXF/Tables.h +++ b/bazaar/DXF/Tables.h @@ -124,10 +124,10 @@ class DXFTables : public Pte uint64 GetNextHandle(void); // adds a layer - DXFLayer *AddLayer(String const &name, int color = 7, String const &lType = "CONTINUOUS"); + DXFLayer &AddLayer(String const &name, int color = 7, String const &lType = "CONTINUOUS"); // adds a linetype - DXFLineType *AddLineType(String const &name, Vector const &elements = Vector()); - DXFLineType *AddLineType(String const &name, double e1, double e2, double e3 = Null, double e4 = Null, double e5 = Null, double e6 = Null, double e7 = Null, double e8 = Null); + DXFLineType &AddLineType(String const &name, Vector const &elements = Vector()); + DXFLineType &AddLineType(String const &name, double e1, double e2, double e3 = Null, double e4 = Null, double e5 = Null, double e6 = Null, double e7 = Null, double e8 = Null); }; #endif