KiCad PCB EDA Suite
Loading...
Searching...
No Matches
idf_outlines.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) 2014-2017 Cirilo Bernardo
5 * Copyright The KiCad Developers, see AUTHORS.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, see <https://www.gnu.org/licenses/>.
19 */
20
21
22#ifndef IDF_OUTLINES_H
23#define IDF_OUTLINES_H
24
25#include <string>
26#include <list>
27#include <map>
28
29#include <io/idf/idf_common.h>
30
31/*
32 * NOTES ON OUTLINE TYPES:
33 *
34 * BOARD_OUTLINE (PANEL_OUTLINE)
35 * .BOARD_OUTLINE [OWNER]
36 * [thickness]
37 * [outlines]
38 *
39 * OTHER_OUTLINE
40 * .OTHER_OUTLINE [OWNER]
41 * [outline identifier] [thickness] [board side: Top/Bot]
42 * [outline]
43 *
44 * ROUTE_OUTLINE
45 * .ROUTE_OUTLINE [OWNER]
46 * [layers]
47 * [outline]
48 *
49 * PLACE_OUTLINE
50 * .PLACE_OUTLINE [OWNER]
51 * [board side: Top/Bot/Both] [height]
52 * [outline]
53 *
54 * ROUTE_KEEPOUT
55 * .ROUTE_KEEPOUT [OWNER]
56 * [layers]
57 * [outline]
58 *
59 * VIA_KEEPOUT
60 * .VIA_KEEPOUT [OWNER]
61 * [outline]
62 *
63 * PLACE_KEEPOUT
64 * .PLACE_KEEPOUT [OWNER]
65 * [board side: Top/Bot/Both] [height]
66 * [outline]
67 *
68 * Placement Group
69 * .PLACE_REGION [OWNER]
70 * [side: Top/Bot/Both ] [component group name]
71 * [outline]
72 *
73 * Component Outline:
74 * .ELECTRICAL/.MECHANICAL
75 * [GEOM] [PART] [UNIT] [HEIGHT]
76 * [outline]
77 * [PROP] [prop name] [prop value]
78 */
79
80class IDF3_BOARD;
81
82
87{
88public:
90 virtual ~BOARD_OUTLINE();
91
99 virtual bool SetUnit( IDF3::IDF_UNIT aUnit );
100
106 virtual IDF3::IDF_UNIT GetUnit( void );
107
113 virtual bool SetThickness( double aThickness );
114
118 virtual double GetThickness( void );
119
125 virtual bool Clear( void );
126
131
135 IDF3_BOARD* GetParent( void );
136
137
145 bool AddOutline( IDF_OUTLINE* aOutline );
146
160 bool DelOutline( IDF_OUTLINE* aOutline );
161
173 bool DelOutline( size_t aIndex );
174
181 const std::list<IDF_OUTLINE*>* GetOutlines( void );
182
186 size_t OutlinesSize( void );
187
194 IDF_OUTLINE* GetOutline( size_t aIndex );
195
200
206 bool SetOwner( IDF3::KEY_OWNER aOwner );
207
212 bool IsSingle( void );
213
217 void ClearOutlines( void );
218
224 void AddComment( const std::string& aComment );
225
229 size_t CommentsSize( void );
230
234 std::list< std::string >* GetComments( void );
235
239 const std::string* GetComment( size_t aIndex );
240
246 bool DeleteComment( size_t aIndex );
247
251 void ClearComments( void );
252
253 const std::string& GetError( void )
254 {
255 return errormsg;
256 }
257
258protected:
259 // Read outline data from a BOARD or LIBRARY file's outline section
260 void readOutlines( std::istream& aBoardFile, IDF3::IDF_VERSION aIdfVersion );
261
262 // Write comments to a BOARD or LIBRARY file (must not be within a SECTION as per IDFv3 spec)
263 bool writeComments( std::ostream& aBoardFile );
264
265 // Write the outline owner to a BOARD file
266 bool writeOwner( std::ostream& aBoardFile );
267
268 // Write the data of a single outline object
269 void writeOutline( std::ostream& aBoardFile, IDF_OUTLINE* aOutline, size_t aIndex );
270
271 // Iterate through the outlines and write out all data
272 void writeOutlines( std::ostream& aBoardFile ); // write outline data (no headers)
273
274 // Clear internal list of outlines
275 void clearOutlines( void );
276
280 void setParent( IDF3_BOARD* aParent );
281
282 // Shadow routines used by friends to bypass ownership checks
283 bool addOutline( IDF_OUTLINE* aOutline );
284 virtual bool setThickness( double aThickness );
285 virtual void clear( void );
286
296 virtual void readData( std::istream& aBoardFile, const std::string& aHeader,
297 IDF3::IDF_VERSION aIdfVersion );
298
305 virtual void writeData( std::ostream& aBoardFile );
306
307 std::string errormsg;
308 std::list< IDF_OUTLINE* > outlines;
309
310 // indicates the owner of this outline (MCAD, ECAD, UNOWNED).
312 IDF3::OUTLINE_TYPE outlineType; // type of IDF outline
313 bool single; // true if only a single outline is accepted
314 std::list< std::string > comments; // associated comment list
315 IDF3::IDF_UNIT unit; // outline's native unit (MM or THOU)
316 IDF3_BOARD* parent; // BOARD which contains this outline
317 double thickness; // Board/Extrude Thickness or Height (IDF spec)
318
319private:
320 friend class IDF3_BOARD;
321};
322
323
328{
329public:
330 OTHER_OUTLINE( IDF3_BOARD* aParent );
331
337 virtual bool SetOutlineIdentifier( const std::string& aUniqueID );
338
343 virtual const std::string& GetOutlineIdentifier( void );
344
352 virtual bool SetSide( IDF3::IDF_LAYER aSide );
353
358 virtual IDF3::IDF_LAYER GetSide( void );
359
364 virtual bool Clear( void ) override;
365
366private:
374 virtual void readData( std::istream& aBoardFile, const std::string& aHeader,
375 IDF3::IDF_VERSION aIdfVersion ) override;
376
383 virtual void writeData( std::ostream& aBoardFile ) override;
384
385 friend class IDF3_BOARD;
386
387 std::string uniqueID; // Outline Identifier (IDF spec)
388 IDF3::IDF_LAYER side; // Board Side [TOP/BOTTOM ONLY] (IDF spec)
389};
390
391
396{
397public:
398 ROUTE_OUTLINE( IDF3_BOARD* aParent );
399
406 virtual bool SetLayers( IDF3::IDF_LAYER aLayer );
407
412 virtual IDF3::IDF_LAYER GetLayers( void );
413
418 virtual bool Clear( void ) override;
419
420private:
421 friend class IDF3_BOARD;
422
430 virtual void readData( std::istream& aBoardFile, const std::string& aHeader,
431 IDF3::IDF_VERSION aIdfVersion ) override;
432
436 virtual void writeData( std::ostream& aBoardFile ) override;
437
438protected:
439 IDF3::IDF_LAYER layers; // Routing layers (IDF spec)
440};
441
442
447{
448public:
449 PLACE_OUTLINE( IDF3_BOARD* aParent );
450
457 virtual bool SetSide( IDF3::IDF_LAYER aSide );
458
463 virtual IDF3::IDF_LAYER GetSide( void );
464
471 virtual bool SetMaxHeight( double aHeight );
472
477 virtual double GetMaxHeight( void );
478
483 virtual bool Clear( void ) override;
484
485private:
486 friend class IDF3_BOARD;
487
496 virtual void readData( std::istream& aBoardFile, const std::string& aHeader,
497 IDF3::IDF_VERSION aIdfVersion ) override;
498
505 virtual void writeData( std::ostream& aBoardFile ) override;
506
507protected:
508 IDF3::IDF_LAYER side; // Board Side [TOP/BOTTOM/BOTH ONLY] (IDF spec)
509};
510
511
516{
517public:
518 ROUTE_KO_OUTLINE( IDF3_BOARD* aParent );
519};
520
521
529{
530public:
531 VIA_KO_OUTLINE( IDF3_BOARD* aParent );
532};
533
534
540{
541public:
542 PLACE_KO_OUTLINE( IDF3_BOARD* aParent );
543};
544
545
550{
551public:
552 GROUP_OUTLINE( IDF3_BOARD* aParent );
553
560 virtual bool SetSide( IDF3::IDF_LAYER aSide );
561
565 virtual IDF3::IDF_LAYER GetSide( void );
566
573 virtual bool SetGroupName( std::string aGroupName );
574
578 virtual const std::string& GetGroupName( void );
579
583 virtual bool Clear( void ) override;
584
585private:
586 friend class IDF3_BOARD;
587
596 virtual void readData( std::istream& aBoardFile, const std::string& aHeader,
597 IDF3::IDF_VERSION aIdfVersion ) override;
598
605 virtual void writeData( std::ostream& aBoardFile ) override;
606
607 IDF3::IDF_LAYER side; // Board Side [TOP/BOTTOM/BOTH ONLY] (IDF spec)
608 std::string groupName; // non-unique string
609};
610
611
616{
617public:
618 IDF3_COMP_OUTLINE( IDF3_BOARD* aParent );
619
623 virtual bool Clear( void ) override;
624
630 bool SetComponentClass( IDF3::COMP_TYPE aCompClass );
631
636
640 void SetGeomName( const std::string& aGeomName );
641
645 const std::string& GetGeomName( void );
646
650 void SetPartName( const std::string& aPartName );
651
655 const std::string& GetPartName( void );
656
661 const std::string& GetUID( void );
662
668 bool CreateDefaultOutline( const std::string &aGeom, const std::string &aPart );
669
670 // XXX: property manipulators
671
672private:
673 friend class IDF3_BOARD;
675
676 void readProperties( std::istream& aLibFile );
677 bool writeProperties( std::ostream& aLibFile );
678
687 virtual void readData( std::istream& aLibFile, const std::string& aHeader,
688 IDF3::IDF_VERSION aIdfVersion ) override;
689
696 virtual void writeData( std::ostream& aLibFile ) override;
697
704 int incrementRef( void );
705
713 int decrementRef( void );
714
715 std::string uid; // unique ID
716 std::string geometry; // geometry name (IDF)
717 std::string part; // part name (IDF)
718 IDF3::COMP_TYPE compType; // component type
719 int refNum; // number of components referring to this outline
720
721 std::map< std::string, std::string > props; // properties list
722};
723
724#endif // IDF_OUTLINES_H
void ClearComments(void)
Deletes all comments.
virtual bool Clear(void)
Free memory and reinitializes all internal data except for the parent pointer.
bool addOutline(IDF_OUTLINE *aOutline)
std::string errormsg
bool AddOutline(IDF_OUTLINE *aOutline)
Add the specified outline to this object.
virtual bool setThickness(double aThickness)
virtual void clear(void)
friend class IDF3_BOARD
virtual ~BOARD_OUTLINE()
IDF3::KEY_OWNER GetOwner(void)
IDF_OUTLINE * GetOutline(size_t aIndex)
Return a pointer to the outline as specified by aIndex.
IDF3::IDF_UNIT unit
bool DeleteComment(size_t aIndex)
Deletes a comment based on the given index.
bool writeComments(std::ostream &aBoardFile)
virtual void readData(std::istream &aBoardFile, const std::string &aHeader, IDF3::IDF_VERSION aIdfVersion)
Read data from a .BOARD_OUTLINE section.
const std::string * GetComment(size_t aIndex)
void writeOutlines(std::ostream &aBoardFile)
IDF3::OUTLINE_TYPE outlineType
bool IsSingle(void)
std::list< std::string > * GetComments(void)
bool writeOwner(std::ostream &aBoardFile)
void clearOutlines(void)
IDF3::KEY_OWNER owner
virtual bool SetThickness(double aThickness)
Set the thickness or height of the outline (mm).
virtual double GetThickness(void)
bool DelOutline(IDF_OUTLINE *aOutline)
Remove the given outline, subject to IDF ownership rules, if it is owned by this object.
const std::list< IDF_OUTLINE * > * GetOutlines(void)
Return outlines list.
IDF3_BOARD * parent
virtual void writeData(std::ostream &aBoardFile)
Write the comments and .BOARD_OUTLINE section to an IDFv3 file.
void readOutlines(std::istream &aBoardFile, IDF3::IDF_VERSION aIdfVersion)
bool SetOwner(IDF3::KEY_OWNER aOwner)
Set the ownership status of the outline subject to IDF ownership rules.
std::list< std::string > comments
IDF3_BOARD * GetParent(void)
size_t OutlinesSize(void)
void writeOutline(std::ostream &aBoardFile, IDF_OUTLINE *aOutline, size_t aIndex)
size_t CommentsSize(void)
IDF3::OUTLINE_TYPE GetOutlineType(void)
void setParent(IDF3_BOARD *aParent)
Set the parent IDF_BOARD object.
void ClearOutlines(void)
Clear internal data except for the parent pointer.
virtual bool SetUnit(IDF3::IDF_UNIT aUnit)
Function SetUnit sets the native unit of the outline; except for component outlines this must be the ...
std::list< IDF_OUTLINE * > outlines
const std::string & GetError(void)
void AddComment(const std::string &aComment)
Add a comment to the outline data.
virtual IDF3::IDF_UNIT GetUnit(void)
Return the native unit type of the outline.
virtual bool SetGroupName(std::string aGroupName)
Set the name of the group, subject to IDF ownership rules.
friend class IDF3_BOARD
IDF3::IDF_LAYER side
virtual bool Clear(void) override
Delete internal data, subject to IDF ownership rules.
virtual void writeData(std::ostream &aBoardFile) override
Write the data to a .PLACE_REGION section of an IDFv3 file.
virtual void readData(std::istream &aBoardFile, const std::string &aHeader, IDF3::IDF_VERSION aIdfVersion) override
Read GROUP_OUTLINE data from an open IDFv3 file.
virtual IDF3::IDF_LAYER GetSide(void)
std::string groupName
virtual const std::string & GetGroupName(void)
Return a reference to the (non-unique) group name.
GROUP_OUTLINE(IDF3_BOARD *aParent)
virtual bool SetSide(IDF3::IDF_LAYER aSide)
Set the side which this outline applies to (TOP, BOTTOM, BOTH).
void SetPartName(const std::string &aPartName)
Set the Part Name (Part Number, IDFv3 spec) of the component outline.
void readProperties(std::istream &aLibFile)
const std::string & GetUID(void)
friend class IDF3_BOARD
virtual void writeData(std::ostream &aLibFile) override
Write comments and component outline data to an IDFv3 Library file.
friend class IDF3_COMP_OUTLINE_DATA
virtual void readData(std::istream &aLibFile, const std::string &aHeader, IDF3::IDF_VERSION aIdfVersion) override
Read a component outline from an open IDFv3 file.
IDF3::COMP_TYPE GetComponentClass(void)
std::map< std::string, std::string > props
IDF3_COMP_OUTLINE(IDF3_BOARD *aParent)
virtual bool Clear(void) override
Delete internal outline data.
IDF3::COMP_TYPE compType
bool CreateDefaultOutline(const std::string &aGeom, const std::string &aPart)
Create a default outline with the given Geometry and Part names.
int decrementRef(void)
Decrement the internal reference counter to keep track of the number of components referring to this ...
void SetGeomName(const std::string &aGeomName)
Set the Geometry Name (Package Name, IDFv3 spec) of the component outline.
std::string geometry
bool SetComponentClass(IDF3::COMP_TYPE aCompClass)
Set the type of component outline (.ELECTRICAL or .MECHANICAL).
bool writeProperties(std::ostream &aLibFile)
const std::string & GetGeomName(void)
int incrementRef(void)
Increment the internal reference counter to keep track of the number of components referring to this ...
const std::string & GetPartName(void)
Return the Part Name (Part Number) of the component outline.
A segment and winding information for an IDF outline.
Definition idf_common.h:551
friend class IDF3_BOARD
virtual void readData(std::istream &aBoardFile, const std::string &aHeader, IDF3::IDF_VERSION aIdfVersion) override
Read an OTHER_OUTLINE data from an IDFv3 file.
IDF3::IDF_LAYER side
std::string uniqueID
virtual bool Clear(void) override
Function Clear deletes internal data except for the parent object.
virtual bool SetOutlineIdentifier(const std::string &aUniqueID)
Function SetOutlineIdentifier sets the Outline Identifier string of this OTHER_OUTLINE object as per ...
virtual const std::string & GetOutlineIdentifier(void)
Function GetOutlineIdentifier returns the object's Outline Identifier.
virtual void writeData(std::ostream &aBoardFile) override
Write the OTHER_OUTLINE data to an open IDFv3 file.
virtual bool SetSide(IDF3::IDF_LAYER aSide)
Function SetSide sets the side which this outline is applicable to (TOP, BOTTOM).
OTHER_OUTLINE(IDF3_BOARD *aParent)
virtual IDF3::IDF_LAYER GetSide(void)
Function GetSide returns the side which this outline is applicable to.
PLACE_KO_OUTLINE(IDF3_BOARD *aParent)
friend class IDF3_BOARD
virtual double GetMaxHeight(void)
Function GetMaxHeight returns the maximum allowable height for a component in this region.
IDF3::IDF_LAYER side
virtual bool SetMaxHeight(double aHeight)
Function SetMaxHeight sets the maximum height of a component within this outline.
virtual bool SetSide(IDF3::IDF_LAYER aSide)
Function SetSide sets the side (TOP, BOTTOM, BOTH) which this outline applies to.
virtual IDF3::IDF_LAYER GetSide(void)
Function GetSide returns the side which this outline is applicable to.
virtual void writeData(std::ostream &aBoardFile) override
Write the PLACE_OUTLINE data to an open IDFv3 file.
virtual bool Clear(void) override
Function Clear deletes all internal data.
virtual void readData(std::istream &aBoardFile, const std::string &aHeader, IDF3::IDF_VERSION aIdfVersion) override
Read PLACE_OUTLINE data from an open IDFv3 file.
PLACE_OUTLINE(IDF3_BOARD *aParent)
ROUTE_KO_OUTLINE(IDF3_BOARD *aParent)
friend class IDF3_BOARD
virtual void writeData(std::ostream &aBoardFile) override
Write the ROUTE_OUTLINE data to an open IDFv3 file.
virtual bool Clear(void) override
Function Clear deletes internal data except for the parent object.
virtual bool SetLayers(IDF3::IDF_LAYER aLayer)
Function SetLayers sets the layer or group of layers this outline is applicable to.
ROUTE_OUTLINE(IDF3_BOARD *aParent)
IDF3::IDF_LAYER layers
virtual void readData(std::istream &aBoardFile, const std::string &aHeader, IDF3::IDF_VERSION aIdfVersion) override
Read ROUTE_OUTLINE data from an IDFv3 file.
virtual IDF3::IDF_LAYER GetLayers(void)
Function GetLayers returns the layer or group of layers which this outline is applicable to.
VIA_KO_OUTLINE(IDF3_BOARD *aParent)
OUTLINE_TYPE
The class of outline.
Definition idf_common.h:150
IDF_VERSION
The supported IDF versions (3.0 and 2.0 ONLY).
Definition idf_common.h:76
IDF_UNIT
The native unit of the board and of component outlines.
Definition idf_common.h:177
IDF_LAYER
The various IDF layer classes and groupings.
Definition idf_common.h:137
KEY_OWNER
The type of CAD which has ownership an object.
Definition idf_common.h:85
COMP_TYPE
Whether a component is a mechanical or electrical part.
Definition idf_common.h:167