2018-08-28 13:26:39 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2020-04-02 00:17:25 +00:00
|
|
|
* Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2018-08-28 13:26:39 +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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SYMBOL_PREVIEW_WIDGET_H
|
|
|
|
#define SYMBOL_PREVIEW_WIDGET_H
|
|
|
|
|
|
|
|
#include <wx/panel.h>
|
|
|
|
#include <kiway.h>
|
|
|
|
#include <gal/gal_display_options.h>
|
2018-09-15 07:00:13 +00:00
|
|
|
#include <class_draw_panel_gal.h>
|
2018-08-28 13:26:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
class LIB_ID;
|
2018-08-30 21:44:50 +00:00
|
|
|
class LIB_PART;
|
2018-08-28 13:26:39 +00:00
|
|
|
class wxStaticText;
|
|
|
|
class wxSizer;
|
|
|
|
|
|
|
|
|
|
|
|
class SYMBOL_PREVIEW_WIDGET: public wxPanel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct a symbol preview widget.
|
|
|
|
*
|
|
|
|
* @param aParent - parent window
|
|
|
|
* @param aKiway - an active Kiway instance
|
2018-09-15 07:00:13 +00:00
|
|
|
* @param aCanvasType = the type of canvas (GAL_TYPE_OPENGL or GAL_TYPE_CAIRO only)
|
2018-08-28 13:26:39 +00:00
|
|
|
*/
|
2018-09-15 07:00:13 +00:00
|
|
|
SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway,
|
|
|
|
EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType );
|
2018-08-28 13:26:39 +00:00
|
|
|
|
2018-08-29 18:31:43 +00:00
|
|
|
~SYMBOL_PREVIEW_WIDGET() override;
|
|
|
|
|
2018-08-28 13:26:39 +00:00
|
|
|
/**
|
|
|
|
* Set the contents of the status label and display it.
|
|
|
|
*/
|
|
|
|
void SetStatusText( wxString const& aText );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the currently displayed symbol.
|
|
|
|
*/
|
2020-04-02 00:17:25 +00:00
|
|
|
void DisplaySymbol( const LIB_ID& aSymbolID, int aUnit, int aConvert = 0 );
|
2018-08-28 13:26:39 +00:00
|
|
|
|
2020-04-02 00:17:25 +00:00
|
|
|
void DisplayPart( LIB_PART* aPart, int aUnit, int aConvert = 0 );
|
2018-08-30 21:44:50 +00:00
|
|
|
|
2018-08-28 13:26:39 +00:00
|
|
|
private:
|
2018-09-17 09:22:11 +00:00
|
|
|
void onSize( wxSizeEvent& aEvent );
|
|
|
|
|
|
|
|
void fitOnDrawArea(); // set the view scale to fit the item on screen and center
|
|
|
|
|
2018-08-28 13:26:39 +00:00
|
|
|
KIWAY& m_kiway;
|
|
|
|
|
|
|
|
KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions;
|
|
|
|
EDA_DRAW_PANEL_GAL* m_preview;
|
|
|
|
|
|
|
|
wxStaticText* m_status;
|
2020-08-09 23:51:36 +00:00
|
|
|
wxPanel* m_statusPanel;
|
2018-08-30 21:44:50 +00:00
|
|
|
wxSizer* m_statusSizer;
|
2020-08-09 23:51:36 +00:00
|
|
|
wxSizer* m_outerSizer;
|
2018-08-29 18:31:43 +00:00
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
/**
|
|
|
|
* A local copy of the #LIB_PART to display on the canvas.
|
2018-10-31 14:52:10 +00:00
|
|
|
*/
|
2019-11-06 19:15:42 +00:00
|
|
|
LIB_PART* m_previewItem;
|
2018-10-31 14:52:10 +00:00
|
|
|
|
|
|
|
/// The bounding box of the current item
|
|
|
|
BOX2I m_itemBBox;
|
2018-08-28 13:26:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // SYMBOL_PREVIEW_WIDGET_H
|