From 47e4798423764426428e5c38e35473200795eded Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 19 Mar 2018 12:09:15 +0100 Subject: [PATCH] kicad2step: Report function name and line number only in debug builds --- utils/kicad2step/pcb/oce_utils.cpp | 92 ++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 23 deletions(-) diff --git a/utils/kicad2step/pcb/oce_utils.cpp b/utils/kicad2step/pcb/oce_utils.cpp index dccd5c6817..0d26580f4e 100644 --- a/utils/kicad2step/pcb/oce_utils.cpp +++ b/utils/kicad2step/pcb/oce_utils.cpp @@ -160,9 +160,11 @@ FormatType fileType( const char* aFileName ) if( !lfile.FileExists() ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * no such file: '" << aFileName << "'\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return FMT_NONE; } @@ -250,9 +252,11 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve ) if( distance < MIN_LENGTH2 ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * rejected a zero-length line\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } @@ -267,9 +271,11 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve ) if( rad < MIN_LENGTH2 ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * rejected a zero-radius arc or circle\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } @@ -305,9 +311,11 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve ) if( rad < MIN_LENGTH2 ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * rejected an arc with equivalent end points\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } } @@ -408,9 +416,11 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve ) do { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * unsupported curve type: '" << aCurve->m_form << "'\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); } while( 0 ); return false; @@ -571,9 +581,11 @@ bool PCBMODEL::AddComponent( const std::string& aFileName, const std::string aRe if( !getModelLabel( aFileName, lmodel ) ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * no model for filename '" << aFileName << "'\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } @@ -583,9 +595,11 @@ bool PCBMODEL::AddComponent( const std::string& aFileName, const std::string aRe if( !getModelLocation( aBottom, aPosition, aRotation, aOffset, aOrientation, toploc ) ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * no location data for filename '" << aFileName << "'\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } @@ -595,9 +609,11 @@ bool PCBMODEL::AddComponent( const std::string& aFileName, const std::string aRe if( llabel.IsNull() ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * could not add component with filename '" << aFileName << "'\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } @@ -637,9 +653,11 @@ bool PCBMODEL::CreatePCB() { m_hasPCB = true; std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * no valid board outline\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } @@ -658,9 +676,11 @@ bool PCBMODEL::CreatePCB() if( !oln.MakeShape( board, m_thickness ) ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * could not create board extrusion\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } @@ -676,9 +696,11 @@ bool PCBMODEL::CreatePCB() else { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * could not create board cutout\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); } } @@ -710,9 +732,11 @@ bool PCBMODEL::CreatePCB() if( sC == eC && !oln.m_curves.empty() ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * could not close outline (dropping outline data with " << oln.m_curves.size() << " segments)\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); oln.Clear(); if( !m_curves.empty() ) @@ -730,9 +754,11 @@ bool PCBMODEL::CreatePCB() if( !oln.MakeShape( board, m_thickness ) ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * could not create board extrusion\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } } @@ -747,9 +773,11 @@ bool PCBMODEL::CreatePCB() else { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * could not create board cutout\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); } } } @@ -790,9 +818,11 @@ bool PCBMODEL::WriteIGES( const std::string& aFileName, bool aOverwrite ) if( m_pcb_label.IsNull() ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * No valid PCB assembly; cannot create output file " << aFileName << "\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } @@ -822,9 +852,11 @@ bool PCBMODEL::WriteSTEP( const std::string& aFileName, bool aOverwrite ) if( m_pcb_label.IsNull() ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * No valid PCB assembly; cannot create output file " << aFileName << "\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } @@ -874,9 +906,11 @@ bool PCBMODEL::getModelLabel( const std::string aFileName, TDF_Label& aLabel ) if( !readIGES( doc, aFileName.c_str() ) ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * readIGES() failed on filename '" << aFileName << "'\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } break; @@ -885,9 +919,11 @@ bool PCBMODEL::getModelLabel( const std::string aFileName, TDF_Label& aLabel ) if( !readSTEP( doc, aFileName.c_str() ) ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * readSTEP() failed on filename '" << aFileName << "'\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } break; @@ -960,9 +996,11 @@ bool PCBMODEL::getModelLabel( const std::string aFileName, TDF_Label& aLabel ) if( aLabel.IsNull() ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * could not transfer model data from file '" << aFileName << "'\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } @@ -1342,9 +1380,11 @@ bool OUTLINE::MakeShape( TopoDS_Shape& aShape, double aThickness ) if( !addEdge( &wire, i, lastPoint ) ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * failed to add an edge\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } } @@ -1355,9 +1395,11 @@ bool OUTLINE::MakeShape( TopoDS_Shape& aShape, double aThickness ) if( aShape.IsNull() ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * failed to create a prismatic shape\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } @@ -1405,9 +1447,11 @@ bool OUTLINE::addEdge( BRepBuilderAPI_MakeWire* aWire, KICADCURVE& aCurve, DOUBL do { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * unsupported curve type: " << aCurve.m_form << "\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; } while( 0 ); @@ -1422,9 +1466,11 @@ bool OUTLINE::addEdge( BRepBuilderAPI_MakeWire* aWire, KICADCURVE& aCurve, DOUBL if( BRepBuilderAPI_DisconnectedWire == aWire->Error() ) { std::ostringstream ostr; +#ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; +#endif /* __WXDEBUG */ ostr << " * failed to add curve\n"; - wxLogMessage( "%s\n", ostr.str().c_str() ); + wxLogMessage( "%s", ostr.str().c_str() ); return false; }