mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Bazaar/DXF : return references instead of pointers (last remaining cases)
git-svn-id: svn://ultimatepp.org/upp/trunk@5272 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
e2afdf8c11
commit
0980fd834a
4 changed files with 27 additions and 18 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -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<double> const &elements)
|
||||
DXFLineType &DXFTables::AddLineType(String const &name, Vector<double> const &elements)
|
||||
{
|
||||
for(int i = 0; i < lineTypes.GetCount(); i++)
|
||||
{
|
||||
|
|
@ -225,16 +225,16 @@ DXFLineType *DXFTables::AddLineType(String const &name, Vector<double> 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<double> elements;
|
||||
elements << e1 << e2;
|
||||
|
|
|
|||
|
|
@ -124,10 +124,10 @@ class DXFTables : public Pte<DXFTables>
|
|||
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<double> const &elements = Vector<double>());
|
||||
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<double> const &elements = Vector<double>());
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue