| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | #include "dxfSection.h" |
|---|
| 14 | #include "dxfEntity.h" |
|---|
| 15 | #include "dxfBlock.h" |
|---|
| 16 | |
|---|
| 17 | void dxfHeader::assign(dxfFile*, codeValue& cv) |
|---|
| 18 | { |
|---|
| 19 | if (cv._groupCode == 9) { |
|---|
| 20 | _inVariable = true; |
|---|
| 21 | VariableList var; |
|---|
| 22 | _variables[cv._string] = var; |
|---|
| 23 | _currentVariable = cv._string; |
|---|
| 24 | } else if (_inVariable) { |
|---|
| 25 | VariableList& var = getVariable(_currentVariable); |
|---|
| 26 | var.push_back(cv); |
|---|
| 27 | } |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | void dxfTables::assign(dxfFile* dxf, codeValue& cv) |
|---|
| 31 | { |
|---|
| 32 | if (cv._groupCode == 0 && cv._string == "TABLE") { |
|---|
| 33 | _currentTable = NULL; |
|---|
| 34 | } else if (cv._groupCode == 2 && !_currentTable.get()) { |
|---|
| 35 | |
|---|
| 36 | if (cv._string == "LAYER") { |
|---|
| 37 | _layerTable = new dxfLayerTable; |
|---|
| 38 | _currentTable = _layerTable.get(); |
|---|
| 39 | } else { |
|---|
| 40 | _currentTable = new dxfTable; |
|---|
| 41 | _others.push_back(_currentTable.get()); |
|---|
| 42 | } |
|---|
| 43 | } else if (_currentTable.get()) { |
|---|
| 44 | _currentTable->assign(dxf, cv); |
|---|
| 45 | } |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | void dxfBlocks::assign(dxfFile* dxf, codeValue& cv) |
|---|
| 49 | { |
|---|
| 50 | if (cv._groupCode == 0 && cv._string == std::string("BLOCK")) { |
|---|
| 51 | _currentBlock = new dxfBlock; |
|---|
| 52 | _blockList.push_back(_currentBlock); |
|---|
| 53 | } else if (cv._groupCode == 0 && cv._string == std::string("ENDBLK") && _currentBlock) { |
|---|
| 54 | std::string bn = _currentBlock->getName(); |
|---|
| 55 | _blockNameList[bn] = _currentBlock; |
|---|
| 56 | } else if (_currentBlock) { |
|---|
| 57 | _currentBlock->assign(dxf, cv); |
|---|
| 58 | } |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | void dxfEntities::assign(dxfFile* dxf, codeValue& cv) |
|---|
| 62 | { |
|---|
| 63 | if (cv._groupCode == 0) { |
|---|
| 64 | if (_currentEntity && _currentEntity->done()) { |
|---|
| 65 | _currentEntity = new dxfEntity(cv._string); |
|---|
| 66 | _entityList.push_back(_currentEntity); |
|---|
| 67 | } else if (_currentEntity) { |
|---|
| 68 | _currentEntity->assign(dxf, cv); |
|---|
| 69 | } else { |
|---|
| 70 | _currentEntity = new dxfEntity(cv._string); |
|---|
| 71 | _entityList.push_back(_currentEntity); |
|---|
| 72 | } |
|---|
| 73 | } else if (_currentEntity) { |
|---|
| 74 | _currentEntity->assign(dxf, cv); |
|---|
| 75 | } |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | void |
|---|
| 79 | dxfEntities::drawScene(scene* sc) |
|---|
| 80 | { |
|---|
| 81 | for (EntityList::iterator itr = _entityList.begin(); |
|---|
| 82 | itr != _entityList.end(); ++itr) |
|---|
| 83 | (*itr)->drawScene(sc); |
|---|
| 84 | } |
|---|
| 85 | dxfBlock* |
|---|
| 86 | dxfBlocks::findBlock(std::string s) { return _blockNameList[s]; } |
|---|