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>
31#include <board.h>
33
34
36 PCB_REFERENCE_IMAGE& aBitmap ) :
38 m_frame( aParent ),
39 m_bitmap( aBitmap ),
40 m_posX( aParent, m_XPosLabel, m_ModPositionX, m_XPosUnit ),
41 m_posY( aParent, m_YPosLabel, m_ModPositionY, m_YPosUnit )
42{
43 // Create the image editor page
46 m_Notebook->AddPage( m_imageEditor, _( "Image" ), false );
47
50
51 // Only show unactivated board layers if the bitmap is on one of them
54
58
60
62}
63
64
66{
67 PCB_REFERENCE_IMAGE& bitmap = static_cast<PCB_REFERENCE_IMAGE&>( *aBitmap );
68 DIALOG_REFERENCE_IMAGE_PROPERTIES dlg( this, bitmap );
69
70 if( dlg.ShowModal() == wxID_OK )
71 {
72 // The bitmap is cached in Opengl: clear the cache in case it has become invalid
75 OnModify();
76 }
77}
78
79
81{
84
86
87 m_cbLocked->SetValue( m_bitmap.IsLocked() );
88 m_cbLocked->SetToolTip( _( "Locked items cannot be freely moved and oriented on the canvas "
89 "and can only be selected when the 'Locked items' checkbox is "
90 "checked in the selection filter." ) );
91
92 return true;
93}
94
95
97{
99 {
100 // Save old image in undo list if not already in edit
101 if( m_bitmap.GetEditFlags() == 0 )
102 m_frame->SaveCopyInUndoList( &m_bitmap, UNDO_REDO::CHANGED );
103
104 // Update our bitmap from the editor
106
107 // Set position, etc.
110 m_bitmap.SetLocked( m_cbLocked->GetValue() );
111
112 return true;
113 }
114
115 return false;
116}
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:79
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:237
virtual void SetLocked(bool aLocked)
Definition: board_item.h:328
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:288
virtual bool IsLocked() const
Definition: board_item.cpp:75
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:801
Class DIALOG_REFERENCE_IMAGE_PROPERTIES_BASE.
DIALOG_REFERENCE_IMAGE_PROPERTIES(PCB_BASE_FRAME *aParent, PCB_REFERENCE_IMAGE &aBitmap)
PCB_BASE_FRAME * m_frame
The reference image being edited.
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...
int ShowModal() override
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:133
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:299
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1454
int SetLayerSelection(int layer)
bool SetLayersHotkeys(bool value)
bool TransferDataFromWindow() override
void TransferToImage(BITMAP_BASE &aItem)
Function TransferToImage copy edited image to aItem.
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
Get the position of the image (this is the center of the image).
void SetPosition(const VECTOR2I &aPosition) override
Set the position of the image.
REFERENCE_IMAGE & GetReferenceImage()
BITMAP_BASE & MutableImage() const
Only use this if you really need to modify the underlying image.
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:199
#define _(s)
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:810
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691