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
39 m_Notebook->AddPage( m_imageEditor, _( "Image" ), false );
40
43
45
47}
48
49
51{
54
55 return true;
56}
57
58
60{
62 {
63 SCH_COMMIT commit( m_frame );
64
65 // Save old image in undo list if not already in edit
66 if( m_bitmap->GetEditFlags() == 0 )
67 commit.Modify( m_bitmap, m_frame->GetScreen() );
68
69 // Update our bitmap from the editor
71
73
74 if( !commit.Empty() )
75 commit.Push( _( "Image Properties" ) );
76
77 return true;
78 }
79
80 return false;
81}
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:132
void TransferToImage(BITMAP_BASE *aItem)
Function TransferToImage copy edited image to aItem.
bool TransferDataFromWindow() override
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:41
VECTOR2I GetPosition() const override
Definition: sch_bitmap.h:145
BITMAP_BASE * GetImage() const
Definition: sch_bitmap.h:54
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_bitmap.h:146
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:405
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:188
#define _(s)
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588