25#include <wx/tokenzr.h>
27#include <fmt/format.h>
30#include <api/common/commands/cross_probe_commands.pb.h>
39#include <glm/gtc/type_ptr.hpp>
123 wxDefaultSize, wxFULL_REPAINT_ON_RESIZE ),
128 wxLogTrace(
m_logTrace, wxT(
"EDA_3D_CANVAS::EDA_3D_CANVAS" ) );
143 auto busy_indicator_factory =
146 return std::make_unique<WX_BUSY_INDICATOR>();
158 wxASSERT( a3DCachePointer !=
nullptr );
161#if defined( __WXMSW__ )
162 EnableTouchEvents( wxTOUCH_ZOOM_GESTURE | wxTOUCH_ROTATE_GESTURE | wxTOUCH_PAN_GESTURES );
163#elif defined( __WXGTK__ )
164 EnableTouchEvents( wxTOUCH_ZOOM_GESTURE | wxTOUCH_ROTATE_GESTURE );
167 const wxEventType events[] =
173 wxEVT_LEFT_UP, wxEVT_LEFT_DOWN, wxEVT_LEFT_DCLICK,
174 wxEVT_RIGHT_UP, wxEVT_RIGHT_DOWN, wxEVT_RIGHT_DCLICK,
175 wxEVT_MIDDLE_UP, wxEVT_MIDDLE_DOWN, wxEVT_MIDDLE_DCLICK,
176 wxEVT_MOTION, wxEVT_MOUSEWHEEL, wxEVT_CHAR, wxEVT_CHAR_HOOK,
178 wxEVT_MENU_OPEN, wxEVT_MENU_CLOSE, wxEVT_MENU_HIGHLIGHT
181 for( wxEventType eventType : events )
188 wxLogTrace(
m_logTrace, wxT(
"EDA_3D_CANVAS::~EDA_3D_CANVAS" ) );
220 std::optional<ORPHANED_GL_OBJECTS> orphaned;
256 wxLogTrace(
m_logTrace, wxT(
"EDA_3D_CANVAS::initializeOpenGL" ) );
260 const int glVersion = gladLoaderLoadGL();
264 wxLogMessage( wxT(
"Failed to load OpenGL via loader" ) );
270 wxLogTrace(
m_logTrace, wxT(
"EDA_3D_CANVAS::initializeOpenGL Using OpenGL version %s" ),
271 From_UTF8( (
char*) glGetString( GL_VERSION ) ) );
274 SetOpenGLInfo( (
const char*) glGetString( GL_VENDOR ), (
const char*) glGetString( GL_RENDERER ),
275 (
const char*) glGetString( GL_VERSION ) );
277 wxString version =
From_UTF8( (
char *) glGetString( GL_VERSION ) );
279 wxLogTrace(
m_logTrace, wxT(
"EDA_3D_CANVAS::%s OpenGL version string %s." ),
280 __WXFUNCTION__, version );
286 wxStringTokenizer tokenizer( version,
" \t\r\n" );
288 if( tokenizer.HasMoreTokens() )
293 tmp = tokenizer.GetNextToken();
295 tokenizer.SetString( tmp, wxString( wxT(
"." ) ) );
297 if( tokenizer.HasMoreTokens() )
298 tokenizer.GetNextToken().ToLong( &major );
300 if( tokenizer.HasMoreTokens() )
301 tokenizer.GetNextToken().ToLong( &minor );
303 if( major < 2 || ( ( major == 2 ) && ( minor < 1 ) ) )
305 wxLogTrace(
m_logTrace, wxT(
"EDA_3D_CANVAS::%s OpenGL ray tracing not supported." ),
311 GetParent()->ProcessWindowEvent( evt );
317 if( ( major == 1 ) && ( minor < 5 ) )
319 wxLogTrace(
m_logTrace, wxT(
"EDA_3D_CANVAS::%s OpenGL not supported." ),
326#if wxCHECK_VERSION( 3, 3, 3 )
327 wxGLCanvas::SetSwapInterval( -1 );
356 if( aCachePointer !=
nullptr )
359 if( aBoard !=
nullptr )
402 msg.Printf( wxT(
"dx %3.2f" ),
m_camera.GetCameraPos().x );
405 msg.Printf( wxT(
"dy %3.2f" ),
m_camera.GetCameraPos().y );
408 msg.Printf( wxT(
"zoom %3.2f" ), 1 /
m_camera.GetZoom() );
428 if( !IsShownOnScreen() )
430 wxLogTrace(
m_logTrace, wxT(
"EDA_3D_CANVAS::DoRePaint !IsShown" ) );
441 wxWindow* viewer = wxGetTopLevelParent(
this );
442 wxWindow* owner = viewer ? viewer->GetParent() :
nullptr;
444 if( owner && !owner->IsShownOnScreen() )
466 wxString err_messages;
467 auto start_time = std::chrono::steady_clock::now();
503 const bool windows_size_changed =
m_camera.SetCurWindowSize( clientSize );
527 glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
528 glClear( GL_COLOR_BUFFER_BIT );
549 const bool was_camera_changed =
m_camera.ParametersChanged();
554 || windows_size_changed )
562 float curtime_delta_s = 0.0f;
568 curtime_delta_s =
static_cast<float>(
static_cast<double>( curtime_delta ) / 1e6 )
570 m_camera.Interpolate( curtime_delta_s );
572 if( curtime_delta_s > 1.0f )
588 bool requested_redraw =
false;
598 catch( std::runtime_error& )
633 const double calculation_time =
634 std::chrono::duration<double, std::milli>( std::chrono::steady_clock::now() - start_time ).count();
638 m_parentStatusBar->SetStatusText( wxString::Format(
_(
"Last render time %.0f ms" ), calculation_time ),
648 if( !err_messages.IsEmpty() )
649 wxLogMessage( err_messages );
662 int index =
static_cast<int>( selectedGizmoSphere );
663 if(
index >= 0 &&
index <
static_cast<int>( viewTable.size() ) )
680 if( !buffer || width <= 0 || height <= 0 )
688 if( !GetParent() || !GetParent()->GetParent() || !GetParent()->GetParent()->IsShownOnScreen() )
694 wxString err_messages;
710 wxLogError(
_(
"OpenGL context creation error" ) );
718 GLuint framebuffer = 0;
719 GLuint colorTexture = 0;
720 GLuint depthStencilBuffer = 0;
721 GLint oldFramebuffer = 0;
722 GLint oldViewport[4];
725 glGetIntegerv( GL_FRAMEBUFFER_BINDING, &oldFramebuffer );
726 glGetIntegerv( GL_VIEWPORT, oldViewport );
729 glGenFramebuffers( 1, &framebuffer );
730 glBindFramebuffer( GL_FRAMEBUFFER, framebuffer );
733 glGenTextures( 1, &colorTexture );
734 glBindTexture( GL_TEXTURE_2D, colorTexture );
735 glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr );
736 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
737 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
738 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
739 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
740 glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTexture, 0 );
745 glGenRenderbuffers( 1, &depthStencilBuffer );
746 glBindRenderbuffer( GL_RENDERBUFFER, depthStencilBuffer );
747 glRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height );
748 glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
749 depthStencilBuffer );
751 auto resetState = std::unique_ptr<void, std::function<void(
void*)>>(
752 reinterpret_cast<void*
>(1),
754 glBindFramebuffer( GL_FRAMEBUFFER, oldFramebuffer );
755 glViewport( oldViewport[0], oldViewport[1], oldViewport[2], oldViewport[3] );
756 glDeleteFramebuffers( 1, &framebuffer );
757 glDeleteTextures( 1, &colorTexture );
758 glDeleteRenderbuffers( 1, &depthStencilBuffer );
765 GLenum framebufferStatus = glCheckFramebufferStatus( GL_FRAMEBUFFER );
767 if( framebufferStatus != GL_FRAMEBUFFER_COMPLETE )
769 wxLogTrace(
m_logTrace, wxT(
"EDA_3D_CANVAS::RenderToFrameBuffer Framebuffer incomplete: 0x%04X" ),
776 glViewport( 0, 0, width, height );
779 wxSize clientSize( width, height );
780 const bool windows_size_changed =
m_camera.SetCurWindowSize( clientSize );
787 wxLogTrace(
m_logTrace, wxT(
"EDA_3D_CANVAS::RenderToFrameBuffer OpenGL initialization failed." ) );
793 wxLogTrace(
m_logTrace, wxT(
"EDA_3D_CANVAS::RenderToFrameBuffer OpenGL version not supported." ) );
799 glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
800 glClear( GL_COLOR_BUFFER_BIT );
803 glReadPixels( 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer );
817 const bool was_camera_changed =
m_camera.ParametersChanged();
828 float curtime_delta_s = 0.0f;
832 curtime_delta_s =
static_cast<float>(
static_cast<double>( curtime_delta ) / 1e6 )
834 m_camera.Interpolate( curtime_delta_s );
836 if( curtime_delta_s > 1.0f )
859 catch( std::runtime_error& )
871 glReadPixels( 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer );
874 GLenum error = glGetError();
875 if( error != GL_NO_ERROR )
877 wxLogTrace(
m_logTrace, wxT(
"EDA_3D_CANVAS::RenderToFrameBuffer OpenGL error: 0x%04X" ), error );
878 err_messages += wxString::Format(
_(
"OpenGL error during off-screen rendering: 0x%04X\n" ), error );
884 if( !err_messages.IsEmpty() )
885 wxLogMessage( err_messages );
908 wxLogTrace(
m_logTrace, wxT(
"EDA_3D_CANVAS::OnEraseBackground" ) );
915 wxLogTrace(
m_logTrace, wxT(
"EDA_3D_CANVAS::OnMouseWheel" ) );
938 float magnification = (
event.GetMagnification() + 1.0f );
951 if( aEvent.IsGestureStart() )
954 m_camera.SetCurMousePosition( aEvent.GetPosition() );
962 m_camera.Pan( aEvent.GetPosition() );
963 m_camera.SetCurMousePosition( aEvent.GetPosition() );
978 if( aEvent.IsGestureStart() )
979 m_camera.SetCurMousePosition( aEvent.GetPosition() );
984 m_camera.Pan( aEvent.GetPosition() );
985 m_camera.SetCurMousePosition( aEvent.GetPosition() );
996 if( aEvent.IsGestureStart() )
999 m_camera.SetCurMousePosition( aEvent.GetPosition() );
1037 if( !event.Dragging() )
1052 return wxString::Format(
_(
"Net %s\tNet class %s" ), aItem->GetNet()->GetNetname(),
1053 aItem->GetNet()->GetNetClass()->GetHumanReadableName() );
1068 switch( rollOverItem->
Type() )
1072 PAD*
pad =
static_cast<PAD*
>( rollOverItem );
1074 if( !
pad->GetNumber().IsEmpty() )
1075 msg += wxString::Format(
_(
"Pad %s\t" ),
pad->GetNumber() );
1077 if(
pad->IsOnCopperLayer() )
1078 msg += printNetInfo(
pad );
1095 msg += printNetInfo( track );
1101 ZONE* zone =
static_cast<ZONE*
>( rollOverItem );
1106 msg += wxString::Format(
_(
"Rule area %s\t" ), zone->
GetZoneName() );
1108 msg += wxString::Format(
_(
"Zone %s\t" ), zone->
GetZoneName() );
1112 msg += printNetInfo( zone );
1177 bool gizmoClicked =
false;
1182 wxSize logicalSize = GetClientSize();
1183 int logicalW = logicalSize.GetWidth();
1184 int logicalH = logicalSize.GetHeight();
1186 int gizmo_x = 0, gizmo_y = 0, gizmo_width = 0, gizmo_height = 0;
1187 std::tie( gizmo_x, gizmo_y, gizmo_width, gizmo_height ) =
m_3d_render_opengl->getGizmoViewport();
1189 float scaleX =
static_cast<float>(
static_cast<double>( gizmo_width ) /
static_cast<double>( logicalW ) );
1190 float scaleY =
static_cast<float>(
static_cast<double>( gizmo_height ) /
static_cast<double>( logicalH ) );
1192 int scaledMouseX =
static_cast<int>(
static_cast<float>(
event.GetX() ) * scaleX );
1193 int scaledMouseY =
static_cast<int>(
static_cast<float>( logicalH -
event.GetY() ) * scaleY );
1222 if( intersectedBoardItem )
1224 switch( intersectedBoardItem->
Type() )
1228 case PCB_PAD_T: footprint =
static_cast<PAD*
>( intersectedBoardItem )->GetParentFootprint();
break;
1230 case PCB_FIELD_T: footprint =
static_cast<PCB_FIELD*
>( intersectedBoardItem )->GetParentFootprint();
break;
1241 kiapi::common::commands::SyncSelection sync;
1244 sync.add_items()->mutable_footprint()->set_reference( footprint->
GetReference().ToUTF8() );
1246 sync.set_mode( kiapi::common::commands::SyncSelectionMode::SSM_ITEMS_ONLY );
1247 sync.set_context( kiapi::common::commands::SyncSelectionContext::SSC_IMPLICIT );
1249 std::string payload;
1356 if( aRedrawImmediately )
1363 wxPostEvent(
this, redrawEvent );
1375 wxASSERT( aMovingSpeed > FLT_EPSILON );
1415 m_camera.SetLookAtPos_T1( mouseRay.
at( hit_t ) );
1429 const float arrow_moving_time_speed = 8.0f;
1431 switch( aRequestedView )
1497 m_camera.ViewCommand_T1( aRequestedView );
1505 m_camera.ViewCommand_T1( aRequestedView );
1519 switch( cfg->m_Render.engine )
1541 glMatrixMode( GL_PROJECTION );
1542 glLoadMatrixf( glm::value_ptr(
m_camera.GetProjectionMatrix() ) );
1544 glMatrixMode( GL_MODELVIEW );
1545 glLoadMatrixf( glm::value_ptr(
m_camera.GetViewMatrix() ) );
1547 glDisable( GL_LIGHTING );
1548 glDisable( GL_CULL_FACE );
1549 glEnable( GL_COLOR_MATERIAL );
1550 glEnable( GL_BLEND );
1551 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1552 glDepthMask( GL_FALSE );
1553 glEnable( GL_POLYGON_OFFSET_FILL );
1554 glPolygonOffset( -2.0f, -2.0f );
1556 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
1557 glDisableClientState( GL_COLOR_ARRAY );
1558 glDisableClientState( GL_NORMAL_ARRAY );
1559 glEnableClientState( GL_VERTEX_ARRAY );
1566 if(
overlay.vertices.empty() )
1569 if( depthUsable && !
overlay.alwaysVisible )
1570 glEnable( GL_DEPTH_TEST );
1572 glDisable( GL_DEPTH_TEST );
1575 glMultMatrixf( glm::value_ptr(
overlay.transform ) );
1577 glVertexPointer( 3, GL_FLOAT, 0,
overlay.vertices.data() );
1578 glDrawArrays( GL_TRIANGLES, 0, (GLsizei)
overlay.vertices.size() );
1582 glDisableClientState( GL_VERTEX_ARRAY );
1583 glDisable( GL_POLYGON_OFFSET_FILL );
1584 glDepthMask( GL_TRUE );
1585 glDisable( GL_BLEND );
1586 glEnable( GL_DEPTH_TEST );
1598 const double determinant = glm::determinant( glm::dmat4( world ) );
1600 if( !aGeometry.
m_Meshes || !std::isfinite( determinant ) || determinant == 0.0 )
1601 return std::nullopt;
1603 const glm::dmat4 inverse = glm::inverse( glm::dmat4( world ) );
1604 const glm::dvec3 origin( inverse * glm::dvec4( aRay.
m_Origin, 1.0 ) );
1605 const glm::dvec3 direction( inverse * glm::dvec4( aRay.
m_Dir, 0.0 ) );
1606 double nearest = std::numeric_limits<double>::infinity();
1607 std::optional<MODEL_HIT> hit;
1609 for(
unsigned int i = 0; i < aGeometry.
m_MeshesSize; ++i )
1616 for(
unsigned int j = 0; j + 2 < mesh.
m_FaceIdxSize; j += 3 )
1624 const glm::dvec3 p = glm::cross( direction, edge2 );
1625 const double det = glm::dot( edge1, p );
1626 const double tolerance = 1e-12 * glm::length( edge1 ) * glm::length( p );
1628 if( !std::isfinite( det ) ||
std::abs( det ) <= tolerance )
1631 const glm::dvec3
delta = origin - a;
1632 const double u = glm::dot(
delta, p ) / det;
1633 const glm::dvec3 q = glm::cross(
delta, edge1 );
1634 const double v = glm::dot( direction, q ) / det;
1635 const double distance = glm::dot( edge2, q ) / det;
1637 if( u >= 0.0 && v >= 0.0 && u + v <= 1.0 && distance >= 0.0 &&
distance < nearest )
1661 if(
distance < 0.0 || !std::isfinite( x ) || !std::isfinite( y )
1662 ||
std::abs( x ) > std::numeric_limits<int>::max()
1663 ||
std::abs( y ) > std::numeric_limits<int>::max() )
1673 if(
pad->HitTest( point, 0, copper ) )
1687 m_camera.MakeRayAtCurrentMousePosition( rayOrigin, rayDir );
1690 mouseRay.
Init( rayOrigin, rayDir );
glm::mat4 CalcModelMatrix(const SFVEC3F &aOffset, const SFVEC3F &aRotation, const SFVEC3F &aScale)
Build the model-to-footprint transform used by rendering and picking.
Defines math related functions.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
void SetOpenGLInfo(const char *aVendor, const char *aRenderer, const char *aVersion)
A setter for OpenGL info when it's initialized.
void SetOpenGLBackendInfo(wxString aBackend)
A setter for OpenGL backend info after the canvas is created.
define an internal structure to be used by the 3D renders
bool IsTriangleInRange(const unsigned int *aFaceIdx, unsigned int aTriangleIdx, unsigned int aVertexCount)
Test whether the three face indices of a triangle all reference valid vertices.
Helper class to handle information needed to display 3D board.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
A class used to derive camera objects from.
Implement a canvas based on a wxGLCanvas.
TOOL_DISPATCHER * m_eventDispatcher
void OnEvent(wxEvent &aEvent)
Used to forward events to the canvas from popups, etc.
void OnMagnify(wxMouseEvent &event)
void restart_editingTimeOut_Timer()
Reset the editing timer.
void RenderToFrameBuffer(unsigned char *aBuffer, int aWidth, int aHeight)
BOARD_ITEM * m_currentRollOverItem
RENDER_3D_BASE * m_3d_render
Non-owning pointer to the active renderer (one of the two below).
std::function< void(const std::optional< RAY > &)> m_hoverHandler
bool m_is_opengl_initialized
void OnResize(wxSizeEvent &event)
bool m_render3dmousePivot
void OnMouseWheel(wxMouseEvent &event)
WX_INFOBAR * m_parentInfoBar
wxTimer m_editing_timeout_timer
int64_t m_strtime_camera_movement
void render_overlays()
Draw the translucent overlays over the rendered scene.
void OnLeftDown(wxMouseEvent &event)
void OnPanGesture(wxPanGestureEvent &event)
void OnRightUp(wxMouseEvent &event)
ACCELERATOR_3D * m_accelerator3DShapes
std::function< bool(const RAY &)> m_pickHandler
void OnTimerTimeout_Redraw(wxTimerEvent &event)
wxStatusBar * m_parentStatusBar
void DoRePaint()
The actual function to repaint the canvas.
std::shared_ptr< SYNC_REPORTER > m_warningReporterSync
void OnRightDown(wxMouseEvent &event)
void InvalidateRaytracingHitTesting()
Invalidate the hover hit-test BVH before board layers are rebuilt.
int m_moving_speed_multiplier
void JoinBgWorker()
Block until any in-progress OpenGL background loading has finished.
bool m_is_opengl_version_supported
wxTimer m_redraw_trigger_timer
BOARD_ADAPTER & m_boardAdapter
void DisplayStatus()
Update the status bar with the position information.
void render3dmousePivot(float aScale)
Render the 3dmouse pivot cursor.
void OnPaint(wxPaintEvent &aEvent)
std::vector< OVERLAY > m_overlays
void RenderRaytracingRequest()
Request to render the current view in Raytracing mode.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
std::optional< MODEL_HIT > PickModel(const RAY &aRay, const S3DMODEL &aGeometry, const FP_3DMODEL &aModel, const FOOTPRINT &aFootprint) const
Pick current mesh geometry; independent of the renderer's cached hit-test scene.
bool m_render_raytracing_was_requested
float m_camera_moving_speed
void ReloadRaytracingForHitTesting(std::stop_token aStop)
Rebuild the auxiliary raytracing BVH used for hover hit-testing in OpenGL mode.
PAD * PickFootprintPad(const RAY &aRay, const FOOTPRINT &aFootprint) const
Project onto the footprint's seating plane and hit-test copper pads.
void OnLeftUp(wxMouseEvent &event)
void ReloadRequest(BOARD *aBoard=nullptr, S3D_CACHE *aCachePointer=nullptr)
RAY getRayAtCurrentMousePosition()
double m_gestureLastZoomFactor
Used to track gesture events.
void OnCloseWindow(wxCloseEvent &event)
bool SetView3D(VIEW3D_TYPE aRequestedView)
Select a specific 3D view or operation.
void OnMiddleDown(wxMouseEvent &event)
void GetScreenshot(wxImage &aDstImage)
Request a screenshot and output it to the aDstImage.
std::unique_ptr< INFOBAR_REPORTER > m_infoBarReporter
void OnZoomGesture(wxZoomGestureEvent &event)
std::unique_ptr< STATUSBAR_REPORTER > m_statusBarReporter
std::unique_ptr< RENDER_3D_OPENGL > m_3d_render_opengl
void OnMiddleUp(wxMouseEvent &event)
void render_pivot(float t, float aScale)
Render the pivot cursor.
void request_start_moving_camera(float aMovingSpeed=2.0f, bool aRenderPivot=true)
Start a camera movement.
void RenderEngineChanged()
Notify that the render engine was changed.
std::shared_ptr< SYNC_REPORTER > m_activityReporterSync
void OnMouseLeave(wxMouseEvent &event)
std::atomic_flag m_is_currently_painting
void OnRefreshRequest(wxEvent &aEvent)
void OnEraseBackground(wxEraseEvent &event)
void releaseOpenGL()
Free created targets and openGL context.
std::unique_ptr< RENDER_3D_RAYTRACE_GL > m_3d_render_raytracing
void Request_refresh(bool aRedrawImmediately=true)
Schedule a refresh update of the canvas.
bool m_opengl_supports_raytracing
~EDA_3D_CANVAS() override
void OnMouseMove(wxMouseEvent &event)
void OnRotateGesture(wxRotateGestureEvent &event)
EDA_3D_CANVAS(wxWindow *aParent, const wxGLAttributes &aGLAttribs, BOARD_ADAPTER &aSettings, CAMERA &aCamera, S3D_CACHE *a3DCachePointer)
Create a new 3D Canvas with an attribute list.
void move_pivot_based_on_cur_mouse_position()
This function hits a ray to the board and start a movement.
double m_gestureLastAngle
void OnTimerTimeout_Editing(wxTimerEvent &event)
void stop_editingTimeOut_Timer()
Stop the editing time so it will not timeout.
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
KICAD_T Type() const
Returns the type of object.
VECTOR3D m_Offset
3D model offset (mm)
VECTOR3D m_Rotation
3D model rotation (degrees)
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
void UnlockCtx(wxGLContext *aContext)
Allow other canvases to bind an OpenGL context.
void DestroyCtx(wxGLContext *aContext)
Destroy a managed OpenGL context.
bool LockCtx(wxGLContext *aContext, wxGLCanvas *aCanvas)
Set a context as current and prevents other canvases from switching it.
wxGLContext * CreateCtx(wxGLCanvas *aCanvas, const wxGLContext *aOther=nullptr)
Create a managed OpenGL context.
static int SetSwapInterval(wxGLCanvas *aCanvas, int aVal)
Attempt to set the OpenGL swap interval.
static wxString DetectGLBackend(wxGLCanvas *aCanvas)
Provides basic 3D controls ( zoom, rotate, translate, ... )
static const float m_delta_move_step_factor
HIDPI_GL_3D_CANVAS(const KIGFX::VC_SETTINGS &aVcSettings, CAMERA &aCamera, wxWindow *parent, const wxGLAttributes &aGLAttribs, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxGLCanvasName, const wxPalette &palette=wxNullPalette)
void OnMouseWheelCamera(wxMouseEvent &event, bool aPan)
void OnMouseMoveCamera(wxMouseEvent &event)
virtual wxSize GetNativePixelSize() const
GL_CONTEXT_MANAGER * GetGLContextManager()
Cache for storing the 3D shapes.
GizmoSphereSelection
Enum to indicate which sphere (direction) is selected.
@ None
No sphere selected.
@ Count
Number of selectable spheres.
A wrapper for reporting to a specific text location in a statusbar.
Handle a list of polygons defining a copper zone.
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
const wxString & GetZoneName() const
bool IsOnCopperLayer() const override
wxDEFINE_EVENT(wxEVT_REFRESH_CUSTOM_COMMAND, wxCommandEvent)
Declaration of the eda_3d_viewer class.
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
static wxString From_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
KICOMMON_API bool PackKiwayApiMessage(const google::protobuf::Message &aMessage, std::string &aBytes)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
void OglGetScreenshot(wxImage &aDstImage)
Get the pixel data of current OpenGL image.
Define generic OpenGL functions that are common to any OpenGL target.
PGM_BASE & Pgm()
The global program "get" accessor.
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > overlay
int64_t GetRunningMicroSecs()
An alternate way to calculate an elapsed time (in microsecondes) to class PROF_COUNTER.
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
T * GetAppSettings(const char *aFilename)
A translucent triangle soup drawn over the scene.
void Init(const SFVEC3F &o, const SFVEC3F &d)
SFVEC3F at(float t) const
Store the a model based on meshes and materials.
unsigned int m_MeshesSize
Number of meshes in the array.
SMESH * m_Meshes
The meshes list of this model.
Per-vertex normal/color/texcoors structure.
unsigned int * m_FaceIdx
Triangle Face Indexes.
unsigned int m_VertexSize
Number of vertex in the arrays.
unsigned int m_FaceIdxSize
Number of elements of the m_FaceIdx array.
SFVEC3F * m_Positions
Vertex position array.
IbisParser parser & reporter
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
VECTOR2< int32_t > VECTOR2I