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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
22
23#include <sch_edit_frame.h>
24#include <sch_bitmap.h>
25#include <sch_commit.h>
26
27
30 m_frame( aParent ),
31 m_bitmap( aBitmap ),
34{
35 // Create the image editor page
36 const REFERENCE_IMAGE& refImage = aBitmap.GetReferenceImage();
37 m_imageEditor = new PANEL_IMAGE_EDITOR( aParent, this, refImage.GetImage() );
38
39 m_imageSizer->Add( m_imageEditor, 1, wxEXPAND | wxALL, 5 );
40
43
45
47}
48
49
51{
52 m_posX.SetValue( m_bitmap.GetPosition().x );
53 m_posY.SetValue( m_bitmap.GetPosition().y );
54
55 return m_imageEditor->TransferDataToWindow();
56}
57
58
60{
61 REFERENCE_IMAGE& refImage = m_bitmap.GetReferenceImage();
62
63 if( m_imageEditor->TransferDataFromWindow() )
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
72 m_imageEditor->TransferToImage( refImage.MutableImage() );
73
74 m_bitmap.SetPosition( VECTOR2I( m_posX.GetIntValue(), m_posY.GetIntValue() ) );
75
76 if( !commit.Empty() )
77 commit.Push( _( "Image Properties" ) );
78
79 return true;
80 }
81
82 return false;
83}
bool Empty() const
Definition commit.h:134
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:102
DIALOG_IMAGE_PROPERTIES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Image Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
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...
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:36
REFERENCE_IMAGE & GetReferenceImage()
Definition sch_bitmap.h:50
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Schematic editor (Eeschema) main window.
#define _(s)
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683