KiCad PCB EDA Suite
PNS::LOGGER Class Reference

#include <pns_logger.h>

Public Member Functions

 LOGGER ()
 
 ~LOGGER ()
 
void Save (const std::string &aFilename)
 
void Clear ()
 
void NewGroup (const std::string &aName, int aIter=0)
 
void EndGroup ()
 
void Log (const ITEM *aItem, int aKind=0, const std::string aName=std::string())
 
void Log (const SHAPE_LINE_CHAIN *aL, int aKind=0, const std::string aName=std::string())
 
void Log (const VECTOR2I &aStart, const VECTOR2I &aEnd, int aKind=0, const std::string aName=std::string())
 

Private Member Functions

void dumpShape (const SHAPE *aSh)
 

Private Attributes

bool m_groupOpened
 
std::stringstream m_theLog
 

Detailed Description

Definition at line 39 of file pns_logger.h.

Constructor & Destructor Documentation

PNS::LOGGER::LOGGER ( )

Definition at line 37 of file pns_logger.cpp.

References m_groupOpened.

38 {
39  m_groupOpened = false;
40 }
bool m_groupOpened
Definition: pns_logger.h:59
PNS::LOGGER::~LOGGER ( )

Definition at line 43 of file pns_logger.cpp.

44 {
45 }

Member Function Documentation

void PNS::LOGGER::Clear ( )

Definition at line 48 of file pns_logger.cpp.

References m_groupOpened, and m_theLog.

Referenced by PNS::SHOVE::ShoveLines(), and PNS::SHOVE::ShoveMultiLines().

49 {
50  m_theLog.str( std::string() );
51  m_groupOpened = false;
52 }
bool m_groupOpened
Definition: pns_logger.h:59
std::stringstream m_theLog
Definition: pns_logger.h:60
void PNS::LOGGER::dumpShape ( const SHAPE aSh)
private

Definition at line 142 of file pns_logger.cpp.

References SEG::A, SEG::B, SHAPE_CONVEX::CPoint(), SHAPE_LINE_CHAIN::CPoint(), SHAPE_CIRCLE::GetCenter(), SHAPE_RECT::GetPosition(), SHAPE_CIRCLE::GetRadius(), SHAPE_SEGMENT::GetSeg(), SHAPE_RECT::GetSize(), SHAPE_LINE_CHAIN::IsClosed(), m_theLog, SHAPE_CONVEX::PointCount(), SHAPE_LINE_CHAIN::PointCount(), SH_CIRCLE, SH_CONVEX, SH_LINE_CHAIN, SH_RECT, SH_SEGMENT, SHAPE::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Log().

143 {
144  switch( aSh->Type() )
145  {
146  case SH_LINE_CHAIN:
147  {
148  const SHAPE_LINE_CHAIN* lc = (const SHAPE_LINE_CHAIN*) aSh;
149  m_theLog << "linechain " << lc->PointCount() << " " << ( lc->IsClosed() ? 1 : 0 ) << " ";
150 
151  for( int i = 0; i < lc->PointCount(); i++ )
152  m_theLog << lc->CPoint( i ).x << " " << lc->CPoint( i ).y << " ";
153 
154  break;
155  }
156 
157  case SH_CIRCLE:
158  {
159  const SHAPE_CIRCLE *c = (const SHAPE_CIRCLE*) aSh;
160  m_theLog << "circle " << c->GetCenter().x << " " << c->GetCenter().y << " " << c->GetRadius();
161  break;
162  }
163 
164  case SH_RECT:
165  {
166  const SHAPE_RECT* r = (const SHAPE_RECT*) aSh;
167  m_theLog << "rect " << r->GetPosition().x << " " << r->GetPosition().y << " " <<
168  r->GetSize().x << " " <<r->GetSize().y;
169  break;
170  }
171 
172  case SH_SEGMENT:
173  {
174  const SHAPE_SEGMENT* s = (const SHAPE_SEGMENT*) aSh;
175  m_theLog << "linechain 2 0 " << s->GetSeg().A.x << " " << s->GetSeg().A.y << " " <<
176  s->GetSeg().B.x << " " << s->GetSeg().B.y;
177  break;
178  }
179 
180  case SH_CONVEX:
181  {
182  const SHAPE_CONVEX* c = (const SHAPE_CONVEX*) aSh;
183  m_theLog << "convex " << c->PointCount() << " ";
184 
185  for( int i = 0; i < c->PointCount(); i++ )
186  m_theLog << c->CPoint( i ).x << " " << c->CPoint( i ).y << " ";
187 
188  break;
189  }
190 
191  default:
192  break;
193  }
194 }
VECTOR2I & B
Definition: seg.h:52
const VECTOR2I GetCenter() const
Definition: shape_circle.h:84
int PointCount() const
Function PointCount()
int GetRadius() const
Definition: shape_circle.h:79
Class SHAPE_CONVEX.
Definition: shape_convex.h:42
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
Definition: shape_convex.h:113
VECTOR2I & A
Definition: seg.h:51
int PointCount() const
Function PointCount()
Definition: shape_convex.h:85
const VECTOR2I & GetPosition() const
Function GetPosition()
Definition: shape_rect.h:100
line chain (polyline)
Definition: shape.h:46
const SEG & GetSeg() const
Definition: shape_segment.h:70
SHAPE_TYPE Type() const
Function Type()
Definition: shape.h:82
Class SHAPE_LINE_CHAIN.
std::stringstream m_theLog
Definition: pns_logger.h:60
line segment
Definition: shape.h:45
bool IsClosed() const
Function IsClosed()
Definition: shape.h:43
circle
Definition: shape.h:47
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
const VECTOR2I GetSize() const
Function GetSize()
Definition: shape_rect.h:110
axis-aligned rectangle
Definition: shape.h:44
void PNS::LOGGER::EndGroup ( )

Definition at line 65 of file pns_logger.cpp.

References m_groupOpened, and m_theLog.

Referenced by Save().

66 {
67  if( !m_groupOpened )
68  return;
69 
70  m_groupOpened = false;
71  m_theLog << "endgroup" << std::endl;
72 }
bool m_groupOpened
Definition: pns_logger.h:59
std::stringstream m_theLog
Definition: pns_logger.h:60
void PNS::LOGGER::Log ( const ITEM aItem,
int  aKind = 0,
const std::string  aName = std::string() 
)

Definition at line 75 of file pns_logger.cpp.

References SEG::A, SEG::B, dumpShape(), LAYER_RANGE::End(), PNS::LINE::EndsWithVia(), PNS::ITEM::Kind(), PNS::ITEM::Layers(), PNS::ITEM::LINE_T, m_theLog, PNS::ITEM::Marker(), PNS::ITEM::Net(), PNS::ITEM::Rank(), PNS::SEGMENT::Seg(), PNS::ITEM::SEGMENT_T, PNS::SOLID::Shape(), PNS::LINE::Shape(), PNS::ITEM::Shape(), PNS::ITEM::SOLID_T, LAYER_RANGE::Start(), PNS::ITEM::VIA_T, PNS::SEGMENT::Width(), PNS::LINE::Width(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PNS::SHOVE::onCollidingLine(), PNS::SHOVE::onCollidingSegment(), PNS::SHOVE::onCollidingSolid(), PNS::SHOVE::onCollidingVia(), PNS::SHOVE::onReverseCollidingVia(), PNS::SHOVE::pushVia(), PNS::SHOVE::ShoveLines(), PNS::SHOVE::ShoveMultiLines(), and PNS::WALKAROUND::singleStep().

76 {
77  m_theLog << "item " << aKind << " " << aName << " ";
78  m_theLog << aItem->Net() << " " << aItem->Layers().Start() << " " <<
79  aItem->Layers().End() << " " << aItem->Marker() << " " << aItem->Rank();
80 
81  switch( aItem->Kind() )
82  {
83  case ITEM::LINE_T:
84  {
85  LINE* l = (LINE*) aItem;
86  m_theLog << " line ";
87  m_theLog << l->Width() << " " << ( l->EndsWithVia() ? 1 : 0 ) << " ";
88  dumpShape ( l->Shape() );
89  m_theLog << std::endl;
90  break;
91  }
92 
93  case ITEM::VIA_T:
94  {
95  m_theLog << " via 0 0 ";
96  dumpShape ( aItem->Shape() );
97  m_theLog << std::endl;
98  break;
99  }
100 
101  case ITEM::SEGMENT_T:
102  {
103  SEGMENT* s =(SEGMENT*) aItem;
104  m_theLog << " line ";
105  m_theLog << s->Width() << " 0 linechain 2 0 " << s->Seg().A.x << " " <<
106  s->Seg().A.y << " " << s->Seg().B.x << " " <<s->Seg().B.y << std::endl;
107  break;
108  }
109 
110  case ITEM::SOLID_T:
111  {
112  SOLID* s = (SOLID*) aItem;
113  m_theLog << " solid 0 0 ";
114  dumpShape( s->Shape() );
115  m_theLog << std::endl;
116  break;
117  }
118 
119  default:
120  break;
121  }
122 }
void dumpShape(const SHAPE *aSh)
Definition: pns_logger.cpp:142
std::stringstream m_theLog
Definition: pns_logger.h:60
Struct SEGMENT is a simple container used when filling areas with segments.
Definition: class_zone.h:57
void PNS::LOGGER::Log ( const SHAPE_LINE_CHAIN aL,
int  aKind = 0,
const std::string  aName = std::string() 
)

Definition at line 125 of file pns_logger.cpp.

References dumpShape(), and m_theLog.

126 {
127  m_theLog << "item " << aKind << " " << aName << " ";
128  m_theLog << 0 << " " << 0 << " " << 0 << " " << 0 << " " << 0;
129  m_theLog << " line ";
130  m_theLog << 0 << " " << 0 << " ";
131  dumpShape( aL );
132  m_theLog << std::endl;
133 }
void dumpShape(const SHAPE *aSh)
Definition: pns_logger.cpp:142
std::stringstream m_theLog
Definition: pns_logger.h:60
void PNS::LOGGER::Log ( const VECTOR2I aStart,
const VECTOR2I aEnd,
int  aKind = 0,
const std::string  aName = std::string() 
)

Definition at line 136 of file pns_logger.cpp.

138 {
139 }
void PNS::LOGGER::NewGroup ( const std::string &  aName,
int  aIter = 0 
)

Definition at line 55 of file pns_logger.cpp.

References m_groupOpened, and m_theLog.

Referenced by PNS::SHOVE::onCollidingLine(), PNS::SHOVE::onCollidingSegment(), PNS::SHOVE::onCollidingSolid(), PNS::SHOVE::onCollidingVia(), PNS::SHOVE::onReverseCollidingVia(), PNS::SHOVE::ShoveLines(), PNS::SHOVE::ShoveMultiLines(), and PNS::WALKAROUND::singleStep().

56 {
57  if( m_groupOpened )
58  m_theLog << "endgroup" << std::endl;
59 
60  m_theLog << "group " << aName << " " << aIter << std::endl;
61  m_groupOpened = true;
62 }
bool m_groupOpened
Definition: pns_logger.h:59
std::stringstream m_theLog
Definition: pns_logger.h:60
void PNS::LOGGER::Save ( const std::string &  aFilename)

Definition at line 197 of file pns_logger.cpp.

References EndGroup(), and m_theLog.

Referenced by PNS::ROUTER::DumpLog().

198 {
199  EndGroup();
200 
201  FILE* f = fopen( aFilename.c_str(), "wb" );
202  wxLogTrace( "PNS", "Saving to '%s' [%p]", aFilename.c_str(), f );
203  const std::string s = m_theLog.str();
204  fwrite( s.c_str(), 1, s.length(), f );
205  fclose( f );
206 }
std::stringstream m_theLog
Definition: pns_logger.h:60
void EndGroup()
Definition: pns_logger.cpp:65

Member Data Documentation

bool PNS::LOGGER::m_groupOpened
private

Definition at line 59 of file pns_logger.h.

Referenced by Clear(), EndGroup(), LOGGER(), and NewGroup().

std::stringstream PNS::LOGGER::m_theLog
private

Definition at line 60 of file pns_logger.h.

Referenced by Clear(), dumpShape(), EndGroup(), Log(), NewGroup(), and Save().


The documentation for this class was generated from the following files: