KiCad PCB EDA Suite
sch_bitmap.h
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) 2011 jean-pierre.charras
5  * Copyright (C) 2011 KiCad Developers, see change_log.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #ifndef _SCH_BITMAP_H_
31 #define _SCH_BITMAP_H_
32 
33 
34 #include <sch_item_struct.h>
35 #include <class_bitmap_base.h>
36 
37 
38 class SCH_BITMAP : public SCH_ITEM
39 {
40  wxPoint m_pos; // XY coordinates of center of the bitmap
41  BITMAP_BASE* m_image; // the BITMAP_BASE item
42 
43 public:
44  SCH_BITMAP( const wxPoint& pos = wxPoint( 0, 0 ) );
45 
46  SCH_BITMAP( const SCH_BITMAP& aSchBitmap );
47 
49  {
50  delete m_image;
51  }
52 
53  SCH_ITEM& operator=( const SCH_ITEM& aItem );
54 
55  /*
56  * Accessors:
57  */
58  double GetPixelScaleFactor() const { return m_image->GetPixelScaleFactor(); }
59  void SetPixelScaleFactor( double aSF ) { m_image->SetPixelScaleFactor( aSF ); }
60 
62  {
63  wxCHECK_MSG( m_image != NULL, NULL, "Invalid SCH_BITMAP initialization, m_image is NULL." );
64 
65  return m_image;
66  }
67 
79  double GetScalingFactor() const
80  {
81  return m_image->GetScalingFactor();
82  }
83 
84 
85  wxString GetClass() const override
86  {
87  return wxT( "SCH_BITMAP" );
88  }
89 
90 
95  wxSize GetSize() const;
96 
97  const EDA_RECT GetBoundingBox() const override;
98 
99  void SwapData( SCH_ITEM* aItem ) override;
100 
101  void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
102  GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override;
103 
111  bool ReadImageFile( const wxString& aFullFilename );
112 
113  bool Save( FILE* aFile ) const override;
114 
115  bool Load( LINE_READER& aLine, wxString& aErrorMsg ) override;
116 
117  void Move( const wxPoint& aMoveVector ) override
118  {
119  m_pos += aMoveVector;
120  }
121 
122 
123  void MirrorY( int aYaxis_position ) override;
124 
125  void MirrorX( int aXaxis_position ) override;
126 
127  void Rotate( wxPoint aPosition ) override;
128 
129  bool IsSelectStateChanged( const wxRect& aRect ) override;
130 
131  wxString GetSelectMenuText() const override { return wxString( _( "Image" ) ); }
132 
133  BITMAP_DEF GetMenuImage() const override;
134 
135  wxPoint GetPosition() const override { return m_pos; }
136 
137  void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
138 
139  bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override;
140 
141  bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override;
142 
143  void Plot( PLOTTER* aPlotter ) override;
144 
145  EDA_ITEM* Clone() const override;
146 
147 #if defined(DEBUG)
148  void Show( int nestLevel, std::ostream& os ) const override;
149 #endif
150 };
151 
152 
153 #endif // _SCH_BITMAP_H_
double GetPixelScaleFactor() const
SCH_ITEM & operator=(const SCH_ITEM &aItem)
Definition: sch_bitmap.cpp:64
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_bitmap.cpp:193
PNG memory record (file in memory).
Definition: bitmap_types.h:38
Base schematic object class definition.
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_bitmap.h:117
double GetPixelScaleFactor() const
Definition: sch_bitmap.h:58
bool Save(FILE *aFile) const override
Function Save writes the data structures for this object out to a FILE in "*.sch" format...
Definition: sch_bitmap.cpp:91
wxPoint m_pos
Definition: sch_bitmap.h:40
void SetPixelScaleFactor(double aSF)
Definition: sch_bitmap.h:59
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_bitmap.h:135
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_bitmap.cpp:316
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_bitmap.cpp:183
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_bitmap.cpp:247
This class handle bitmap images in KiCad.
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_bitmap.cpp:254
BITMAP_BASE * GetImage()
Definition: sch_bitmap.h:61
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
wxSize GetSize() const
Function GetSize.
Definition: sch_bitmap.cpp:228
bool Load(LINE_READER &aLine, wxString &aErrorMsg) override
Function Load reads a schematic item from aLine in a .sch file.
Definition: sch_bitmap.cpp:137
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_bitmap.cpp:125
double GetScalingFactor() const
Function GetScalingFactor.
Definition: sch_bitmap.h:79
void SetPixelScaleFactor(double aSF)
Base plotter engine class.
Definition: plot_common.h:86
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_bitmap.cpp:237
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_bitmap.h:131
Class EDA_RECT handles the component boundary box.
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_bitmap.cpp:119
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
bool HitTest(const wxPoint &aPosition, int aAccuracy) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item...
Definition: sch_bitmap.cpp:287
double GetScalingFactor() const
Function GetScalingFactor.
SCH_BITMAP(const wxPoint &pos=wxPoint(0, 0))
Definition: sch_bitmap.cpp:45
bool ReadImageFile(const wxString &aFullFilename)
Function ReadImageFile Reads and stores an image file.
Definition: sch_bitmap.cpp:85
bool IsSelectStateChanged(const wxRect &aRect) override
Function IsSelectStateChanged checks if the selection state of an item inside aRect has changed...
Definition: sch_bitmap.cpp:261
BITMAP_BASE * m_image
Definition: sch_bitmap.h:41
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_bitmap.h:85
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_bitmap.cpp:310
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_bitmap.h:137
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39