KiCad PCB EDA Suite
cobject2d.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
5  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #include "cobject2d.h"
31 #include <cstdio>
32 
33 
35 
36 
37 COBJECT2D::COBJECT2D( OBJECT2D_TYPE aObjType, const BOARD_ITEM &aBoardItem )
38  : m_boardItem(aBoardItem)
39 {
40  m_obj_type = aObjType;
41  COBJECT2D_STATS::Instance().AddOne( aObjType );
42 }
43 
44 
45 /*
46  * Lookup table for OBJECT2D_TYPE printed names
47  */
48 // clang-format off
49 const std::map<OBJECT2D_TYPE, const char*> objectTypeNames
50 {
51  { OBJECT2D_TYPE::FILLED_CIRCLE, "OBJECT2D_TYPE::FILLED_CIRCLE" },
52  { OBJECT2D_TYPE::CSG, "OBJECT2D_TYPE::CSG" },
53  { OBJECT2D_TYPE::POLYGON, "OBJECT2D_TYPE::POLYGON" },
54  { OBJECT2D_TYPE::DUMMYBLOCK, "OBJECT2D_TYPE::DUMMYBLOCK" },
55  { OBJECT2D_TYPE::POLYGON4PT, "OBJECT2D_TYPE::POLYGON4PT" },
56  { OBJECT2D_TYPE::RING, "OBJECT2D_TYPE::RING" },
57  { OBJECT2D_TYPE::ROUNDSEG, "OBJECT2D_TYPE::ROUNDSEG" },
58  { OBJECT2D_TYPE::TRIANGLE, "OBJECT2D_TYPE::TRIANGLE" },
59  { OBJECT2D_TYPE::CONTAINER, "OBJECT2D_TYPE::CONTAINER" },
60  { OBJECT2D_TYPE::BVHCONTAINER, "OBJECT2D_TYPE::BVHCONTAINER" },
61 };
62 // clang-format on
63 
64 
66 {
67  printf( "OBJ2D Statistics:\n" );
68 
69  for( auto& objectType : objectTypeNames )
70  {
71  printf( " %20s %u\n", objectType.second,
72  m_counter[static_cast<int>( objectType.first )] );
73  }
74 }
const std::map< OBJECT2D_TYPE, const char * > objectTypeNames
Definition: cobject2d.cpp:50
void PrintStats()
Definition: cobject2d.cpp:65
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
unsigned int m_counter[static_cast< int >(OBJECT2D_TYPE::MAX)]
Definition: cobject2d.h:167
void AddOne(OBJECT2D_TYPE aObjType)
Definition: cobject2d.h:145
COBJECT2D(OBJECT2D_TYPE aObjType, const BOARD_ITEM &aBoardItem)
Definition: cobject2d.cpp:37
static COBJECT2D_STATS & Instance()
Definition: cobject2d.h:152
OBJECT2D_TYPE m_obj_type
Definition: cobject2d.h:67
OBJECT2D_TYPE
Definition: cobject2d.h:46
static COBJECT2D_STATS * s_instance
Definition: cobject2d.h:169
Implements a class for object statistics using Singleton pattern.
Definition: cobject2d.h:132