KiCad PCB EDA Suite
object_3d.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 "object_3d.h"
31 #include <board_item.h>
32 #include "../hitinfo.h"
33 #include <map>
34 
35 
37 
39 
40 
42 {
43  m_obj_type = aObjType;
44  OBJECT_3D_STATS::Instance().AddOne( aObjType );
46  m_modelTransparency = 0.0f;
47  m_boardItem = nullptr;
48 }
49 
50 
51 /*
52  * Lookup table for OBJECT_2D_TYPE printed names
53  */
54 // clang-format off
55 const std::map<OBJECT_3D_TYPE, const char*> objectTypeNames
56 {
57  { OBJECT_3D_TYPE::CYLINDER, "OBJECT_3D_TYPE::CYLINDER" },
58  { OBJECT_3D_TYPE::DUMMYBLOCK, "OBJECT_3D_TYPE::DUMMY_BLOCK" },
59  { OBJECT_3D_TYPE::LAYERITEM, "OBJECT_3D_TYPE::LAYER_ITEM" },
60  { OBJECT_3D_TYPE::XYPLANE, "OBJECT_3D_TYPE::XY_PLANE" },
61  { OBJECT_3D_TYPE::ROUNDSEG, "OBJECT_3D_TYPE::ROUND_SEG" },
62  { OBJECT_3D_TYPE::TRIANGLE, "OBJECT_3D_TYPE::TRIANGLE" }
63 };
64 // clang-format on
65 
66 
68 {
69  wxLogDebug( "OBJECT_3D_STATS:\n" );
70 
71  for( auto& objectType : objectTypeNames )
72  {
73  wxLogDebug( " %20s %u\n", objectType.second,
74  m_counter[static_cast<int>( objectType.first )] );
75  }
76 }
BOARD_ITEM * m_boardItem
Definition: object_3d.h:102
void PrintStats()
Definition: object_3d.cpp:67
float m_modelTransparency
Definition: object_3d.h:106
static OBJECT_3D_STATS * s_instance
Definition: object_3d.h:148
unsigned int m_counter[static_cast< int >(OBJECT_3D_TYPE::MAX)]
Definition: object_3d.h:146
Blinn Phong based material https://en.wikipedia.org/wiki/Blinn%E2%80%93Phong_shading_model.
Definition: material.h:382
OBJECT_3D(OBJECT_3D_TYPE aObjType)
Definition: object_3d.cpp:41
OBJECT_3D_TYPE m_obj_type
Definition: object_3d.h:99
static OBJECT_3D_STATS & Instance()
Definition: object_3d.h:132
Implements a class for object statistics using Singleton pattern.
Definition: object_3d.h:112
const MATERIAL * m_material
Definition: object_3d.h:100
static const BLINN_PHONG_MATERIAL s_defaultMaterial
Definition: object_3d.cpp:38
const std::map< OBJECT_3D_TYPE, const char * > objectTypeNames
Definition: object_3d.cpp:56
OBJECT_3D_TYPE
Definition: object_3d.h:38
void AddOne(OBJECT_3D_TYPE aObjType)
Definition: object_3d.h:125