bool PCB_POLYGON::Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit, const wxString& aActualConversion ) { XNODE* lNode; wxString propValue; lNode = FindNode( aNode, wxT( "netNameRef" ) ); if( lNode ) { lNode->GetAttribute( wxT( "Name" ), &propValue ); propValue.Trim( false ); propValue.Trim( true ); m_net = propValue; m_netCode = GetNetCode( m_net ); } // retrieve polygon outline FormPolygon( aNode, &m_outline, aDefaultMeasurementUnit, aActualConversion ); m_positionX = m_outline[0]->x; m_positionY = m_outline[0]->y; // fill the polygon with the same contour as its outline is m_islands.Add( new VERTICES_ARRAY ); FormPolygon( aNode, m_islands[0], aDefaultMeasurementUnit, aActualConversion ); return true; }
XNODE* NETLIST_EXPORTER_GENERIC::node( const wxString& aName, const wxString& aTextualContent /* = wxEmptyString*/ ) { XNODE* n = new XNODE( wxXML_ELEMENT_NODE, aName ); if( aTextualContent.Len() > 0 ) // excludes wxEmptyString, the parameter's default value n->AddChild( new XNODE( wxXML_TEXT_NODE, wxEmptyString, aTextualContent ) ); return n; }
bool PCB_COPPER_POUR::Parse( XNODE* aNode, wxString aDefaultMeasurementUnit, wxString aActualConversion, wxStatusBar* aStatusBar ) { XNODE* lNode; wxString pourType, str, propValue; int pourSpacing, thermalWidth; // aStatusBar->SetStatusText( aStatusBar->GetStatusText() + wxT( " CooperPour..." ) ); //str = FindNode( aNode, wxT( "pourType" ) )->GetNodeContent(); //str.Trim( false ); //pourType = str.MakeUpper(); lNode = FindNode( aNode, wxT( "netNameRef" ) ); if( lNode ) { lNode->GetAttribute( wxT( "Name" ), &propValue ); propValue.Trim( false ); propValue.Trim( true ); m_net = propValue; m_netCode = GetNetCode( m_net ); } if( FindNode( aNode, wxT( "width" ) ) ) SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(), aDefaultMeasurementUnit, &m_width, aActualConversion ); if( FindNode( aNode, wxT( "pourSpacing" ) ) ) SetWidth( FindNode( aNode, wxT( "pourSpacing" ) )->GetNodeContent(), aDefaultMeasurementUnit, &pourSpacing, aActualConversion ); if( FindNode( aNode, wxT( "thermalWidth" ) ) ) SetWidth( FindNode( aNode, wxT( "thermalWidth" ) )->GetNodeContent(), aDefaultMeasurementUnit, &thermalWidth, aActualConversion ); lNode = FindNode( aNode, wxT( "pcbPoly" ) ); if( lNode ) { // retrieve copper pour outline FormPolygon( lNode, &m_outline, aDefaultMeasurementUnit, aActualConversion ); m_positionX = m_outline[0]->x; m_positionY = m_outline[0]->y; } else { return false; } return true; }
void SetTextParameters( XNODE* aNode, TTEXTVALUE* aTextValue, wxString aDefaultMeasurementUnit, wxString aActualConversion ) { XNODE* tNode; wxString str; tNode = FindNode( aNode, wxT( "pt" ) ); if( tNode ) SetPosition( tNode->GetNodeContent(), aDefaultMeasurementUnit, &aTextValue->textPositionX, &aTextValue->textPositionY, aActualConversion ); tNode = FindNode( aNode, wxT( "rotation" ) ); if( tNode ) { str = tNode->GetNodeContent(); str.Trim( false ); aTextValue->textRotation = StrToInt1Units( str ); } str = FindNodeGetContent( aNode, wxT( "isVisible" ) ); if( str == wxT( "True" ) ) aTextValue->textIsVisible = 1; else if( str == wxT( "False" ) ) aTextValue->textIsVisible = 0; str = FindNodeGetContent( aNode, wxT( "justify" ) ); aTextValue->justify = GetJustifyIdentificator( str ); str = FindNodeGetContent( aNode, wxT( "isFlipped" ) ); if( str == wxT( "True" ) ) aTextValue->mirror = 1; tNode = FindNode( aNode, wxT( "textStyleRef" ) ); if( tNode ) SetFontProperty( tNode, aTextValue, aDefaultMeasurementUnit, aActualConversion ); }
XNODE* NETLIST_EXPORTER_GENERIC::makeRoot( int aCtl ) { XNODE* xroot = node( wxT( "export" ) ); xroot->AddAttribute( wxT( "version" ), wxT( "D" ) ); if( aCtl & GNL_HEADER ) // add the "design" header xroot->AddChild( makeDesignHeader() ); if( aCtl & GNL_COMPONENTS ) xroot->AddChild( makeComponents() ); if( aCtl & GNL_PARTS ) xroot->AddChild( makeLibParts() ); if( aCtl & GNL_LIBRARIES ) // must follow makeGenericLibParts() xroot->AddChild( makeLibraries() ); if( aCtl & GNL_NETS ) xroot->AddChild( makeListOfNets() ); return xroot; }
XNODE* NETLIST_EXPORTER_GENERIC::makeLibraries() { XNODE* xlibs = node( wxT( "libraries" ) ); // auto_ptr for( std::set<void*>::iterator it = m_Libraries.begin(); it!=m_Libraries.end(); ++it ) { PART_LIB* lib = (PART_LIB*) *it; XNODE* xlibrary; xlibs->AddChild( xlibrary = node( wxT( "library" ) ) ); xlibrary->AddAttribute( wxT( "logical" ), lib->GetLogicalName() ); xlibrary->AddChild( node( wxT( "uri" ), lib->GetFullFileName() ) ); // @todo: add more fun stuff here } return xlibs; }
void PCB_TEXT::Parse( XNODE* aNode, int aLayer, wxString aDefaultMeasurementUnit, wxString aActualConversion ) { XNODE* lNode; wxString str; m_PCadLayer = aLayer; m_KiCadLayer = GetKiCadLayer(); m_positionX = 0; m_positionY = 0; m_name.mirror = 0; // Normal, not mirrored lNode = FindNode( aNode, wxT( "pt" ) ); if( lNode ) SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_positionX, &m_positionY, aActualConversion ); lNode = FindNode( aNode, wxT( "rotation" ) ); if( lNode ) { str = lNode->GetNodeContent(); str.Trim( false ); m_rotation = StrToInt1Units( str ); } aNode->GetAttribute( wxT( "Name" ), &m_name.text ); m_name.text.Replace( "\r", "" ); str = FindNodeGetContent( aNode, wxT( "justify" ) ); m_name.justify = GetJustifyIdentificator( str ); str = FindNodeGetContent( aNode, wxT( "isFlipped" ) ); if( str == wxT( "True" ) ) m_name.mirror = 1; lNode = FindNode( aNode, wxT( "textStyleRef" ) ); if( lNode ) SetFontProperty( lNode, &m_name, aDefaultMeasurementUnit, aActualConversion ); }
bool PCB_PLANE::Parse( XNODE* aNode, wxString aDefaultMeasurementUnit, wxString aActualConversion, wxStatusBar* aStatusBar ) { XNODE* lNode; wxString pourType, str, propValue; // aStatusBar->SetStatusText( aStatusBar->GetStatusText() + wxT( " Plane..." ) ); lNode = FindNode( aNode, wxT( "netNameRef" ) ); if( lNode ) { lNode->GetAttribute( wxT( "Name" ), &propValue ); propValue.Trim( false ); propValue.Trim( true ); m_net = propValue; m_netCode = GetNetCode( m_net ); } if( FindNode( aNode, wxT( "width" ) ) ) SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(), aDefaultMeasurementUnit, &m_width, aActualConversion ); lNode = FindNode( aNode, wxT( "pcbPoly" ) ); if( lNode ) { // retrieve plane outline FormPolygon( lNode, &m_outline, aDefaultMeasurementUnit, aActualConversion ); m_positionX = m_outline[0]->x; m_positionY = m_outline[0]->y; } else { return false; } return true; }
void PCB_POLYGON::FormPolygon( XNODE* aNode, VERTICES_ARRAY* aPolygon, const wxString& aDefaultMeasurementUnit, const wxString& aActualConversion ) { XNODE* lNode; double x, y; lNode = FindNode( aNode, wxT( "pt" ) ); while( lNode ) { if( lNode->GetName() == wxT( "pt" ) ) { SetDoublePrecisionPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit, &x, &y, aActualConversion ); aPolygon->Add( new wxRealPoint( x, y ) ); } lNode = lNode->GetNext(); } }
void XNODE::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) { // output attributes first if they exist for( XATTR* attr = (XATTR*) GetAttributes(); attr; attr = (XATTR*) attr->GetNext() ) { out->Print( 0, " (%s %s)", TO_UTF8( attr->GetName() ), out->Quotew( attr->GetValue() ).c_str() ); } // we only expect to have used one of two types here: switch( GetType() ) { case wxXML_ELEMENT_NODE: // output children if they exist. for( XNODE* kid = (XNODE*) GetChildren(); kid; kid = (XNODE*) kid->GetNext() ) { if( kid->GetType() != wxXML_TEXT_NODE ) { if( kid == GetChildren() ) out->Print( 0, "\n" ); kid->Format( out, nestLevel+1 ); } else { kid->Format( out, 0 ); } } break; case wxXML_TEXT_NODE: out->Print( 0, " %s", out->Quotew( GetContent() ).c_str() ); break; default: ; // not supported } }
XNODE* NETLIST_EXPORTER_GENERIC::makeComponents() { XNODE* xcomps = node( wxT( "components" ) ); wxString timeStamp; // some strings we need many times, but don't want to construct more // than once for performance. These are used within loops so the // enclosing wxString constructor would fire on each loop iteration if // they were in a nested scope. // these are actually constructor invocations, not assignments as it appears: wxString sFields = wxT( "fields" ); wxString sField = wxT( "field" ); wxString sComponent = wxT( "comp" ); // use "part" ? wxString sName = wxT( "name" ); wxString sRef = wxT( "ref" ); wxString sPins = wxT( "pins" ); wxString sPin = wxT( "pin" ); wxString sValue = wxT( "value" ); wxString sSheetPath = wxT( "sheetpath" ); wxString sFootprint = wxT( "footprint" ); wxString sDatasheet = wxT( "datasheet" ); wxString sTStamp = wxT( "tstamp" ); wxString sTStamps = wxT( "tstamps" ); wxString sTSFmt = wxT( "%8.8lX" ); // comp->m_TimeStamp wxString sLibSource = wxT( "libsource" ); wxString sLibPart = wxT( "libpart" ); wxString sLib = wxT( "lib" ); wxString sPart = wxT( "part" ); wxString sNames = wxT( "names" ); m_ReferencesAlreadyFound.Clear(); SCH_SHEET_LIST sheetList( g_RootSheet ); // Output is xml, so there is no reason to remove spaces from the field values. // And XML element names need not be translated to various languages. for( unsigned i = 0; i < sheetList.size(); i++ ) { for( EDA_ITEM* schItem = sheetList[i].LastDrawList(); schItem; schItem = schItem->Next() ) { SCH_COMPONENT* comp = findNextComponentAndCreatePinList( schItem, &sheetList[i] ); if( !comp ) break; // No component left schItem = comp; XNODE* xcomp; // current component being constructed // Output the component's elements in order of expected access frequency. // This may not always look best, but it will allow faster execution // under XSL processing systems which do sequential searching within // an element. xcomps->AddChild( xcomp = node( sComponent ) ); xcomp->AddAttribute( sRef, comp->GetRef( &sheetList[i] ) ); xcomp->AddChild( node( sValue, comp->GetField( VALUE )->GetText() ) ); if( !comp->GetField( FOOTPRINT )->IsVoid() ) xcomp->AddChild( node( sFootprint, comp->GetField( FOOTPRINT )->GetText() ) ); if( !comp->GetField( DATASHEET )->IsVoid() ) xcomp->AddChild( node( sDatasheet, comp->GetField( DATASHEET )->GetText() ) ); // Export all user defined fields within the component, // which start at field index MANDATORY_FIELDS. Only output the <fields> // container element if there are any <field>s. if( comp->GetFieldCount() > MANDATORY_FIELDS ) { XNODE* xfields; xcomp->AddChild( xfields = node( sFields ) ); for( int fldNdx = MANDATORY_FIELDS; fldNdx < comp->GetFieldCount(); ++fldNdx ) { SCH_FIELD* f = comp->GetField( fldNdx ); // only output a field if non empty and not just "~" if( !f->IsVoid() ) { XNODE* xfield; xfields->AddChild( xfield = node( sField, f->GetText() ) ); xfield->AddAttribute( sName, f->GetName() ); } } } XNODE* xlibsource; xcomp->AddChild( xlibsource = node( sLibSource ) ); // "logical" library name, which is in anticipation of a better search // algorithm for parts based on "logical_lib.part" and where logical_lib // is merely the library name minus path and extension. LIB_PART* part = m_libs->FindLibPart( comp->GetLibId() ); if( part ) xlibsource->AddAttribute( sLib, part->GetLib()->GetLogicalName() ); // We only want the symbol name, not the full LIB_ID. xlibsource->AddAttribute( sPart, comp->GetLibId().GetLibItemName() ); XNODE* xsheetpath; xcomp->AddChild( xsheetpath = node( sSheetPath ) ); xsheetpath->AddAttribute( sNames, sheetList[i].PathHumanReadable() ); xsheetpath->AddAttribute( sTStamps, sheetList[i].Path() ); timeStamp.Printf( sTSFmt, (unsigned long)comp->GetTimeStamp() ); xcomp->AddChild( node( sTStamp, timeStamp ) ); } } return xcomps; }
void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc ) { int tok; XNODE* iNode = NULL, *cNode = NULL; wxString str; bool growing = false; bool attr = false; wxCSConv conv( wxT( "windows-1251" ) ); FILE* fp = wxFopen( aFileName, wxT( "rt" ) ); if( !fp ) THROW_IO_ERROR( wxT( "Unable to open file: " ) + aFileName ); // lexer now owns fp, will close on exception or return DSNLEXER lexer( empty_keywords, 0, fp, aFileName ); iNode = new XNODE( wxXML_ELEMENT_NODE, wxT( "www.lura.sk" ) ); while( ( tok = lexer.NextTok() ) != DSN_EOF ) { if( growing && ( tok == DSN_LEFT || tok == DSN_RIGHT ) ) { if( attr ) { cNode->AddAttribute( wxT( "Name" ), str.Trim( false ) ); } else if( str != wxEmptyString ) { cNode->AddChild( new XNODE( wxXML_TEXT_NODE, wxEmptyString, str ) ); } growing = false; attr = false; } if( tok == DSN_RIGHT ) { iNode = iNode->GetParent(); } else if( tok == DSN_LEFT ) { tok = lexer.NextTok(); str = wxEmptyString; cNode = new XNODE( wxXML_ELEMENT_NODE, wxString( lexer.CurText(), conv ) ); iNode->AddChild( cNode ); iNode = cNode; growing = true; } else { str += wxT( ' ' ); str += wxString( lexer.CurText(), conv ); if( tok == DSN_STRING ) attr = true; } } if( iNode ) { aXmlDoc->SetRoot( iNode ); //aXmlDoc->Save( wxT( "test.xml" ) ); } }
void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc ) { char line[sizeof( ACCEL_ASCII_KEYWORD )]; int tok; XNODE* iNode = NULL, *cNode = NULL; wxString str, propValue, content; wxCSConv conv( wxT( "windows-1251" ) ); FILE* fp = wxFopen( aFileName, wxT( "rt" ) ); if( !fp ) THROW_IO_ERROR( wxT( "Unable to open file: " ) + aFileName ); // check file format if( !fgets( line, sizeof( line ), fp ) || strcmp( line, ACCEL_ASCII_KEYWORD ) ) THROW_IO_ERROR( "Unknown file type" ); // rewind the file fseek( fp, 0, SEEK_SET ); // lexer now owns fp, will close on exception or return DSNLEXER lexer( empty_keywords, 0, fp, aFileName ); iNode = new XNODE( wxXML_ELEMENT_NODE, wxT( "www.lura.sk" ) ); while( ( tok = lexer.NextTok() ) != DSN_EOF ) { if( tok == DSN_RIGHT ) { iNode = iNode->GetParent(); } else if( tok == DSN_LEFT ) { tok = lexer.NextTok(); str = wxEmptyString; cNode = new XNODE( wxXML_ELEMENT_NODE, wxString( lexer.CurText(), conv ) ); iNode->AddChild( cNode ); iNode = cNode; } else if( cNode ) { str = wxString( lexer.CurText(), conv ); if( tok == DSN_STRING ) { // update attribute if( iNode->GetAttribute( wxT( "Name" ), &propValue ) ) { iNode->DeleteAttribute( wxT( "Name" ) ); iNode->AddAttribute( wxT( "Name" ), propValue + wxT( ' ' ) + str ); } else iNode->AddAttribute( wxT( "Name" ), str ); } else if( str != wxEmptyString ) { // update node content content = cNode->GetNodeContent() + wxT( ' ' ) + str; if( cNode->GetChildren() ) cNode->GetChildren()->SetContent( content ); else cNode->AddChild( new wxXmlNode( wxXML_TEXT_NODE, wxEmptyString, content ) ); } } } if( iNode ) { aXmlDoc->SetRoot( iNode ); //aXmlDoc->Save( wxT( "test.xml" ) ); } }
XNODE* NETLIST_EXPORTER_GENERIC::makeListOfNets() { XNODE* xnets = node( wxT( "nets" ) ); // auto_ptr if exceptions ever get used. wxString netCodeTxt; wxString netName; wxString ref; wxString sNet = wxT( "net" ); wxString sName = wxT( "name" ); wxString sCode = wxT( "code" ); wxString sRef = wxT( "ref" ); wxString sPin = wxT( "pin" ); wxString sNode = wxT( "node" ); wxString sFmtd = wxT( "%d" ); XNODE* xnet = 0; int netCode; int lastNetCode = -1; int sameNetcodeCount = 0; /* output: <net code="123" name="/cfcard.sch/WAIT#"> <node ref="R23" pin="1"/> <node ref="U18" pin="12"/> </net> */ m_LibParts.clear(); // must call this function before using m_LibParts. for( unsigned ii = 0; ii < m_masterList->size(); ii++ ) { NETLIST_OBJECT* nitem = m_masterList->GetItem( ii ); SCH_COMPONENT* comp; // New net found, write net id; if( ( netCode = nitem->GetNet() ) != lastNetCode ) { sameNetcodeCount = 0; // item count for this net netName = nitem->GetNetName(); lastNetCode = netCode; } if( nitem->m_Type != NET_PIN ) continue; if( nitem->m_Flag != 0 ) // Redundant pin, skip it continue; comp = nitem->GetComponentParent(); // Get the reference for the net name and the main parent component ref = comp->GetRef( &nitem->m_SheetPath ); if( ref[0] == wxChar( '#' ) ) continue; if( ++sameNetcodeCount == 1 ) { xnets->AddChild( xnet = node( sNet ) ); netCodeTxt.Printf( sFmtd, netCode ); xnet->AddAttribute( sCode, netCodeTxt ); xnet->AddAttribute( sName, netName ); } XNODE* xnode; xnet->AddChild( xnode = node( sNode ) ); xnode->AddAttribute( sRef, ref ); xnode->AddAttribute( sPin, nitem->GetPinNumText() ); } return xnets; }
XNODE* NETLIST_EXPORTER_GENERIC::makeLibParts() { XNODE* xlibparts = node( wxT( "libparts" ) ); // auto_ptr wxString sLibpart = wxT( "libpart" ); wxString sLib = wxT( "lib" ); wxString sPart = wxT( "part" ); wxString sAliases = wxT( "aliases" ); wxString sAlias = wxT( "alias" ); wxString sPins = wxT( "pins" ); // key for library component pins list wxString sPin = wxT( "pin" ); // key for one library component pin descr wxString sPinNum = wxT( "num" ); // key for one library component pin num wxString sPinName = wxT( "name" ); // key for one library component pin name wxString sPinType = wxT( "type" ); // key for one library component pin electrical type wxString sName = wxT( "name" ); wxString sField = wxT( "field" ); wxString sFields = wxT( "fields" ); wxString sDescr = wxT( "description" ); wxString sDocs = wxT( "docs" ); wxString sFprints = wxT( "footprints" ); wxString sFp = wxT( "fp" ); LIB_PINS pinList; LIB_FIELDS fieldList; m_Libraries.clear(); for( std::set<LIB_PART*>::iterator it = m_LibParts.begin(); it!=m_LibParts.end(); ++it ) { LIB_PART* lcomp = *it; PART_LIB* library = lcomp->GetLib(); m_Libraries.insert( library ); // inserts component's library if unique XNODE* xlibpart; xlibparts->AddChild( xlibpart = node( sLibpart ) ); xlibpart->AddAttribute( sLib, library->GetLogicalName() ); xlibpart->AddAttribute( sPart, lcomp->GetName() ); if( lcomp->GetAliasCount() ) { wxArrayString aliases = lcomp->GetAliasNames( false ); if( aliases.GetCount() ) { XNODE* xaliases = node( sAliases ); xlibpart->AddChild( xaliases ); for( unsigned i=0; i<aliases.GetCount(); ++i ) { xaliases->AddChild( node( sAlias, aliases[i] ) ); } } } //----- show the important properties ------------------------- if( !lcomp->GetAlias( 0 )->GetDescription().IsEmpty() ) xlibpart->AddChild( node( sDescr, lcomp->GetAlias( 0 )->GetDescription() ) ); if( !lcomp->GetAlias( 0 )->GetDocFileName().IsEmpty() ) xlibpart->AddChild( node( sDocs, lcomp->GetAlias( 0 )->GetDocFileName() ) ); // Write the footprint list if( lcomp->GetFootPrints().GetCount() ) { XNODE* xfootprints; xlibpart->AddChild( xfootprints = node( sFprints ) ); for( unsigned i=0; i<lcomp->GetFootPrints().GetCount(); ++i ) { xfootprints->AddChild( node( sFp, lcomp->GetFootPrints()[i] ) ); } } //----- show the fields here ---------------------------------- fieldList.clear(); lcomp->GetFields( fieldList ); XNODE* xfields; xlibpart->AddChild( xfields = node( sFields ) ); for( unsigned i=0; i<fieldList.size(); ++i ) { if( !fieldList[i].GetText().IsEmpty() ) { XNODE* xfield; xfields->AddChild( xfield = node( sField, fieldList[i].GetText() ) ); xfield->AddAttribute( sName, fieldList[i].GetName(false) ); } } //----- show the pins here ------------------------------------ pinList.clear(); lcomp->GetPins( pinList, 0, 0 ); /* we must erase redundant Pins references in pinList * These redundant pins exist because some pins * are found more than one time when a component has * multiple parts per package or has 2 representations (DeMorgan conversion) * For instance, a 74ls00 has DeMorgan conversion, with different pin shapes, * and therefore each pin appears 2 times in the list. * Common pins (VCC, GND) can also be found more than once. */ sort( pinList.begin(), pinList.end(), sortPinsByNumber ); for( int ii = 0; ii < (int)pinList.size()-1; ii++ ) { if( pinList[ii]->GetNumber() == pinList[ii+1]->GetNumber() ) { // 2 pins have the same number, remove the redundant pin at index i+1 pinList.erase(pinList.begin() + ii + 1); ii--; } } if( pinList.size() ) { XNODE* pins; xlibpart->AddChild( pins = node( sPins ) ); for( unsigned i=0; i<pinList.size(); ++i ) { XNODE* pin; pins->AddChild( pin = node( sPin ) ); pin->AddAttribute( sPinNum, pinList[i]->GetNumberString() ); pin->AddAttribute( sPinName, pinList[i]->GetName() ); pin->AddAttribute( sPinType, pinList[i]->GetCanonicalElectricalTypeName() ); // caution: construction work site here, drive slowly } } } return xlibparts; }
XNODE* NETLIST_EXPORTER_GENERIC::makeDesignHeader() { SCH_SCREEN* screen; XNODE* xdesign = node( wxT( "design" ) ); XNODE* xtitleBlock; XNODE* xsheet; XNODE* xcomment; wxString sheetTxt; wxFileName sourceFileName; // the root sheet is a special sheet, call it source xdesign->AddChild( node( wxT( "source" ), g_RootSheet->GetScreen()->GetFileName() ) ); xdesign->AddChild( node( wxT( "date" ), DateAndTime() ) ); // which Eeschema tool xdesign->AddChild( node( wxT( "tool" ), wxT( "Eeschema " ) + GetBuildVersion() ) ); /* Export the sheets information */ SCH_SHEET_LIST sheetList( g_RootSheet ); for( unsigned i = 0; i < sheetList.size(); i++ ) { screen = sheetList[i].LastScreen(); xdesign->AddChild( xsheet = node( wxT( "sheet" ) ) ); // get the string representation of the sheet index number. // Note that sheet->GetIndex() is zero index base and we need to increment the // number by one to make it human readable sheetTxt.Printf( wxT( "%u" ), i + 1 ); xsheet->AddAttribute( wxT( "number" ), sheetTxt ); xsheet->AddAttribute( wxT( "name" ), sheetList[i].PathHumanReadable() ); xsheet->AddAttribute( wxT( "tstamps" ), sheetList[i].Path() ); TITLE_BLOCK tb = screen->GetTitleBlock(); xsheet->AddChild( xtitleBlock = node( wxT( "title_block" ) ) ); xtitleBlock->AddChild( node( wxT( "title" ), tb.GetTitle() ) ); xtitleBlock->AddChild( node( wxT( "company" ), tb.GetCompany() ) ); xtitleBlock->AddChild( node( wxT( "rev" ), tb.GetRevision() ) ); xtitleBlock->AddChild( node( wxT( "date" ), tb.GetDate() ) ); // We are going to remove the fileName directories. sourceFileName = wxFileName( screen->GetFileName() ); xtitleBlock->AddChild( node( wxT( "source" ), sourceFileName.GetFullName() ) ); xtitleBlock->AddChild( xcomment = node( wxT( "comment" ) ) ); xcomment->AddAttribute( wxT("number"), wxT("1") ); xcomment->AddAttribute( wxT( "value" ), tb.GetComment1() ); xtitleBlock->AddChild( xcomment = node( wxT( "comment" ) ) ); xcomment->AddAttribute( wxT("number"), wxT("2") ); xcomment->AddAttribute( wxT( "value" ), tb.GetComment2() ); xtitleBlock->AddChild( xcomment = node( wxT( "comment" ) ) ); xcomment->AddAttribute( wxT("number"), wxT("3") ); xcomment->AddAttribute( wxT( "value" ), tb.GetComment3() ); xtitleBlock->AddChild( xcomment = node( wxT( "comment" ) ) ); xcomment->AddAttribute( wxT("number"), wxT("4") ); xcomment->AddAttribute( wxT( "value" ), tb.GetComment4() ); } return xdesign; }
void PCB_EDIT_FRAME::ReadMacros() { wxString str; wxFileName fn; fn = GetBoard()->GetFileName(); fn.SetExt( MacrosFileExtension ); wxFileDialog dlg( this, _( "Read Macros File" ), fn.GetPath(), fn.GetFullName(), MacrosFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR ); if( dlg.ShowModal() == wxID_CANCEL ) return; if( !wxFileExists( dlg.GetPath() ) ) { wxString msg; msg.Printf( _( "File %s not found" ), GetChars( dlg.GetPath() ) ); DisplayError( this, msg ); return; } wxXmlDocument xml; xml.SetFileEncoding( wxT( "UTF-8" ) ); if( !xml.Load( dlg.GetFilename() ) ) return; XNODE *macrosNode = (XNODE*) xml.GetRoot()->GetChildren(); while( macrosNode ) { int number = -1; if( macrosNode->GetName() == wxT( "macros" ) ) { number = wxAtoi( macrosNode->GetAttribute( wxT( "number" ), wxT( "-1" ) ) ); if( number >= 0 && number < 10 ) { m_Macros[number].m_Record.clear(); XNODE *hotkeyNode = (XNODE*) macrosNode->GetChildren(); while( hotkeyNode ) { if( hotkeyNode->GetName() == wxT( "hotkey" ) ) { int x = wxAtoi( hotkeyNode->GetAttribute( wxT( "x" ), wxT( "0" ) ) ); int y = wxAtoi( hotkeyNode->GetAttribute( wxT( "y" ), wxT( "0" ) ) ); int hk = wxAtoi( hotkeyNode->GetAttribute( wxT( "hkcode" ), wxT( "0" ) ) ); MACROS_RECORD macros_record; macros_record.m_HotkeyCode = hk; macros_record.m_Position.x = x; macros_record.m_Position.y = y; m_Macros[number].m_Record.push_back( macros_record ); } hotkeyNode = (XNODE*) hotkeyNode->GetNext(); } } } macrosNode = (XNODE*) macrosNode->GetNext(); } }