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>
|
2016-09-30 05:51:18 +00:00
|
|
|
* Copyright (C) 2015-2016 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file panel_prev_model.h
|
2016-07-19 17:35:25 +00:00
|
|
|
* @brief Defines a panel which is to be added to a wxFileDialog via
|
|
|
|
* SetExtraControl();
|
|
|
|
* The panel shows a preview of the module being edited and provides controls
|
|
|
|
* to set the offset/rotation/scale of each model 3d shape as per KiCad's
|
|
|
|
* current behavior. The panel may also be used in the 3D configuration dialog
|
|
|
|
* to tune the positioning of the models without invoking a file selector dialog.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PANEL_PREV_MODEL_H
|
|
|
|
#define PANEL_PREV_MODEL_H
|
|
|
|
|
2017-02-06 14:20:46 +00:00
|
|
|
#include "panel_prev_3d_base.h"
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
#include <vector>
|
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>
|
2020-03-26 14:05:20 +00:00
|
|
|
#include <3d_rendering/ctrack_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;
|
2016-07-19 17:35:25 +00:00
|
|
|
class MODULE;
|
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
class PANEL_PREV_3D: public EDA_3D_BOARD_HOLDER, public TOOLS_HOLDER, public PANEL_PREV_3D_BASE
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-03-28 17:14:04 +00:00
|
|
|
PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE* aModule,
|
2020-03-24 01:01:23 +00:00
|
|
|
std::vector<MODULE_3D_SETTINGS>* aParentModelList );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2017-02-19 07:30:34 +00:00
|
|
|
~PANEL_PREV_3D();
|
2016-08-05 19:30:23 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
private:
|
2018-03-28 17:14:04 +00:00
|
|
|
EDA_3D_CANVAS* m_previewPane;
|
2020-10-06 09:55:26 +00:00
|
|
|
WX_INFOBAR* m_infobar;
|
2020-03-26 14:05:20 +00:00
|
|
|
BOARD_ADAPTER m_boardAdapter;
|
|
|
|
CCAMERA& m_currentCamera;
|
|
|
|
CTRACK_BALL m_trackBallCamera;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
BOARD* m_dummyBoard;
|
2018-07-20 20:56:12 +00:00
|
|
|
MODULE* m_dummyModule;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-07-20 20:56:12 +00:00
|
|
|
std::vector<MODULE_3D_SETTINGS>* m_parentModelList;
|
|
|
|
int m_selected; /// Index into m_parentInfoList
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
EDA_UNITS m_userUnits;
|
2018-02-02 15:56:09 +00:00
|
|
|
|
2017-02-06 14:20:46 +00:00
|
|
|
// Methods of the class
|
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
|
|
|
|
*/
|
|
|
|
void loadCommonSettings();
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/**
|
|
|
|
* @brief updateOrientation - it will receive the events from editing the fields
|
|
|
|
* @param event
|
|
|
|
*/
|
2017-02-06 14:20:46 +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
|
|
|
|
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
|
|
|
|
{
|
2020-03-18 22:48:36 +00:00
|
|
|
m_previewPane->SetView3D( ID_VIEW3D_LEFT );
|
2017-02-06 14:20:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void View3DFront( wxCommandEvent& event ) override
|
|
|
|
{
|
2020-03-18 22:48:36 +00:00
|
|
|
m_previewPane->SetView3D( ID_VIEW3D_FRONT );
|
2017-02-06 14:20:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void View3DTop( wxCommandEvent& event ) override
|
|
|
|
{
|
2020-03-18 22:48:36 +00:00
|
|
|
m_previewPane->SetView3D( ID_VIEW3D_TOP );
|
2017-02-06 14:20:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void View3DUpdate( wxCommandEvent& event ) override
|
|
|
|
{
|
|
|
|
m_previewPane->ReloadRequest();
|
|
|
|
m_previewPane->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
void View3DRight( wxCommandEvent& event ) override
|
|
|
|
{
|
2020-03-18 22:48:36 +00:00
|
|
|
m_previewPane->SetView3D( ID_VIEW3D_RIGHT );
|
2017-02-06 14:20:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void View3DBack( wxCommandEvent& event ) override
|
|
|
|
{
|
2020-03-18 22:48:36 +00:00
|
|
|
m_previewPane->SetView3D( ID_VIEW3D_BACK );
|
2017-02-06 14:20:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void View3DBottom( wxCommandEvent& event ) override
|
|
|
|
{
|
2020-03-18 22:48:36 +00:00
|
|
|
m_previewPane->SetView3D( ID_VIEW3D_BOTTOM );
|
2017-02-06 14:20:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2020-03-24 01:01:23 +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 );
|
|
|
|
|
|
|
|
wxWindow* GetToolCanvas() const override { return m_previewPane; }
|
2020-03-26 14:05:20 +00:00
|
|
|
|
|
|
|
BOARD_ADAPTER& GetAdapter() override { return m_boardAdapter; }
|
|
|
|
CCAMERA& GetCurrentCamera() override { return m_currentCamera; }
|
2020-03-24 01:01:23 +00:00
|
|
|
|
2017-02-06 14:20:46 +00:00
|
|
|
/**
|
2018-07-20 20:56:12 +00:00
|
|
|
* @brief SetModelDataIdx - Sets the currently selected index in the model list so that
|
|
|
|
* the scale/rotation/offset controls can be updated.
|
2017-02-06 14:20:46 +00:00
|
|
|
*/
|
2018-07-20 20:56:12 +00:00
|
|
|
void SetSelectedModel( int idx );
|
2017-02-06 14:20:46 +00:00
|
|
|
|
|
|
|
/**
|
2018-03-28 17:14:04 +00:00
|
|
|
* @brief UpdateModelInfoList - copy shapes from the current shape list which are flagged
|
|
|
|
* for preview to the copy of module that is on the preview dummy board
|
2017-02-06 14:20:46 +00:00
|
|
|
*/
|
2018-07-20 20:56:12 +00:00
|
|
|
void UpdateDummyModule( bool aRelaodRequired = true );
|
2015-12-08 07:31:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PANEL_PREV_MODEL_H
|