KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2024 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 <sch_edit_frame.h>
28#include <sch_bitmap.h>
29#include <sch_commit.h>
30
31
33 DIALOG_IMAGE_PROPERTIES_BASE( aParent ), m_frame( aParent ), m_bitmap( aBitmap ),
34 m_posX( aParent, m_XPosLabel, m_ModPositionX, m_XPosUnit ),
35 m_posY( aParent, m_YPosLabel, m_ModPositionY, m_YPosUnit )
36{
37 // Create the image editor page
38 const REFERENCE_IMAGE& refImage = aBitmap.GetReferenceImage();
40 m_Notebook->AddPage( m_imageEditor, _( "Image" ), false );
41
44
46
48}
49
50
52{
55
56 return true;
57}
58
59
61{
64 {
65 SCH_COMMIT commit( m_frame );
66
67 // Save old image in undo list if not already in edit
68 if( m_bitmap.GetEditFlags() == 0 )
69 commit.Modify( &m_bitmap, m_frame->GetScreen() );
70
71 // Update our bitmap from the editor
73
75
76 if( !commit.Empty() )
77 commit.Push( _( "Image Properties" ) );
78
79 return true;
80 }
81
82 return false;
83}
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:105
bool Empty() const
Returns status of an item.
Definition: commit.h:144
Class DIALOG_IMAGE_PROPERTIES_BASE.
PANEL_IMAGE_EDITOR * m_imageEditor
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:133
bool TransferDataFromWindow() override
void TransferToImage(BITMAP_BASE &aItem)
Function TransferToImage copy edited image to aItem.
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
BITMAP_BASE & MutableImage() const
Only use this if you really need to modify the underlying image.
const BITMAP_BASE & GetImage() const
Get the underlying image.
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:40
VECTOR2I GetPosition() const override
Definition: sch_bitmap.cpp:115
REFERENCE_IMAGE & GetReferenceImage()
Definition: sch_bitmap.h:51
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_bitmap.cpp:121
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
Definition: sch_commit.cpp:432
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
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)
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691