KiCad PCB EDA Suite
Loading...
Searching...
No Matches
render_3d_raytrace_ram.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-2020 Mario Luzeiro <[email protected]>
5 * Copyright (C) 2024 Alex Shvartzkop <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
23#include <wx/log.h>
24
25
27 RENDER_3D_RAYTRACE_BASE( aAdapter, aCamera ),
28 m_outputBuffer( nullptr ),
29 m_pboDataSize( 0 )
30{
31}
32
33
38
39
44
45
50
51
53{
54 delete[] m_outputBuffer;
55 m_outputBuffer = nullptr;
56}
57
58
60{
61 if( m_windowSize != aSize )
62 {
63 m_windowSize = aSize;
64
65 initPbo();
66 }
67}
68
69
70bool RENDER_3D_RAYTRACE_RAM::Redraw( bool aIsMoving )
71{
72 bool requestRedraw = false;
73
74 // Initialize openGL if need
76 {
78
79 //aIsMoving = true;
80 requestRedraw = true;
81
82 // It will assign the first time the windows size, so it will now
83 // revert to preview mode the first time the Redraw is called
86 }
87
88 std::unique_ptr<BUSY_INDICATOR> busy = CreateBusyIndicator();
89
90 // Reload board if it was requested
92 {
94 m_activityReporter->Report( _( "Loading..." ) );
95
96 //aIsMoving = true;
97 requestRedraw = true;
98 Reload( false );
99 }
100
101
102 // Recalculate constants if windows size was changed
104 {
106 aIsMoving = true;
107 requestRedraw = true;
108
110 }
111
112 const bool was_camera_changed = m_camera.ParametersChanged();
113
114 if( requestRedraw || aIsMoving || was_camera_changed )
115 m_renderState = RT_RENDER_STATE_MAX; // Set to an invalid state,
116 // so it will restart again latter
117
118 // This will only render if need, otherwise it will redraw the PBO on the screen again
119 if( aIsMoving || was_camera_changed )
120 {
121 // Set head light (camera view light) with the opposite direction of the camera
122 if( m_cameraLight )
123 m_cameraLight->SetDirection( -m_camera.GetDir() );
124
125 if( m_outputBuffer )
126 {
128 }
129 }
130 else
131 {
133 {
134 if( m_outputBuffer )
135 {
137
139 requestRedraw = true;
140 }
141 }
142 }
143
144 return requestRedraw;
145}
146
147
Helper class to handle information needed to display 3D board.
A class used to derive camera objects from.
Definition camera.h:99
std::unique_ptr< BUSY_INDICATOR > CreateBusyIndicator() const
Return a created busy indicator, if a factory has been set, else a null pointer.
bool m_canvasInitialized
Flag if the canvas specific for this render was already initialized.
std::shared_ptr< REPORTER > m_activityReporter
wxSize m_windowSize
The window size that this camera is working.
RENDER_3D_RAYTRACE_BASE(BOARD_ADAPTER &aAdapter, CAMERA &aCamera)
RT_RENDER_STATE m_renderState
State used on quality render.
wxSize m_oldWindowsSize
Used to see if the windows size changed.
void renderPreview(uint8_t *ptrPBO)
void Reload(bool aOnlyLoadCopperAndShapes, std::stop_token aStop={})
RENDER_3D_RAYTRACE_RAM(BOARD_ADAPTER &aAdapter, CAMERA &aCamera)
bool Redraw(bool aIsMoving) override
Redraw the view.
void SetCurWindowSize(const wxSize &aSize) override
Before each render, the canvas will tell the render what is the size of its windows,...
#define _(s)
@ RT_RENDER_STATE_FINISH
@ RT_RENDER_STATE_MAX