2016-07-19 17:35:25 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
|
|
|
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2018-12-08 13:20:32 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
2019-01-13 19:04:34 +00:00
|
|
|
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-07-19 17:35:25 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file eda_3d_viewer.h
|
|
|
|
* @brief Declaration of the eda_3d_viewer class
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EDA_3D_VIEWER_H
|
|
|
|
#define EDA_3D_VIEWER_H
|
|
|
|
|
|
|
|
#include "../3d_canvas/cinfo3d_visu.h"
|
|
|
|
#include "../3d_canvas/eda_3d_canvas.h"
|
|
|
|
#include <kiway_player.h>
|
|
|
|
#include <wx/colourdata.h>
|
2018-10-12 19:02:11 +00:00
|
|
|
#include <../common/dialogs/dialog_color_picker.h> // for CUSTOM_COLORS_LIST definition
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE (wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS)
|
|
|
|
|
|
|
|
#define VIEWER3D_FRAMENAME wxT( "Viewer3DFrameName" )
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard
|
|
|
|
*/
|
|
|
|
class EDA_3D_VIEWER : public KIWAY_PLAYER
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2018-05-10 10:49:20 +00:00
|
|
|
EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent,
|
2016-07-19 17:35:25 +00:00
|
|
|
const wxString &aTitle,
|
|
|
|
long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
|
|
|
|
|
|
|
|
~EDA_3D_VIEWER();
|
|
|
|
|
|
|
|
PCB_BASE_FRAME* Parent() const { return (PCB_BASE_FRAME*)GetParent(); }
|
|
|
|
|
|
|
|
BOARD* GetBoard() { return Parent()->GetBoard(); }
|
|
|
|
|
2017-05-13 06:17:06 +00:00
|
|
|
/**
|
|
|
|
* Request reloading the 3D view. However the request will be executed
|
|
|
|
* only when the 3D canvas is refreshed.
|
2018-07-08 12:12:38 +00:00
|
|
|
* It allows one to prepare changes and request for 3D rebuild only when all
|
2017-05-13 06:17:06 +00:00
|
|
|
* changes are committed.
|
|
|
|
* This is made because the 3D rebuild can take a long time, and this rebuild
|
|
|
|
* cannot always made after each change, for calculation time reason.
|
|
|
|
*/
|
2016-07-19 17:35:25 +00:00
|
|
|
void ReloadRequest();
|
|
|
|
|
2017-05-13 06:17:06 +00:00
|
|
|
// !TODO: review this function: it need a way to tell what changed,
|
|
|
|
// to only reload/rebuild things that have really changed
|
|
|
|
/**
|
|
|
|
* Reload and refresh (rebuild) the 3D scene.
|
|
|
|
* Warning: rebuilding the 3D scene can take a bit of time, so
|
|
|
|
* rebuilding the scene can be immediate, or made later, during
|
|
|
|
* the next 3D canvas refresh (on zoom for instance)
|
|
|
|
* @param aForceImmediateRedraw = true to immediately rebuild the 3D scene,
|
|
|
|
* false to wait a refresh later.
|
|
|
|
*/
|
|
|
|
void NewDisplay( bool aForceImmediateRedraw = false );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the default file name (eg: to be suggested to a screenshot)
|
|
|
|
* @param aFn = file name to assign
|
|
|
|
*/
|
2018-12-08 13:20:32 +00:00
|
|
|
void SetDefaultFileName( const wxString& aFn )
|
2016-09-06 05:15:59 +00:00
|
|
|
{
|
2018-12-08 13:20:32 +00:00
|
|
|
m_defaultSaveScreenshotFileName = aFn;
|
2016-09-06 05:15:59 +00:00
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the default suggested file name
|
|
|
|
*/
|
2018-12-08 13:20:32 +00:00
|
|
|
const wxFileName& GetDefaultFileName() const { return m_defaultSaveScreenshotFileName; }
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return current settings
|
|
|
|
*/
|
|
|
|
CINFO3D_VISU &GetSettings() { return m_settings; }
|
|
|
|
|
2019-01-31 09:00:29 +00:00
|
|
|
/**
|
|
|
|
* Return a structure containing currently used hotkey mapping.
|
|
|
|
*/
|
|
|
|
EDA_HOTKEY_CONFIG* GetHotkeyConfig() const;
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/**
|
|
|
|
* Get a SFVEC3D from a wx colour dialog
|
|
|
|
* @param aColor is the SFVEC3D to change
|
|
|
|
* @param aTitle is the title displayed in the colordialog selector
|
2018-10-12 19:02:11 +00:00
|
|
|
* @param aPredefinedColors is a reference to a CUSTOM_COLOR_ITEM list
|
2016-07-19 17:35:25 +00:00
|
|
|
* which contains a few predefined colors
|
2018-10-12 19:02:11 +00:00
|
|
|
* if empty, no predefined colors are used.
|
|
|
|
* no change if aborted by user
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
|
|
|
bool Set3DColorFromUser( SFVEC3D &aColor, const wxString& aTitle,
|
2018-10-12 19:02:11 +00:00
|
|
|
CUSTOM_COLORS_LIST* aPredefinedColors );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the solder mask color from a set of colors
|
|
|
|
* @return true if a new color is chosen, false if
|
|
|
|
* no change or aborted by user
|
|
|
|
*/
|
|
|
|
bool Set3DSolderMaskColorFromUser();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the solder mask color from a set of colors
|
|
|
|
* @return true if a new color is chosen, false if
|
|
|
|
* no change or aborted by user
|
|
|
|
*/
|
|
|
|
bool Set3DSolderPasteColorFromUser();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the copper color from a set of colors
|
|
|
|
* @return true if a new color is chosen, false if
|
|
|
|
* no change or aborted by user
|
|
|
|
*/
|
|
|
|
bool Set3DCopperColorFromUser();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the copper color from a set of colors
|
|
|
|
* @return true if a new color is chosen, false if
|
|
|
|
* no change or aborted by user
|
|
|
|
*/
|
|
|
|
bool Set3DBoardBodyColorFromUser();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the silkscreen color from a set of colors
|
|
|
|
* @return true if a new color is chosen, false if
|
|
|
|
* no change or aborted by user
|
|
|
|
*/
|
|
|
|
bool Set3DSilkScreenColorFromUser();
|
|
|
|
|
2019-04-08 09:49:18 +00:00
|
|
|
/**
|
|
|
|
* Notification that common settings are updated.
|
|
|
|
*
|
|
|
|
* This would be private (and only called by the Kiway), but we
|
|
|
|
* need to do this manually from the PCB frame because the 3D viewer isn't
|
|
|
|
* updated via the #KIWAY.
|
|
|
|
*/
|
|
|
|
void CommonSettingsChanged() override;
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
private:
|
2017-12-28 08:29:56 +00:00
|
|
|
/// Called when user press the File->Exit
|
2016-07-19 17:35:25 +00:00
|
|
|
void Exit3DFrame( wxCommandEvent &event );
|
|
|
|
|
|
|
|
void OnCloseWindow( wxCloseEvent &event );
|
|
|
|
|
|
|
|
void Process_Special_Functions( wxCommandEvent &event );
|
|
|
|
|
|
|
|
void On3DGridSelection( wxCommandEvent &event );
|
|
|
|
|
|
|
|
void OnRenderEngineSelection( wxCommandEvent &event );
|
2019-01-19 13:02:10 +00:00
|
|
|
void OnDisableRayTracing( wxCommandEvent& aEvent );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-01-13 19:04:34 +00:00
|
|
|
void OnUpdateUIEngine( wxUpdateUIEvent& aEvent );
|
|
|
|
void OnUpdateUIMaterial( wxUpdateUIEvent& aEvent );
|
|
|
|
void OnUpdateUIOpenGL( wxUpdateUIEvent& aEvent );
|
|
|
|
void OnUpdateUIRayTracing( wxUpdateUIEvent& aEvent );
|
|
|
|
void OnUpdateUIAxis( wxUpdateUIEvent& aEvent );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
void ProcessZoom( wxCommandEvent &event );
|
|
|
|
|
|
|
|
void OnActivate( wxActivateEvent &event );
|
|
|
|
|
|
|
|
void OnSetFocus( wxFocusEvent &event );
|
|
|
|
|
|
|
|
void Install3DViewOptionDialog( wxCommandEvent &event );
|
|
|
|
|
|
|
|
void CreateMenuBar();
|
|
|
|
|
2019-01-31 09:00:29 +00:00
|
|
|
void DisplayHotKeys()
|
|
|
|
{
|
|
|
|
DisplayHotkeyList( this, GetHotkeyConfig() );
|
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
void ReCreateMainToolbar();
|
|
|
|
|
|
|
|
void SetToolbars();
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void SaveSettings( wxConfigBase *aCfg ) override;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void LoadSettings( wxConfigBase *aCfg ) override;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
void OnLeftClick( wxDC *DC, const wxPoint &MousePos );
|
|
|
|
void OnRightClick( const wxPoint &MousePos, wxMenu *PopMenu );
|
2018-04-25 13:18:28 +00:00
|
|
|
void OnKeyEvent( wxKeyEvent& event );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
void RedrawActiveWindow( wxDC *DC, bool EraseBg );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a Screenshot of the current 3D view.
|
|
|
|
* Output file format is png or jpeg, or image is copied to the clipboard
|
|
|
|
*/
|
|
|
|
void takeScreenshot( wxCommandEvent& event );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief RenderEngineChanged - Update toolbar icon and call canvas RenderEngineChanged
|
|
|
|
*/
|
|
|
|
void RenderEngineChanged();
|
|
|
|
|
2017-11-02 20:41:29 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2019-04-08 09:49:18 +00:00
|
|
|
/**
|
|
|
|
* Load configuration from common settings.
|
|
|
|
*/
|
|
|
|
void loadCommonSettings();
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/**
|
|
|
|
* Filename to propose for save a screenshot
|
|
|
|
*/
|
2018-12-08 13:20:32 +00:00
|
|
|
wxFileName m_defaultSaveScreenshotFileName;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The canvas where the openGL context will be rendered
|
|
|
|
*/
|
|
|
|
EDA_3D_CANVAS *m_canvas;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store all the settings and options to be used by the renders
|
|
|
|
*/
|
|
|
|
CINFO3D_VISU m_settings;
|
|
|
|
|
2019-01-19 13:02:10 +00:00
|
|
|
bool m_disable_ray_tracing;
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/**
|
|
|
|
* Trace mask used to enable or disable the trace output of this class.
|
|
|
|
* The debug output can be turned on by setting the WXTRACE environment variable to
|
|
|
|
* "KI_TRACE_EDA_3D_VIEWER". See the wxWidgets documentation on wxLogTrace for
|
|
|
|
* more information.
|
|
|
|
*/
|
|
|
|
static const wxChar *m_logTrace;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // EDA_3D_VIEWER_H
|