KiCad PCB EDA Suite
cobject.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-2020 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 "cobject.h"
31 #include <cstdio>
32 #include <map>
33 
34 
36 
38 
40 {
41  m_obj_type = aObjType;
42  COBJECT3D_STATS::Instance().AddOne( aObjType );
44  m_modelTransparency = 0.0f;
45 }
46 
47 
48 /*
49  * Lookup table for OBJECT2D_TYPE printed names
50  */
51 // clang-format off
52 const std::map<OBJECT3D_TYPE, const char*> objectTypeNames
53 {
54  { OBJECT3D_TYPE::CYLINDER, "OBJECT3D_TYPE::CYLINDER" },
55  { OBJECT3D_TYPE::DUMMYBLOCK, "OBJECT2D_TYPE::DUMMYBLOCK" },
56  { OBJECT3D_TYPE::LAYERITEM, "OBJECT2D_TYPE::LAYERITEM" },
57  { OBJECT3D_TYPE::XYPLANE, "OBJECT2D_TYPE::XYPLANE" },
58  { OBJECT3D_TYPE::ROUNDSEG, "OBJECT2D_TYPE::ROUNDSEG" },
59  { OBJECT3D_TYPE::TRIANGLE, "OBJECT2D_TYPE::TRIANGLE" }
60 };
61 // clang-format on
62 
63 
65 {
66  wxLogDebug( "OBJ3D Statistics:\n" );
67 
68  for( auto& objectType : objectTypeNames )
69  {
70  wxLogDebug( " %20s %u\n", objectType.second,
71  m_counter[static_cast<int>( objectType.first )] );
72  }
73 }
OBJECT3D_TYPE m_obj_type
Definition: cobject.h:55
const CMATERIAL * m_material
Definition: cobject.h:56
void PrintStats()
Definition: cobject.cpp:64
void AddOne(OBJECT3D_TYPE aObjType)
Definition: cobject.h:126
COBJECT(OBJECT3D_TYPE aObjType)
Definition: cobject.cpp:39
unsigned int m_counter[static_cast< int >(OBJECT3D_TYPE::MAX)]
Definition: cobject.h:148
Blinn Phong based material https://en.wikipedia.org/wiki/Blinn%E2%80%93Phong_shading_model.
Definition: cmaterial.h:318
float m_modelTransparency
Definition: cobject.h:60
static const CBLINN_PHONG_MATERIAL s_defaultMaterial
Definition: cobject.cpp:37
static COBJECT3D_STATS * s_instance
Definition: cobject.h:150
OBJECT3D_TYPE
Definition: cobject.h:38
static COBJECT3D_STATS & Instance()
Definition: cobject.h:133
const std::map< OBJECT3D_TYPE, const char * > objectTypeNames
Definition: cobject.cpp:53
Implements a class for object statistics using Singleton pattern.
Definition: cobject.h:113