KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_reference_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-2023 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
26
27#include <pcb_base_edit_frame.h>
28#include <pcb_reference_image.h>
29#include <tool/tool_manager.h>
30#include <tool/actions.h>
32
33
35 PCB_REFERENCE_IMAGE* aBitmap ) :
37 m_frame( aParent ),
38 m_bitmap( aBitmap ),
39 m_posX( aParent, m_XPosLabel, m_ModPositionX, m_XPosUnit ),
40 m_posY( aParent, m_YPosLabel, m_ModPositionY, m_YPosUnit )
41{
42 // Create the image editor page
44 m_Notebook->AddPage( m_imageEditor, _( "Image" ), false );
45
48
49 // Only show unactivated board layers if the bitmap is on one of them
52
56
58
60}
61
62
64{
65 PCB_REFERENCE_IMAGE* bitmap = static_cast<PCB_REFERENCE_IMAGE*>( aBitmap );
66 DIALOG_REFERENCE_IMAGE_PROPERTIES dlg( this, bitmap );
67
68 if( dlg.ShowModal() == wxID_OK )
69 {
70 // The bitmap is cached in Opengl: clear the cache in case it has become invalid
73 OnModify();
74 }
75}
76
77
79{
82
84
85 m_cbLocked->SetValue( m_bitmap->IsLocked() );
86 m_cbLocked->SetToolTip( _( "Locked items cannot be freely moved and oriented on the canvas "
87 "and can only be selected when the 'Locked items' checkbox is "
88 "checked in the selection filter." ) );
89
90 return true;
91}
92
93
95{
97 {
98 // Save old image in undo list if not already in edit
99 if( m_bitmap->GetEditFlags() == 0 )
100 m_frame->SaveCopyInUndoList( m_bitmap, UNDO_REDO::CHANGED );
101
102 // Update our bitmap from the editor
104
105 // Set position, etc.
108 m_bitmap->SetLocked( m_cbLocked->GetValue() );
109
110 return true;
111 }
112
113 return false;
114}
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:77
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:226
virtual void SetLocked(bool aLocked)
Definition: board_item.h:300
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:260
virtual bool IsLocked() const
Definition: board_item.cpp:74
bool IsLayerEnabled(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Definition: board.cpp:706
Class DIALOG_REFERENCE_IMAGE_PROPERTIES_BASE.
DIALOG_REFERENCE_IMAGE_PROPERTIES(PCB_BASE_FRAME *aParent, PCB_REFERENCE_IMAGE *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:132
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:267
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1410
int SetLayerSelection(int layer)
bool SetLayersHotkeys(bool value)
void TransferToImage(BITMAP_BASE *aItem)
Function TransferToImage copy edited image to aItem.
bool TransferDataFromWindow() override
void ShowReferenceImagePropertiesDialog(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 ...
virtual void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand)
Create a new entry in undo list of commands.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
BOARD * GetBoard() const
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)
Object to handle a bitmap image that can be inserted in a PCB.
VECTOR2I GetPosition() const override
BITMAP_BASE * MutableImage() const
Only use this if you really need to modify the underlying image.
void SetPosition(const VECTOR2I &aPosition) override
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:167
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:188
#define _(s)
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:1022
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588