2007-09-13 11:55:46 +00:00
|
|
|
|
/*****************************************************/
|
|
|
|
|
/* Definitions for the Component classes for EESchema */
|
|
|
|
|
/*****************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
#ifndef COMPONENT_CLASS_H
|
|
|
|
|
#define COMPONENT_CLASS_H
|
|
|
|
|
|
|
|
|
|
#ifndef eda_global
|
|
|
|
|
#define eda_global extern
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "base_struct.h"
|
2008-02-12 21:12:46 +00:00
|
|
|
|
#include "class_screen.h"
|
2008-09-20 17:20:40 +00:00
|
|
|
|
#include <wx/arrstr.h>
|
2008-02-12 21:12:46 +00:00
|
|
|
|
#include <wx/dynarray.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2008-09-20 17:20:40 +00:00
|
|
|
|
#include "class_sch_cmp_field.h"
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
WX_DECLARE_OBJARRAY( DrawSheetPath, ArrayOfSheetLists );
|
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Struct Error
|
|
|
|
|
* is a holder of an error message and may be thrown from functions.
|
|
|
|
|
*/
|
|
|
|
|
struct Error
|
|
|
|
|
{
|
|
|
|
|
wxString errorText;
|
|
|
|
|
|
|
|
|
|
Error( const wxChar* aMsg ) :
|
|
|
|
|
errorText( aMsg )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Error( const wxString& aMsg ) :
|
|
|
|
|
errorText( aMsg )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Fields identifiers */
|
|
|
|
|
enum NumFieldType {
|
|
|
|
|
REFERENCE = 0, ///< Field Reference of part, i.e. "IC21"
|
|
|
|
|
VALUE, ///< Field Value of part, i.e. "3.3K"
|
|
|
|
|
FOOTPRINT, ///< Field Name Module PCB, i.e. "16DIP300"
|
|
|
|
|
DATASHEET, ///< name of datasheet
|
|
|
|
|
|
|
|
|
|
FIELD1,
|
|
|
|
|
FIELD2,
|
|
|
|
|
FIELD3,
|
|
|
|
|
FIELD4,
|
|
|
|
|
FIELD5,
|
|
|
|
|
FIELD6,
|
|
|
|
|
FIELD7,
|
|
|
|
|
FIELD8,
|
|
|
|
|
|
|
|
|
|
NUMBER_OF_FIELDS
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
/**
|
|
|
|
|
* Class SCH_COMPONENT
|
|
|
|
|
* describes a real schematic component
|
2007-09-13 11:55:46 +00:00
|
|
|
|
*/
|
2008-03-20 01:50:21 +00:00
|
|
|
|
class SCH_COMPONENT : public SCH_ITEM
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
|
|
|
|
public:
|
2008-04-09 17:27:59 +00:00
|
|
|
|
int m_Multi; /* In multi unit chip - which unit to draw. */
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
wxPoint m_Pos;
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
wxString m_ChipName; /* Key to look for in the library, i.e. "74LS00". */
|
2008-04-12 18:39:20 +00:00
|
|
|
|
wxString m_PrefixString; /* C, R, U, Q etc - the first character which typically indicates what the component is.
|
|
|
|
|
* determined, upon placement, from the library component.
|
|
|
|
|
* determined, upon file load, by the first non-digits in the reference fields. */
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
2008-04-09 17:27:59 +00:00
|
|
|
|
int m_Convert; /* Gestion (management) des mutiples representations (ex: conversion De Morgan) */
|
|
|
|
|
int m_Transform[2][2]; /* The rotation/mirror transformation matrix. */
|
|
|
|
|
|
2008-04-12 18:39:20 +00:00
|
|
|
|
private:
|
2008-04-15 19:38:19 +00:00
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
/** how many fields are fixed, or automatic and pre-made in the SCH_COMPONENT class */
|
|
|
|
|
|
|
|
|
|
typedef std::vector<SCH_CMP_FIELD> SCH_CMP_FIELDS;
|
|
|
|
|
SCH_CMP_FIELDS m_Fields;
|
|
|
|
|
|
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
|
/* Hierarchical references.
|
2008-10-06 05:44:29 +00:00
|
|
|
|
* format is
|
|
|
|
|
* path reference multi
|
|
|
|
|
* with:
|
|
|
|
|
* path = /<timestamp1>/<timestamp2> (subsheet path, = / for the root scheet)
|
|
|
|
|
* reference = reference for this path (C23, R5, U78 ... )
|
|
|
|
|
* multi = part selection in multi parts per package (0 or 1 for <EFBFBD>ne part per package)
|
2008-04-15 19:38:19 +00:00
|
|
|
|
*/
|
|
|
|
|
wxArrayString m_PathsAndReferences;
|
2008-02-12 21:12:46 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
public:
|
2008-10-06 05:44:29 +00:00
|
|
|
|
SCH_COMPONENT( const wxPoint& pos = wxPoint( 0, 0 ), SCH_ITEM* aParent = NULL );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
~SCH_COMPONENT() { }
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
|
virtual wxString GetClass() const
|
|
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
|
return wxT( "SCH_COMPONENT" );
|
2007-09-13 11:28:58 +00:00
|
|
|
|
}
|
2007-09-13 11:55:46 +00:00
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function Save
|
|
|
|
|
* writes the data structures for this object out to a FILE in "*.brd" format.
|
|
|
|
|
* @param aFile The FILE to write to.
|
|
|
|
|
* @return bool - true if success writing else false.
|
|
|
|
|
*/
|
|
|
|
|
bool Save( FILE* aFile ) const;
|
2007-09-13 11:55:46 +00:00
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function Load
|
|
|
|
|
* reads a component in from a file. The file stream must be positioned at the
|
|
|
|
|
* first field of the file, not at the component tag.
|
|
|
|
|
* @param aFile The FILE to read from.
|
|
|
|
|
* @throw Error containing the error message text if there is a file format
|
|
|
|
|
* error or if the disk read has failed.
|
|
|
|
|
void Load( FILE* aFile ) throw( Error );
|
|
|
|
|
*/
|
|
|
|
|
|
2008-04-09 17:27:59 +00:00
|
|
|
|
SCH_COMPONENT* GenCopy();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
void SetRotationMiroir( int type );
|
|
|
|
|
int GetRotationMiroir();
|
|
|
|
|
wxPoint GetScreenCoord( const wxPoint& coord );
|
|
|
|
|
void Display_Infos( WinEDA_DrawFrame* frame );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
2008-04-21 06:34:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* Suppress annotation ( i.i IC23 changed to IC? and part reset to 1)
|
|
|
|
|
* @param aSheet: DrawSheetPath value: if NULL remove all annotations,
|
|
|
|
|
* else remove annotation relative to this sheetpath
|
|
|
|
|
*/
|
|
|
|
|
void ClearAnnotation( DrawSheetPath* aSheet );
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
EDA_Rect GetBoundaryBox() const;
|
|
|
|
|
EDA_Rect GetBoundingBox();
|
2007-09-13 11:55:46 +00:00
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
/**
|
|
|
|
|
* Function ReturnFieldName
|
|
|
|
|
* returns the Field name given a field index like (REFERENCE, VALUE ..)
|
|
|
|
|
* @reeturn wxString - the field name or wxEmptyString if invalid field index.
|
|
|
|
|
*/
|
|
|
|
|
wxString ReturnFieldName( int aFieldNdx ) const;
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
/**
|
|
|
|
|
* Function GetField
|
|
|
|
|
* returns a field.
|
|
|
|
|
* @param aFieldNdx An index into the array of fields
|
|
|
|
|
* @return SCH_CMP_FIELD* - the field value or NULL if does not exist
|
|
|
|
|
*/
|
|
|
|
|
SCH_CMP_FIELD* GetField( int aFieldNdx ) const;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2008-10-06 05:44:29 +00:00
|
|
|
|
* Function AddField
|
2008-10-06 15:03:59 +00:00
|
|
|
|
* adds a field to the component. The field is copied as it is put into
|
|
|
|
|
* the component.
|
2008-10-06 05:44:29 +00:00
|
|
|
|
* @param aField A const reference to the SCH_CMP_FIELD to add.
|
2007-09-20 21:06:49 +00:00
|
|
|
|
*/
|
2008-10-06 05:44:29 +00:00
|
|
|
|
void AddField( const SCH_CMP_FIELD& aField );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
|
/**
|
|
|
|
|
* Function GetFieldCount
|
|
|
|
|
* returns the number of fields in this component.
|
|
|
|
|
*/
|
|
|
|
|
int GetFieldCount() const { return (int) m_Fields.size(); }
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
|
virtual void Draw( WinEDA_DrawPanel* panel,
|
2008-02-26 19:19:54 +00:00
|
|
|
|
wxDC* DC,
|
|
|
|
|
const wxPoint& offset,
|
|
|
|
|
int draw_mode,
|
|
|
|
|
int Color = -1 );
|
2008-04-14 19:22:48 +00:00
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
void SwapData( SCH_COMPONENT* copyitem );
|
2007-09-13 11:55:46 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
|
2008-02-12 21:12:46 +00:00
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
|
//returns a unique ID, in the form of a path.
|
2008-02-28 19:27:25 +00:00
|
|
|
|
wxString GetPath( DrawSheetPath* sheet );
|
2008-04-16 08:40:31 +00:00
|
|
|
|
//returns the reference, for the given sheet path.
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
2008-02-28 19:27:25 +00:00
|
|
|
|
const wxString GetRef( DrawSheetPath* sheet );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
2008-04-16 08:40:31 +00:00
|
|
|
|
//Set the reference, for the given sheet path.
|
2008-04-15 19:38:19 +00:00
|
|
|
|
void SetRef( DrawSheetPath* sheet, const wxString& ref );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function AddHierarchicalReference
|
|
|
|
|
* adds a full hierachical reference (path + local reference)
|
2008-04-16 08:40:31 +00:00
|
|
|
|
* @param aPath = hierarchical path (/<sheet timestamp>/component timestamp> like /05678E50/A23EF560)
|
|
|
|
|
* @param aRef = local reference like C45, R56
|
|
|
|
|
* @param aMulti = part selection, used in multi part per package (0 or 1 for non multi)
|
|
|
|
|
*/
|
|
|
|
|
void AddHierarchicalReference( const wxString& aPath, const wxString& aRef, int aMulti );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
2008-04-16 08:40:31 +00:00
|
|
|
|
//returns the unit selection, for the given sheet path.
|
2008-04-12 18:39:20 +00:00
|
|
|
|
int GetUnitSelection( DrawSheetPath* aSheet );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
2008-04-16 08:40:31 +00:00
|
|
|
|
//Set the unit selection, for the given sheet path.
|
2008-04-12 18:39:20 +00:00
|
|
|
|
void SetUnitSelection( DrawSheetPath* aSheet, int aUnitSelection );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
|
#if defined (DEBUG)
|
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* Function Show
|
|
|
|
|
* is used to output the object tree, currently for debugging only.
|
2008-02-26 19:19:54 +00:00
|
|
|
|
* @param nestLevel An aid to prettier tree indenting, and is the level
|
2007-09-20 21:06:49 +00:00
|
|
|
|
* of nesting of this object within the overall tree.
|
|
|
|
|
* @param os The ostream& to output to.
|
|
|
|
|
*/
|
2008-02-26 19:19:54 +00:00
|
|
|
|
void Show( int nestLevel, std::ostream& os );
|
|
|
|
|
|
|
|
|
|
#endif
|
2007-05-06 16:03:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* COMPONENT_CLASS_H */
|