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, 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
34 m_frame( aParent ),
35 m_bitmap( aBitmap ),
38{
39 // Create the image editor page
40 const REFERENCE_IMAGE& refImage = aBitmap.GetReferenceImage();
41 m_imageEditor = new PANEL_IMAGE_EDITOR( aParent, this, refImage.GetImage() );
42
43 m_imageSizer->Add( m_imageEditor, 1, wxEXPAND | wxALL, 5 );
44
47
49
51}
52
53
55{
56 m_posX.SetValue( m_bitmap.GetPosition().x );
57 m_posY.SetValue( m_bitmap.GetPosition().y );
58
59 return m_imageEditor->TransferDataToWindow();
60}
61
62
64{
65 REFERENCE_IMAGE& refImage = m_bitmap.GetReferenceImage();
66
67 if( m_imageEditor->TransferDataFromWindow() )
68 {
69 SCH_COMMIT commit( m_frame );
70
71 // Save old image in undo list if not already in edit
72 if( m_bitmap.GetEditFlags() == 0 )
73 commit.Modify( &m_bitmap, m_frame->GetScreen() );
74
75 // Update our bitmap from the editor
76 m_imageEditor->TransferToImage( refImage.MutableImage() );
77
78 m_bitmap.SetPosition( VECTOR2I( m_posX.GetIntValue(), m_posY.GetIntValue() ) );
79
80 if( !commit.Empty() )
81 commit.Push( _( "Image Properties" ) );
82
83 return true;
84 }
85
86 return false;
87}
bool Empty() const
Definition commit.h:137
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:106
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:40
REFERENCE_IMAGE & GetReferenceImage()
Definition sch_bitmap.h:51
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:695