19 changed files with 451 additions and 8 deletions
-
23d-viewer/3d_cache/3d_cache.h
-
1163d-viewer/3d_rendering/3d_placeholder_utils.cpp
-
393d-viewer/3d_rendering/3d_placeholder_utils.h
-
13d-viewer/3d_rendering/opengl/create_scene.cpp
-
1833d-viewer/3d_rendering/opengl/render_3d_opengl.cpp
-
63d-viewer/3d_rendering/opengl/render_3d_opengl.h
-
593d-viewer/3d_rendering/raytracing/create_scene.cpp
-
23d-viewer/3d_rendering/raytracing/render_3d_raytrace_base.h
-
173d-viewer/3d_rendering/raytracing/shapes3D/dummy_block_3d.cpp
-
23d-viewer/3d_viewer/3d_menubar.cpp
-
63d-viewer/3d_viewer/eda_3d_viewer_frame.cpp
-
13d-viewer/3d_viewer/eda_3d_viewer_settings.cpp
-
13d-viewer/3d_viewer/eda_3d_viewer_settings.h
-
73d-viewer/3d_viewer/tools/eda_3d_actions.cpp
-
13d-viewer/3d_viewer/tools/eda_3d_actions.h
-
103d-viewer/3d_viewer/tools/eda_3d_controller.cpp
-
13d-viewer/3d_viewer/tools/eda_3d_controller.h
-
13d-viewer/CMakeLists.txt
-
43d-viewer/dialogs/panel_preview_3d_model.cpp
@ -0,0 +1,116 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#include "3d_placeholder_utils.h"
|
|||
|
|||
#include <footprint.h>
|
|||
#include <pad.h>
|
|||
#include <board_item.h>
|
|||
#include <layer_ids.h>
|
|||
#include <geometry/eda_angle.h>
|
|||
|
|||
|
|||
BOX2I CalcPlaceholderLocalBox( const FOOTPRINT* aFootprint ) |
|||
{ |
|||
BOX2I localBox; |
|||
bool hasLocalBounds = false; |
|||
|
|||
for( PAD* pad : aFootprint->Pads() ) |
|||
{ |
|||
VECTOR2I padPos = pad->GetFPRelativePosition(); |
|||
VECTOR2I padSize = pad->GetSize( PADSTACK::ALL_LAYERS ); |
|||
|
|||
BOX2I padBox; |
|||
padBox.SetOrigin( padPos - padSize / 2 ); |
|||
padBox.SetSize( padSize ); |
|||
|
|||
if( !hasLocalBounds ) |
|||
{ |
|||
localBox = padBox; |
|||
hasLocalBounds = true; |
|||
} |
|||
else |
|||
{ |
|||
localBox.Merge( padBox ); |
|||
} |
|||
} |
|||
|
|||
if( !hasLocalBounds ) |
|||
{ |
|||
VECTOR2I fpPos = aFootprint->GetPosition(); |
|||
EDA_ANGLE fpAngle = aFootprint->GetOrientation(); |
|||
|
|||
for( BOARD_ITEM* item : aFootprint->GraphicalItems() ) |
|||
{ |
|||
PCB_LAYER_ID layer = item->GetLayer(); |
|||
|
|||
if( layer == F_Fab || layer == B_Fab || layer == F_CrtYd || layer == B_CrtYd || layer == F_SilkS |
|||
|| layer == B_SilkS ) |
|||
{ |
|||
BOX2I itemBox = item->GetBoundingBox(); |
|||
|
|||
VECTOR2I corners[4] = { itemBox.GetOrigin() - fpPos, |
|||
VECTOR2I( itemBox.GetRight(), itemBox.GetTop() ) - fpPos, |
|||
VECTOR2I( itemBox.GetRight(), itemBox.GetBottom() ) - fpPos, |
|||
VECTOR2I( itemBox.GetLeft(), itemBox.GetBottom() ) - fpPos }; |
|||
|
|||
BOX2I localItemBox; |
|||
|
|||
for( int ci = 0; ci < 4; ++ci ) |
|||
{ |
|||
RotatePoint( corners[ci], -fpAngle ); |
|||
|
|||
if( ci == 0 ) |
|||
{ |
|||
localItemBox.SetOrigin( corners[ci] ); |
|||
localItemBox.SetSize( VECTOR2I( 0, 0 ) ); |
|||
} |
|||
else |
|||
{ |
|||
localItemBox.Merge( BOX2I( corners[ci], VECTOR2I( 0, 0 ) ) ); |
|||
} |
|||
} |
|||
|
|||
if( !hasLocalBounds ) |
|||
{ |
|||
localBox = localItemBox; |
|||
hasLocalBounds = true; |
|||
} |
|||
else |
|||
{ |
|||
localBox.Merge( localItemBox ); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
if( !hasLocalBounds ) |
|||
{ |
|||
BOX2I fpBox = aFootprint->GetBoundingBox( false ); |
|||
int size = std::min( fpBox.GetWidth(), fpBox.GetHeight() ); |
|||
localBox.SetOrigin( VECTOR2I( -size / 2, -size / 2 ) ); |
|||
localBox.SetSize( VECTOR2I( size, size ) ); |
|||
} |
|||
|
|||
return localBox; |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
* or you may search the http://www.gnu.org website for the version 2 license, |
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#ifndef PLACEHOLDER_3D_UTILS_H |
|||
#define PLACEHOLDER_3D_UTILS_H |
|||
|
|||
#include <math/box2.h> |
|||
|
|||
class FOOTPRINT; |
|||
|
|||
/** |
|||
* Calculate a local space bounding box for a placeholder 3D model. |
|||
* |
|||
* Attempts pads first, then graphical items on fab/courtyard/silk layers, |
|||
* then falls back to the footprint bounding box. |
|||
*/ |
|||
BOX2I CalcPlaceholderLocalBox( const FOOTPRINT* aFootprint ); |
|||
|
|||
#endif // PLACEHOLDER_3D_UTILS_H |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue