7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-14 17:19:35 +00:00

PCB Editor: Add User Background Images

This commit is contained in:
Mike Williams 2022-02-08 14:29:54 -05:00
parent 1f4079802c
commit 3669cb4673
46 changed files with 978 additions and 30 deletions

View File

@ -512,6 +512,7 @@ set( PCB_COMMON_SRCS
${CMAKE_SOURCE_DIR}/pcbnew/netinfo_list.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pad.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_target.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_bitmap.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_text.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_textbox.cpp
${CMAKE_SOURCE_DIR}/pcbnew/board_stackup_manager/board_stackup.cpp

View File

@ -25,6 +25,10 @@
#include <wx/dcclient.h>
#include <confirm.h>
#include <bitmap_base.h>
#include <pcb_base_edit_frame.h>
#include <pcb_bitmap.h>
#include <tool/tool_manager.h>
#include <tool/actions.h>
#include <dialogs/dialog_image_editor.h>
@ -129,3 +133,24 @@ void DIALOG_IMAGE_EDITOR::TransferToImage( BITMAP_BASE* aItem )
m_workingImage->SetScale( scale );
aItem->ImportData( m_workingImage );
}
void PCB_BASE_EDIT_FRAME::ShowBitmapPropertiesDialog( BOARD_ITEM* aBitmap )
{
PCB_BITMAP* bitmap = static_cast<PCB_BITMAP*>( aBitmap );
DIALOG_IMAGE_EDITOR dlg( this, bitmap->GetImage() );
if( dlg.ShowModal() == wxID_OK )
{
// save old image in undo list if not already in edit
if( bitmap->GetEditFlags() == 0 )
SaveCopyInUndoList( bitmap, UNDO_REDO::CHANGED );
dlg.TransferToImage( bitmap->GetImage() );
// The bitmap is cached in Opengl: clear the cache in case it has become invalid
GetCanvas()->GetView()->RecacheAllItems();
m_toolManager->PostEvent( EVENTS::SelectedItemsModified );
this->OnModify();
}
}

View File

@ -315,6 +315,7 @@ static struct EDA_ITEM_DESC
.Map( PCB_FOOTPRINT_T, _HKI( "Footprint" ) )
.Map( PCB_PAD_T, _HKI( "Pad" ) )
.Map( PCB_SHAPE_T, _HKI( "Graphic" ) )
.Map( PCB_BITMAP_T, _HKI( "Bitmap" ) )
.Map( PCB_TEXT_T, _HKI( "Text" ) )
.Map( PCB_TEXTBOX_T, _HKI( "Text Box" ) )
.Map( PCB_FP_TEXT_T, _HKI( "Text" ) )

View File

@ -480,10 +480,12 @@ void CAIRO_GAL_BASE::DrawCurve( const VECTOR2D& aStartPoint, const VECTOR2D& aCo
}
void CAIRO_GAL_BASE::DrawBitmap( const BITMAP_BASE& aBitmap )
void CAIRO_GAL_BASE::DrawBitmap( const BITMAP_BASE& aBitmap, double alphaBlend )
{
cairo_save( m_currentContext );
alphaBlend = std::clamp( alphaBlend, 0.0, 1.0 );
// We have to calculate the pixel size in users units to draw the image.
// m_worldUnitLength is a factor used for converting IU to inches
double scale = 1.0 / ( aBitmap.GetPPI() * m_worldUnitLength );
@ -537,7 +539,7 @@ void CAIRO_GAL_BASE::DrawBitmap( const BITMAP_BASE& aBitmap )
cairo_surface_mark_dirty( image );
cairo_set_source_surface( m_currentContext, image, 0, 0 );
cairo_paint( m_currentContext );
cairo_paint_with_alpha( m_currentContext, alphaBlend );
// store the image handle so it can be destroyed later
m_imageSurfaces.push_back( image );

View File

@ -1232,8 +1232,10 @@ void OPENGL_GAL::DrawCurve( const VECTOR2D& aStartPoint, const VECTOR2D& aContro
}
void OPENGL_GAL::DrawBitmap( const BITMAP_BASE& aBitmap )
void OPENGL_GAL::DrawBitmap( const BITMAP_BASE& aBitmap, double alphaBlend )
{
GLfloat alpha = std::clamp( alphaBlend, 0.0, 1.0 );
// We have to calculate the pixel size in users units to draw the image.
// m_worldUnitLength is a factor used for converting IU to inches
double scale = 1.0 / ( aBitmap.GetPPI() * m_worldUnitLength );
@ -1259,16 +1261,16 @@ void OPENGL_GAL::DrawBitmap( const BITMAP_BASE& aBitmap )
glBindTexture( GL_TEXTURE_2D, texture_id );
glBegin( GL_QUADS );
glColor4f( 1.0, 1.0, 1.0, 1.0 );
glColor4f( 1.0, 1.0, 1.0, alpha );
glTexCoord2f( 0.0, 0.0 );
glVertex3f( v0.x, v0.y, m_layerDepth );
glColor4f( 1.0, 1.0, 1.0, 1.0 );
glColor4f( 1.0, 1.0, 1.0, alpha );
glTexCoord2f( 1.0, 0.0 );
glVertex3f( v1.x, v0.y, m_layerDepth );
glColor4f( 1.0, 1.0, 1.0, 1.0 );
glColor4f( 1.0, 1.0, 1.0, alpha );
glTexCoord2f( 1.0, 1.0 );
glVertex3f( v1.x, v1.y, m_layerDepth );
glColor4f( 1.0, 1.0, 1.0, 1.0 );
glColor4f( 1.0, 1.0, 1.0, alpha );
glTexCoord2f( 0.0, 1.0 );
glVertex3f( v0.x, v1.y, m_layerDepth );
glEnd();

View File

@ -74,6 +74,7 @@ convexhull
copper_line_width
copper_text_dims
courtyard_line_width
data
date
defaults
descr
@ -148,6 +149,7 @@ hide
hole_to_hole_min
host
id
image
island
island_removal_mode
island_area_min

View File

@ -157,6 +157,7 @@ PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS( PROJECT* aProject, const wxStrin
m_params.emplace_back( new PARAM<double>( "board.opacity.vias", &m_ViaOpacity, 1.0 ) );
m_params.emplace_back( new PARAM<double>( "board.opacity.pads", &m_PadOpacity, 1.0 ) );
m_params.emplace_back( new PARAM<double>( "board.opacity.zones", &m_ZoneOpacity, 0.6 ) );
m_params.emplace_back( new PARAM<double>( "board.opacity.background_images", &m_BgImageOpacity, 0.6 ) );
m_params.emplace_back( new PARAM_LIST<wxString>( "board.hidden_nets", &m_HiddenNets, {} ) );

View File

@ -88,6 +88,7 @@ enum KICAD_T
PCB_FOOTPRINT_T, ///< class FOOTPRINT, a footprint
PCB_PAD_T, ///< class PAD, a pad in a footprint
PCB_SHAPE_T, ///< class PCB_SHAPE, a segment not on copper layers
PCB_BITMAP_T, ///< class PCB_BITMAP, bitmap on a layer
PCB_TEXT_T, ///< class PCB_TEXT, text on a layer
PCB_TEXTBOX_T, ///< class PCB_TEXTBOX, wrapped text on a layer
PCB_FP_TEXT_T, ///< class FP_TEXT, text in a footprint
@ -111,7 +112,7 @@ enum KICAD_T
PCB_DIM_ORTHOGONAL_T, ///< class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
PCB_TARGET_T, ///< class PCB_TARGET, a target (graphic item)
PCB_ZONE_T, ///< class ZONE, a copper pour area
PCB_ITEM_LIST_T , ///< class BOARD_ITEM_LIST, a list of board items
PCB_ITEM_LIST_T, ///< class BOARD_ITEM_LIST, a list of board items
PCB_NETINFO_T, ///< class NETINFO_ITEM, a description of a net
PCB_GROUP_T, ///< class PCB_GROUP, a set of BOARD_ITEMs
@ -406,6 +407,7 @@ constexpr bool IsPcbnewType( const KICAD_T aType )
case PCB_FOOTPRINT_T:
case PCB_PAD_T:
case PCB_SHAPE_T:
case PCB_BITMAP_T:
case PCB_TEXT_T:
case PCB_TEXTBOX_T:
case PCB_FP_TEXT_T:

View File

@ -118,7 +118,7 @@ public:
double aFilterValue = 0.0 ) override;
/// @copydoc GAL::DrawBitmap()
void DrawBitmap( const BITMAP_BASE& aBitmap ) override;
void DrawBitmap( const BITMAP_BASE& aBitmap, double alphaBlend = 1.0 ) override;
// --------------
// Screen methods

View File

@ -206,7 +206,7 @@ public:
/**
* Draw a bitmap image.
*/
virtual void DrawBitmap( const BITMAP_BASE& aBitmap ) {};
virtual void DrawBitmap( const BITMAP_BASE& aBitmap, double alphaBlend = 1.0 ) {};
// --------------
// Screen methods

View File

@ -157,7 +157,7 @@ public:
double aFilterValue = 0.0 ) override;
/// @copydoc GAL::DrawBitmap()
void DrawBitmap( const BITMAP_BASE& aBitmap ) override;
void DrawBitmap( const BITMAP_BASE& aBitmap, double alphaBlend = 1.0 ) override;
/// @copydoc GAL::BitmapText()
void BitmapText( const wxString& aText, const VECTOR2I& aPosition,

View File

@ -40,6 +40,7 @@ public:
m_ViaOpacity = 1.0;
m_PadOpacity = 1.0;
m_ZoneOpacity = 1.0;
m_BgImageOpacity = 1.0;
}
/// @see ZONE_DISPLAY_MODE - stored in the project
@ -57,6 +58,7 @@ public:
double m_ViaOpacity; ///< Opacity override for all types of via
double m_PadOpacity; ///< Opacity override for SMD pads and PTHs
double m_ZoneOpacity; ///< Opacity override for filled zone areas
double m_BgImageOpacity; ///< Opacity override for background images
};
#endif // PCBSTRUCT_H_

View File

@ -123,6 +123,7 @@ public:
double m_ViaOpacity; ///< Opacity override for all types of via
double m_PadOpacity; ///< Opacity override for SMD pads and PTH
double m_ZoneOpacity; ///< Opacity override for filled zones
double m_BgImageOpacity; ///< Opacity override for filled zones
/**
* A list of netnames that have been manually hidden in the board editor.

View File

@ -478,6 +478,7 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx
DEPENDS python/swig/netinfo.i
DEPENDS python/swig/pad.i
DEPENDS python/swig/pcb_group.i
DEPENDS python/swig/pcb_bitmap.i
DEPENDS python/swig/pcb_text.i
DEPENDS python/swig/pcb_group.i
DEPENDS python/swig/plugins.i

View File

@ -112,6 +112,7 @@ void ARRAY_CREATOR::Invoke()
{
case PCB_FOOTPRINT_T:
case PCB_SHAPE_T:
case PCB_BITMAP_T:
case PCB_TEXT_T:
case PCB_TEXTBOX_T:
case PCB_TRACE_T:

View File

@ -44,6 +44,7 @@
#include <pcb_group.h>
#include <pcb_target.h>
#include <pcb_shape.h>
#include <pcb_bitmap.h>
#include <pcb_text.h>
#include <pcb_textbox.h>
#include <pgm_base.h>
@ -307,6 +308,7 @@ void BOARD::Move( const VECTOR2I& aMoveVector ) // overload
// @todo : anything like this elsewhere? maybe put into GENERAL_COLLECTOR class.
static const KICAD_T top_level_board_stuff[] = {
PCB_MARKER_T,
PCB_BITMAP_T,
PCB_TEXT_T,
PCB_TEXTBOX_T,
PCB_SHAPE_T,
@ -739,6 +741,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode, bool aSkipConnectivity
case PCB_DIM_ORTHOGONAL_T:
case PCB_DIM_LEADER_T:
case PCB_SHAPE_T:
case PCB_BITMAP_T:
case PCB_TEXT_T:
case PCB_TEXTBOX_T:
case PCB_TARGET_T:
@ -851,6 +854,7 @@ void BOARD::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aRemoveMode )
case PCB_DIM_ORTHOGONAL_T:
case PCB_DIM_LEADER_T:
case PCB_SHAPE_T:
case PCB_BITMAP_T:
case PCB_TEXT_T:
case PCB_TEXTBOX_T:
case PCB_TARGET_T:
@ -1334,6 +1338,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T s
break;
case PCB_SHAPE_T:
case PCB_BITMAP_T:
case PCB_TEXT_T:
case PCB_TEXTBOX_T:
case PCB_DIM_ALIGNED_T:
@ -1350,6 +1355,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T s
switch( stype = *++p )
{
case PCB_SHAPE_T:
case PCB_BITMAP_T:
case PCB_TEXT_T:
case PCB_TEXTBOX_T:
case PCB_DIM_ALIGNED_T:

View File

@ -341,6 +341,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
// Board items
case PCB_SHAPE_T: // a shape (normally not on copper layers)
case PCB_BITMAP_T: // a bitmap on a user layer
case PCB_TEXT_T: // a text on a layer
case PCB_TEXTBOX_T: // a wrapped text on a layer
case PCB_TRACE_T: // a track segment (segment on a copper layer)

View File

@ -49,6 +49,7 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
// *** all items in a same list (shown here) must be contiguous ****
PCB_MARKER_T, // in m_markers
PCB_TEXT_T, // in m_drawings
PCB_BITMAP_T, // in m_drawings
PCB_TEXTBOX_T, // in m_drawings
PCB_SHAPE_T, // in m_drawings
PCB_DIM_ALIGNED_T, // in m_drawings
@ -72,6 +73,7 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
const KICAD_T GENERAL_COLLECTOR::BoardLevelItems[] = {
PCB_MARKER_T,
PCB_BITMAP_T,
PCB_TEXT_T,
PCB_TEXTBOX_T,
PCB_SHAPE_T,
@ -118,6 +120,7 @@ const KICAD_T GENERAL_COLLECTOR::FootprintItems[] = {
PCB_PAD_T,
PCB_FP_ZONE_T,
PCB_GROUP_T,
PCB_BITMAP_T,
EOT
};

View File

@ -119,6 +119,10 @@ void PCB_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem )
{
switch( aItem->Type() )
{
case PCB_BITMAP_T:
ShowBitmapPropertiesDialog( aItem);
break;
case PCB_TEXT_T:
case PCB_FP_TEXT_T:
ShowTextPropertiesDialog( aItem );

View File

@ -532,6 +532,7 @@ void FOOTPRINT::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode, bool aSkipConnectiv
case PCB_FP_DIM_ORTHOGONAL_T:
case PCB_FP_SHAPE_T:
case PCB_FP_TEXTBOX_T:
case PCB_BITMAP_T:
if( aMode == ADD_MODE::APPEND )
m_drawings.push_back( aBoardItem );
else
@ -786,7 +787,10 @@ const EDA_RECT FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisi
for( BOARD_ITEM* item : m_drawings )
{
if( !isFPEdit && m_privateLayers.test( item->GetLayer() ) )
// We want the bitmap bounding box just in the footprint editor
// so it will start with the correct initial zoom
if( !isFPEdit
&& ( m_privateLayers.test( item->GetLayer() ) || item->Type() != PCB_BITMAP_T ) )
continue;
if( item->Type() != PCB_FP_TEXT_T )
@ -893,7 +897,7 @@ SHAPE_POLY_SET FOOTPRINT::GetBoundingHull() const
if( !isFPEdit && m_privateLayers.test( item->GetLayer() ) )
continue;
if( item->Type() != PCB_FP_TEXT_T )
if( item->Type() != PCB_FP_TEXT_T && item->Type() != PCB_BITMAP_T )
{
item->TransformShapeWithClearanceToPolygon( rawPolys, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
ERROR_OUTSIDE );
@ -1096,9 +1100,12 @@ bool FOOTPRINT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
{
// Text items are selectable on their own, and are therefore excluded from this
// test. TextBox items are NOT selectable on their own, and so MUST be included
// here.
if( item->Type() != PCB_FP_TEXT_T && item->HitTest( arect, false, 0 ) )
// here. Bitmaps aren't selectable since they aren't displayed.
if( item->Type() != PCB_FP_TEXT_T && item->Type() != PCB_FP_TEXT_T
&& item->HitTest( arect, false, 0 ) )
{
return true;
}
}
// Groups are not hit-tested; only their members
@ -1689,6 +1696,7 @@ void FOOTPRINT::SetPosition( const VECTOR2I& aPos )
case PCB_FP_DIM_ORTHOGONAL_T:
case PCB_FP_DIM_RADIAL_T:
case PCB_FP_DIM_LEADER_T:
case PCB_BITMAP_T:
item->Move( delta );
break;

View File

@ -1181,6 +1181,7 @@ void FOOTPRINT_EDIT_FRAME::setupUIConditions()
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawArc );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawPolygon );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawRuleArea );
CURRENT_EDIT_TOOL( PCB_ACTIONS::placeImage );
CURRENT_EDIT_TOOL( PCB_ACTIONS::placeText );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawTextBox );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawAlignedDimension );

View File

@ -185,6 +185,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
placeMenu->Add( PCB_ACTIONS::drawRectangle );
placeMenu->Add( PCB_ACTIONS::drawCircle );
placeMenu->Add( PCB_ACTIONS::drawPolygon );
placeMenu->Add( PCB_ACTIONS::placeImage );
placeMenu->Add( PCB_ACTIONS::placeText );
placeMenu->Add( PCB_ACTIONS::drawTextBox );

View File

@ -326,6 +326,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
placeMenu->Add( PCB_ACTIONS::drawRectangle );
placeMenu->Add( PCB_ACTIONS::drawCircle );
placeMenu->Add( PCB_ACTIONS::drawPolygon );
placeMenu->Add( PCB_ACTIONS::placeImage );
placeMenu->Add( PCB_ACTIONS::placeText );
placeMenu->Add( PCB_ACTIONS::drawTextBox );

View File

@ -172,6 +172,7 @@ public:
*/
//void SetRotationAngle( EDA_ANGLE aRotationAngle );
void ShowBitmapPropertiesDialog( BOARD_ITEM* aBitmap );
void ShowTextPropertiesDialog( BOARD_ITEM* aText );
int ShowTextBoxPropertiesDialog( BOARD_ITEM* aText );
void ShowGraphicItemPropertiesDialog( BOARD_ITEM* aItem );

211
pcbnew/pcb_bitmap.cpp Normal file
View File

@ -0,0 +1,211 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2011 jean-pierre.charras
* Copyright (C) 2022 Mike Williams
* Copyright (C) 2011-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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 pcb_bitmap.cpp
*/
#include <pcb_draw_panel_gal.h>
#include <plotters/plotter.h>
#include <settings/color_settings.h>
#include <bitmaps.h>
#include <base_units.h>
#include <common.h>
#include <eda_draw_frame.h>
#include <core/mirror.h>
#include <pcb_bitmap.h>
#include <trigo.h>
#include <geometry/shape_rect.h>
#include <convert_to_biu.h>
#include <wx/mstream.h>
PCB_BITMAP::PCB_BITMAP( BOARD_ITEM* aParent, const VECTOR2I& pos ) :
BOARD_ITEM( aParent, PCB_BITMAP_T )
{
m_pos = pos;
m_layer = PCB_LAYER_ID::Dwgs_User; // used only to draw/plot a rectangle,
// when a bitmap cannot be drawn or plotted
m_image = new BITMAP_BASE();
m_image->SetPixelSizeIu( (float) Mils2iu( 1000 ) / m_image->GetPPI() );
}
PCB_BITMAP::PCB_BITMAP( const PCB_BITMAP& aPCBBitmap ) : BOARD_ITEM( aPCBBitmap )
{
m_pos = aPCBBitmap.m_pos;
m_layer = aPCBBitmap.m_layer;
m_image = new BITMAP_BASE( *aPCBBitmap.m_image );
m_image->SetPixelSizeIu( (float) Mils2iu( 1000 ) / m_image->GetPPI() );
}
PCB_BITMAP& PCB_BITMAP::operator=( const BOARD_ITEM& aItem )
{
wxCHECK_MSG( Type() == aItem.Type(), *this,
wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " )
+ GetClass() );
if( &aItem != this )
{
BOARD_ITEM::operator=( aItem );
PCB_BITMAP* bitmap = (PCB_BITMAP*) &aItem;
delete m_image;
m_image = new BITMAP_BASE( *bitmap->m_image );
m_pos = bitmap->m_pos;
m_image->SetPixelSizeIu( Mils2iu( 1000 ) / m_image->GetPPI() );
}
return *this;
}
bool PCB_BITMAP::ReadImageFile( const wxString& aFullFilename )
{
return m_image->ReadImageFile( aFullFilename );
}
EDA_ITEM* PCB_BITMAP::Clone() const
{
return new PCB_BITMAP( *this );
}
void PCB_BITMAP::SwapData( BOARD_ITEM* aItem )
{
wxCHECK_RET( aItem->Type() == PCB_BITMAP_T,
wxString::Format( wxT( "PCB_BITMAP object cannot swap data with %s object." ),
aItem->GetClass() ) );
PCB_BITMAP* item = (PCB_BITMAP*) aItem;
std::swap( m_pos, item->m_pos );
std::swap( m_image, item->m_image );
}
const EDA_RECT PCB_BITMAP::GetBoundingBox() const
{
// Bitmaps are center origin, EDA_RECTs need top-left origin
VECTOR2I size = m_image->GetSize();
VECTOR2I topLeft = { m_pos.x - size.x / 2, m_pos.y - size.y / 2 };
return EDA_RECT( topLeft, size );
}
std::shared_ptr<SHAPE> PCB_BITMAP::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
{
EDA_RECT box = GetBoundingBox();
return std::shared_ptr<SHAPE_RECT>(
new SHAPE_RECT( box.GetCenter(), box.GetWidth(), box.GetHeight() ) );
}
const VECTOR2I PCB_BITMAP::GetSize() const
{
return m_image->GetSize();
}
void PCB_BITMAP::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
{
if( aFlipLeftRight )
{
MIRROR( m_pos.x, aCentre.x );
m_image->Mirror( false );
}
else
{
MIRROR( m_pos.y, aCentre.y );
m_image->Mirror( true );
}
}
void PCB_BITMAP::Rotate( const VECTOR2I& aCenter, const EDA_ANGLE& aAngle )
{
RotatePoint( m_pos, aCenter, aAngle );
m_image->Rotate( false );
}
#if defined( DEBUG )
void PCB_BITMAP::Show( int nestLevel, std::ostream& os ) const
{
// XML output:
wxString s = GetClass();
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << m_pos << "/>\n";
}
#endif
bool PCB_BITMAP::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
{
EDA_RECT rect = GetBoundingBox();
rect.Inflate( aAccuracy );
return rect.Contains( aPosition );
}
bool PCB_BITMAP::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
{
EDA_RECT rect = aRect;
rect.Inflate( aAccuracy );
if( aContained )
return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}
BITMAPS PCB_BITMAP::GetMenuImage() const
{
return BITMAPS::image;
}
void PCB_BITMAP::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{
aList.emplace_back( _( "Bitmap" ), wxEmptyString );
aList.emplace_back( _( "Width" ), MessageTextFromValue( aFrame->GetUserUnits(), GetSize().x ) );
aList.emplace_back( _( "Height" ),
MessageTextFromValue( aFrame->GetUserUnits(), GetSize().y ) );
}
void PCB_BITMAP::ViewGetLayers( int aLayers[], int& aCount ) const
{
aCount = 1;
aLayers[0] = LAYER_DRAW_BITMAPS;
}

Some files were not shown because too many files have changed in this diff Show More