bool KICADMODULE::parseText( SEXPR::SEXPR* data ) { // we're only interested in the Reference Designator if( data->GetNumberOfChildren() < 3 ) return true; SEXPR::SEXPR* child = data->GetChild( 1 ); std::string text; if( child->IsSymbol() ) text = child->GetSymbol(); else if( child->IsString() ) text = child->GetString(); if( text != "reference" ) return true; child = data->GetChild( 2 ); if( child->IsSymbol() ) text = child->GetSymbol(); else if( child->IsString() ) text = child->GetString(); m_refdes = text; return true; }
bool KICADMODEL::Read( SEXPR::SEXPR* aEntry ) { // form: ( pad N thru_hole shape (at x y {r}) (size x y) (drill {oval} x {y}) (layers X X X) ) int nchild = aEntry->GetNumberOfChildren(); if( nchild < 2 ) { std::ostringstream ostr; ostr << "* invalid model entry"; wxLogMessage( "%s\n", ostr.str().c_str() ); return false; } SEXPR::SEXPR* child = aEntry->GetChild( 1 ); if( child->IsSymbol() ) m_modelname = child->GetSymbol(); else if( child->IsString() ) m_modelname = child->GetString(); else { std::ostringstream ostr; ostr << "* invalid model entry; invalid path"; wxLogMessage( "%s\n", ostr.str().c_str() ); return false; } for( int i = 2; i < nchild; ++i ) { child = aEntry->GetChild( i ); if( !child->IsList() ) continue; std::string name = child->GetChild( 0 )->GetSymbol(); bool ret = true; if( name == "at" ) ret = Get3DCoordinate( child->GetChild( 1 ), m_offset ); else if( name == "scale" ) ret = Get3DCoordinate( child->GetChild( 1 ), m_scale ); else if( name == "rotate" ) ret = GetXYZRotation( child->GetChild( 1 ), m_rotation ); if( !ret ) return false; } return true; }
bool KICADMODULE::parseLayer( SEXPR::SEXPR* data ) { SEXPR::SEXPR* val = data->GetChild( 1 ); std::string layer; if( val->IsSymbol() ) layer = val->GetSymbol(); else if( val->IsString() ) layer = val->GetString(); else { std::ostringstream ostr; ostr << "* corrupt module in PCB file; layer cannot be parsed\n"; wxLogMessage( "%s\n", ostr.str().c_str() ); return false; } if( layer == "F.Cu" ) m_side = LAYER_TOP; else if( layer == "B.Cu" ) m_side = LAYER_BOTTOM; return true; }