KiCad PCB EDA Suite
pcbnew/dialogs/dialog_image_properties.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <dialogs/dialog_image_properties.h>
26
27#include <pcb_base_edit_frame.h>
28#include <pcb_bitmap.h>
29#include <tool/tool_manager.h>
30#include <tool/actions.h>
32
33
35 DIALOG_IMAGE_PROPERTIES_BASE( aParent ), m_frame( aParent ), m_bitmap( aBitmap ),
36 m_posX( aParent, m_XPosLabel, m_ModPositionX, m_XPosUnit ),
37 m_posY( aParent, m_YPosLabel, m_ModPositionY, m_YPosUnit )
38{
39 // Create the image editor page
41 m_Notebook->AddPage( m_imageEditor, _( "Image" ), false );
42
45
46 // Only show unactivated board layers if the bitmap is on one of them
47 if( !m_frame->GetBoard()->IsLayerEnabled( m_bitmap->GetLayer() ) )
49
53
55
57}
58
59
61{
62 PCB_BITMAP* bitmap = static_cast<PCB_BITMAP*>( aBitmap );
63 DIALOG_IMAGE_PROPERTIES dlg( this, bitmap );
64
65 if( dlg.ShowModal() == wxID_OK )
66 {
67 // The bitmap is cached in Opengl: clear the cache in case it has become invalid
70 OnModify();
71 }
72}
73
74
76{
79
81
82 m_cbLocked->SetValue( m_bitmap->IsLocked() );
83 m_cbLocked->SetToolTip( _( "Locked footprints cannot be freely moved and oriented on the "
84 "canvas and can only be selected when the 'Locked items' checkbox "
85 "is enabled in the selection filter." ) );
86
87 return true;
88}
89
90
92{
94 {
95 // Save old image in undo list if not already in edit
96 if( m_bitmap->GetEditFlags() == 0 )
98
99 // Update our bitmap from the editor
101
102 // Set position, etc.
105 m_bitmap->SetLocked( m_cbLocked->GetValue() );
106
107 return true;
108 }
109
110 return false;
111}
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:58
DIALOG_IMAGE_PROPERTIES(SCH_EDIT_FRAME *aParent, SCH_BITMAP *aBitmap)
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:147
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:213
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1381
int SetLayerSelection(int layer)
bool SetLayersHotkeys(bool value)
void TransferToImage(BITMAP_BASE *aItem)
Function TransferToImage copy edited image to aItem.
bool TransferDataFromWindow() override
void ShowBitmapPropertiesDialog(BOARD_ITEM *aBitmap)
Set the angle used for rotate operations.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
void OnModify() override
Must be called after a change in order to set the "modify" flag and update other data structures and ...
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Object to handle a bitmap image that can be inserted in a PCB.
Definition: pcb_bitmap.h:42
BITMAP_BASE * GetImage() const
Definition: pcb_bitmap.h:53
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void SetBoardFrame(PCB_BASE_FRAME *aFrame)
void ShowNonActivatedLayers(bool aShow)
VECTOR2I GetPosition() const override
Definition: sch_bitmap.h:136
BITMAP_BASE * GetImage() const
Definition: sch_bitmap.h:54
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_bitmap.h:137
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
Create a copy of the current schematic item, and put it in the undo list.
virtual bool IsLocked() const
Definition: sch_item.h:229
virtual void SetLocked(bool aLocked)
Set the 'lock' status to aLocked for of this item.
Definition: sch_item.h:234
void SetLayer(SCH_LAYER_ID aLayer)
Set the layer this item is on.
Definition: sch_item.h:253
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:246
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:170
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
virtual long long int GetValue()
Return the current value in Internal Units.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
void SetCoordType(ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType)
Set the current origin transform mode.
Definition: unit_binder.h:187
#define _(s)
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:932
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618