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, REPORTER* aStatusReporter,
71 REPORTER* aWarningReporter )
72{
73 bool requestRedraw = false;
74
75 // Initialize openGL if need
77 {
79
80 //aIsMoving = true;
81 requestRedraw = true;
82
83 // It will assign the first time the windows size, so it will now
84 // revert to preview mode the first time the Redraw is called
87 }
88
89 std::unique_ptr<BUSY_INDICATOR> busy = CreateBusyIndicator();
90
91 // Reload board if it was requested
93 {
94 if( aStatusReporter )
95 aStatusReporter->Report( _( "Loading..." ) );
96
97 //aIsMoving = true;
98 requestRedraw = true;
99 Reload( aStatusReporter, aWarningReporter, false );
100 }
101
102
103 // Recalculate constants if windows size was changed
105 {
107 aIsMoving = true;
108 requestRedraw = true;
109
111 }
112
113 const bool was_camera_changed = m_camera.ParametersChanged();
114
115 if( requestRedraw || aIsMoving || was_camera_changed )
116 m_renderState = RT_RENDER_STATE_MAX; // Set to an invalid state,
117 // so it will restart again latter
118
119 // This will only render if need, otherwise it will redraw the PBO on the screen again
120 if( aIsMoving || was_camera_changed )
121 {
122 // Set head light (camera view light) with the opposite direction of the camera
123 if( m_cameraLight )
124 m_cameraLight->SetDirection( -m_camera.GetDir() );
125
126 if( m_outputBuffer )
127 {
129 }
130 }
131 else
132 {
134 {
135 if( m_outputBuffer )
136 {
137 render( m_outputBuffer, aStatusReporter );
138
140 requestRedraw = true;
141 }
142 }
143 }
144
145 return requestRedraw;
146}
147
148
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.
wxSize m_windowSize
The window size that this camera is working.
void Reload(REPORTER *aStatusReporter, REPORTER *aWarningReporter, bool aOnlyLoadCopperAndShapes)
RENDER_3D_RAYTRACE_BASE(BOARD_ADAPTER &aAdapter, CAMERA &aCamera)
void render(uint8_t *ptrPBO, REPORTER *aStatusReporter)
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)
RENDER_3D_RAYTRACE_RAM(BOARD_ADAPTER &aAdapter, CAMERA &aCamera)
bool Redraw(bool aIsMoving, REPORTER *aStatusReporter, REPORTER *aWarningReporter) 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,...
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:71
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Definition reporter.h:100
#define _(s)
@ RT_RENDER_STATE_FINISH
@ RT_RENDER_STATE_MAX