2015-12-08 07:31:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-07-19 17:35:25 +00:00
|
|
|
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
2015-12-08 07:31:57 +00:00
|
|
|
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
2022-10-02 19:00:42 +00:00
|
|
|
* Copyright (C) 2015-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-12-08 07:31:57 +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
|
|
|
|
*/
|
|
|
|
|
2021-06-19 17:28:45 +00:00
|
|
|
#ifndef PANEL_PREVIEW_3D_MODEL_H
|
|
|
|
#define PANEL_PREVIEW_3D_MODEL_H
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-06-19 17:28:45 +00:00
|
|
|
#include "panel_preview_3d_model_base.h"
|
2017-02-06 14:20:46 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
#include <vector>
|
2022-10-02 19:00:42 +00:00
|
|
|
#include <widgets/unit_binder.h>
|
2020-04-19 00:51:49 +00:00
|
|
|
#include <tool/tools_holder.h>
|
2017-02-06 14:20:46 +00:00
|
|
|
#include <3d_canvas/eda_3d_canvas.h>
|
2020-03-18 22:48:36 +00:00
|
|
|
#include <3d_viewer_id.h>
|
2021-01-03 22:23:00 +00:00
|
|
|
#include <3d_rendering/track_ball.h>
|
2017-02-06 14:20:46 +00:00
|
|
|
|
2017-02-06 19:49:29 +00:00
|
|
|
// Define min and max parameter values
|
2017-03-02 17:13:34 +00:00
|
|
|
#define MAX_SCALE 10000.0
|
2017-02-06 19:49:29 +00:00
|
|
|
#define MAX_ROTATION 180.0
|
|
|
|
#define MAX_OFFSET 1000.0
|
|
|
|
|
2018-03-07 13:05:12 +00:00
|
|
|
#define SCALE_INCREMENT_FINE 0.02
|
|
|
|
#define SCALE_INCREMENT 0.1
|
2017-03-02 18:58:14 +00:00
|
|
|
|
2019-08-08 22:01:48 +00:00
|
|
|
#define ROTATION_INCREMENT 90 // in degrees, for spin button command
|
|
|
|
#define ROTATION_INCREMENT_WHEEL 90 // in degrees, for mouse wheel command
|
2017-03-02 18:58:14 +00:00
|
|
|
#define ROTATION_INCREMENT_WHEEL_FINE 1 // in degrees, for mouse wheel command
|
|
|
|
|
2018-03-07 13:05:12 +00:00
|
|
|
#define OFFSET_INCREMENT_MM 0.5
|
|
|
|
#define OFFSET_INCREMENT_MM_FINE 0.1
|
2017-03-02 18:58:14 +00:00
|
|
|
|
2018-03-07 13:05:12 +00:00
|
|
|
#define OFFSET_INCREMENT_MIL 25.0
|
|
|
|
#define OFFSET_INCREMENT_MIL_FINE 5.0
|
2017-02-06 19:49:29 +00:00
|
|
|
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
// Declared classes to create pointers
|
2020-10-06 09:55:26 +00:00
|
|
|
class WX_INFOBAR;
|
2016-01-25 04:55:36 +00:00
|
|
|
class S3D_CACHE;
|
2018-03-07 13:05:12 +00:00
|
|
|
class FILENAME_RESOLVER;
|
2016-07-19 17:35:25 +00:00
|
|
|
class BOARD;
|
2020-03-26 14:05:20 +00:00
|
|
|
class BOARD_ADAPTER;
|
2020-11-13 15:15:52 +00:00
|
|
|
class FOOTPRINT;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-06-19 17:28:45 +00:00
|
|
|
class PANEL_PREVIEW_3D_MODEL: public EDA_3D_BOARD_HOLDER, public TOOLS_HOLDER, public PANEL_PREVIEW_3D_MODEL_BASE
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-06-19 17:28:45 +00:00
|
|
|
PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAME* aFrame, FOOTPRINT* aFootprint,
|
|
|
|
std::vector<FP_3DMODEL>* aParentModelList );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-06-19 17:28:45 +00:00
|
|
|
~PANEL_PREVIEW_3D_MODEL();
|
2016-08-05 19:30:23 +00:00
|
|
|
|
2020-12-16 18:19:28 +00:00
|
|
|
/**
|
|
|
|
* The TOOL_DISPATCHER needs these to work around some issues in wxWidgets where the menu
|
|
|
|
* events aren't captured by the menus themselves.
|
|
|
|
*/
|
|
|
|
void OnMenuEvent( wxMenuEvent& aEvent );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-16 18:19:28 +00:00
|
|
|
wxWindow* GetToolCanvas() const override { return m_previewPane; }
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-16 18:19:28 +00:00
|
|
|
BOARD_ADAPTER& GetAdapter() override { return m_boardAdapter; }
|
2021-01-02 21:05:29 +00:00
|
|
|
CAMERA& GetCurrentCamera() override { return m_currentCamera; }
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-16 18:19:28 +00:00
|
|
|
/**
|
|
|
|
* Set the currently selected index in the model list so that the scale/rotation/offset
|
|
|
|
* controls can be updated.
|
|
|
|
*/
|
|
|
|
void SetSelectedModel( int idx );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy shapes from the current shape list which are flagged for preview to the copy of
|
|
|
|
* footprint that is on the preview dummy board.
|
|
|
|
*/
|
|
|
|
void UpdateDummyFootprint( bool aRelaodRequired = true );
|
2018-02-02 15:56:09 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
private:
|
2019-04-08 09:49:18 +00:00
|
|
|
/**
|
|
|
|
* Load 3D relevant settings from the user configuration
|
|
|
|
*/
|
2021-07-04 12:19:40 +00:00
|
|
|
void loadSettings();
|
2019-04-08 09:49:18 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/**
|
2020-12-16 18:19:28 +00:00
|
|
|
* It will receive the events from editing the fields.
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
2021-01-02 21:05:29 +00:00
|
|
|
void updateOrientation( wxCommandEvent& event ) override;
|
2015-12-09 05:43:30 +00:00
|
|
|
|
2017-02-06 19:49:29 +00:00
|
|
|
void onMouseWheelScale( wxMouseEvent& event ) override;
|
|
|
|
void onMouseWheelRot( wxMouseEvent& event ) override;
|
|
|
|
void onMouseWheelOffset( wxMouseEvent& event ) override;
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void onIncrementRot( wxSpinEvent& event ) override
|
|
|
|
{
|
|
|
|
doIncrementRotation( event, 1.0 );
|
|
|
|
}
|
|
|
|
void onDecrementRot( wxSpinEvent& event ) override
|
|
|
|
{
|
|
|
|
doIncrementRotation( event, -1.0 );
|
|
|
|
}
|
|
|
|
void onIncrementScale( wxSpinEvent& event ) override
|
|
|
|
{
|
|
|
|
doIncrementScale( event, 1.0 );
|
|
|
|
}
|
|
|
|
void onDecrementScale( wxSpinEvent& event ) override
|
|
|
|
{
|
|
|
|
doIncrementScale( event, -1.0 );
|
|
|
|
}
|
|
|
|
void onIncrementOffset( wxSpinEvent& event ) override
|
|
|
|
{
|
|
|
|
doIncrementOffset( event, 1.0 );
|
|
|
|
}
|
|
|
|
void onDecrementOffset( wxSpinEvent& event ) override
|
|
|
|
{
|
|
|
|
doIncrementOffset( event, -1.0 );
|
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-04-19 17:23:40 +00:00
|
|
|
void onOpacitySlider( wxCommandEvent& event ) override;
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void doIncrementScale( wxSpinEvent& aEvent, double aSign );
|
|
|
|
void doIncrementRotation( wxSpinEvent& aEvent, double aSign );
|
|
|
|
void doIncrementOffset( wxSpinEvent& aEvent, double aSign );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2023-03-04 12:11:16 +00:00
|
|
|
void onUnitsChanged( wxCommandEvent& aEvent );
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
wxString formatScaleValue( double aValue );
|
|
|
|
wxString formatRotationValue( double aValue );
|
|
|
|
wxString formatOffsetValue( double aValue );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2017-02-06 14:20:46 +00:00
|
|
|
void View3DISO( wxCommandEvent& event ) override
|
|
|
|
{
|
2020-03-26 14:05:20 +00:00
|
|
|
m_currentCamera.ToggleProjection();
|
2017-02-06 14:20:46 +00:00
|
|
|
m_previewPane->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
void View3DLeft( wxCommandEvent& event ) override
|
|
|
|
{
|
2022-09-28 23:18:50 +00:00
|
|
|
m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_LEFT );
|
2017-02-06 14:20:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void View3DFront( wxCommandEvent& event ) override
|
|
|
|
{
|
2022-09-28 23:18:50 +00:00
|
|
|
m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_FRONT );
|
2017-02-06 14:20:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void View3DTop( wxCommandEvent& event ) override
|
|
|
|
{
|
2022-09-28 23:18:50 +00:00
|
|
|
m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_TOP );
|
2017-02-06 14:20:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void View3DUpdate( wxCommandEvent& event ) override
|
|
|
|
{
|
|
|
|
m_previewPane->ReloadRequest();
|
|
|
|
m_previewPane->Refresh();
|
|
|
|
}
|
|
|
|
|
2023-07-09 19:31:15 +00:00
|
|
|
void View3DSettings( wxCommandEvent& event ) override;
|
|
|
|
|
2017-02-06 14:20:46 +00:00
|
|
|
void View3DRight( wxCommandEvent& event ) override
|
|
|
|
{
|
2022-09-28 23:18:50 +00:00
|
|
|
m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_RIGHT );
|
2017-02-06 14:20:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void View3DBack( wxCommandEvent& event ) override
|
|
|
|
{
|
2022-09-28 23:18:50 +00:00
|
|
|
m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_BACK );
|
2017-02-06 14:20:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void View3DBottom( wxCommandEvent& event ) override
|
|
|
|
{
|
2022-09-28 23:18:50 +00:00
|
|
|
m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_BOTTOM );
|
2017-02-06 14:20:46 +00:00
|
|
|
}
|
|
|
|
|
2020-12-16 18:19:28 +00:00
|
|
|
private:
|
2023-07-09 19:31:15 +00:00
|
|
|
PCB_BASE_FRAME* m_parentFrame;
|
2020-12-16 18:19:28 +00:00
|
|
|
EDA_3D_CANVAS* m_previewPane;
|
|
|
|
WX_INFOBAR* m_infobar;
|
|
|
|
BOARD_ADAPTER m_boardAdapter;
|
2021-01-02 21:05:29 +00:00
|
|
|
CAMERA& m_currentCamera;
|
|
|
|
TRACK_BALL m_trackBallCamera;
|
2020-03-26 14:05:20 +00:00
|
|
|
|
2020-12-16 18:19:28 +00:00
|
|
|
BOARD* m_dummyBoard;
|
|
|
|
FOOTPRINT* m_dummyFootprint;
|
2020-03-24 01:01:23 +00:00
|
|
|
|
2020-12-16 18:19:28 +00:00
|
|
|
std::vector<FP_3DMODEL>* m_parentModelList;
|
|
|
|
int m_selected; /// Index into m_parentInfoList
|
2017-02-06 14:20:46 +00:00
|
|
|
|
2022-10-02 19:00:42 +00:00
|
|
|
EDA_UNITS m_userUnits;
|
2015-12-08 07:31:57 +00:00
|
|
|
};
|
|
|
|
|
2021-06-19 17:28:45 +00:00
|
|
|
#endif // PANEL_PREVIEW_3D_MODEL_H
|