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 ),
35{
36 // Create the image editor page
37 const REFERENCE_IMAGE& refImage = aBitmap.GetReferenceImage();
38 m_imageEditor = new PANEL_IMAGE_EDITOR( aParent, this, refImage.GetImage() );
39
40 m_imageSizer->Add( m_imageEditor, 1, wxEXPAND | wxALL, 5 );
41
45
47
49}
50
51
53{
54 m_posX.SetValue( m_bitmap.GetPosition().x );
55 m_posY.SetValue( m_bitmap.GetPosition().y );
56 m_rotation.SetAngleValue( m_bitmap.GetReferenceImage().GetOrientation() );
57
58 // A UNIT_BINDER only reads wxTextEntry and wxStaticText controls, so a spin control would
59 // silently report 0.
60 m_ModOpacity->SetValue( m_bitmap.GetReferenceImage().GetOpacity() );
61
62 return m_imageEditor->TransferDataToWindow();
63}
64
65
67{
68 REFERENCE_IMAGE& refImage = m_bitmap.GetReferenceImage();
69
70 if( m_imageEditor->TransferDataFromWindow() )
71 {
72 SCH_COMMIT commit( m_frame );
73
74 // Save old image in undo list if not already in edit
75 if( m_bitmap.GetEditFlags() == 0 )
76 commit.Modify( &m_bitmap, m_frame->GetScreen() );
77
78 // Update our bitmap from the editor
79 m_imageEditor->TransferToImage( refImage.MutableImage() );
80
81 m_bitmap.SetPosition( VECTOR2I( m_posX.GetIntValue(), m_posY.GetIntValue() ) );
82 refImage.SetOrientation( m_rotation.GetAngleValue() );
83 refImage.SetOpacity( m_ModOpacity->GetValue() );
84
85 if( !commit.Empty() )
86 commit.Push( _( "Image Properties" ) );
87
88 return true;
89 }
90
91 return false;
92}
bool Empty() const
Definition commit.h:145
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.
void SetOrientation(const EDA_ANGLE &aAngle)
Set the rotation of the image content relative to the stored raster.
void SetOpacity(double aOpacity)
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
Commit for the schematic and symbol editors.
Definition sch_commit.h:54
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
Schematic editor (Eeschema) main window.
#define _(s)
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708