Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
f3d5c494
Commit
f3d5c494
authored
Jun 17, 2010
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
meet Ralph, a big harry template fieldnames patch
parent
39476ccd
Changes
30
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
4436 additions
and
2138 deletions
+4436
-2138
.bzrignore
.bzrignore
+5
-2
CHANGELOG.txt
CHANGELOG.txt
+26
-0
TokenList2DsnLexer.cmake
CMakeModules/TokenList2DsnLexer.cmake
+24
-11
dsnlexer.cpp
common/dsnlexer.cpp
+42
-0
CMakeLists.txt
eeschema/CMakeLists.txt
+20
-4
class_libentry.cpp
eeschema/class_libentry.cpp
+117
-51
class_libentry.h
eeschema/class_libentry.h
+22
-6
class_libentry_fields.cpp
eeschema/class_libentry_fields.cpp
+35
-49
class_libentry_fields.h
eeschema/class_libentry_fields.h
+13
-23
class_sch_cmp_field.h
eeschema/class_sch_cmp_field.h
+5
-6
class_sch_component.cpp
eeschema/class_sch_component.cpp
+67
-41
class_sch_component.h
eeschema/class_sch_component.h
+12
-28
cmp_library_lexer.cpp
eeschema/cmp_library_lexer.cpp
+1
-1
dialog_edit_component_in_schematic.cpp
eeschema/dialog_edit_component_in_schematic.cpp
+114
-54
dialog_edit_component_in_schematic.h
eeschema/dialog_edit_component_in_schematic.h
+2
-6
dialog_edit_libentry_fields_in_lib.cpp
eeschema/dialog_edit_libentry_fields_in_lib.cpp
+186
-86
dialog_eeschema_options.cpp
eeschema/dialog_eeschema_options.cpp
+86
-0
dialog_eeschema_options.h
eeschema/dialog_eeschema_options.h
+8
-1
dialog_eeschema_options_base.cpp
eeschema/dialog_eeschema_options_base.cpp
+262
-162
dialog_eeschema_options_base.fbp
eeschema/dialog_eeschema_options_base.fbp
+2717
-1426
dialog_eeschema_options_base.h
eeschema/dialog_eeschema_options_base.h
+109
-82
eeschema_config.cpp
eeschema/eeschema_config.cpp
+72
-5
read_from_file_schematic_items_descriptions.cpp
eeschema/read_from_file_schematic_items_descriptions.cpp
+1
-2
template_fieldnames.cpp
eeschema/template_fieldnames.cpp
+179
-0
template_fieldnames.h
eeschema/template_fieldnames.h
+149
-0
template_fieldnames.lst
eeschema/template_fieldnames.lst
+5
-0
dsnlexer.h
include/dsnlexer.h
+42
-2
param_config.h
include/param_config.h
+62
-78
wxEeschemaStruct.h
include/wxEeschemaStruct.h
+47
-0
specctra.cpp
pcbnew/specctra.cpp
+6
-12
No files found.
.bzrignore
View file @
f3d5c494
eeschema/cmp_library_base.cpp
eeschema/cmp_library_base.h
eeschema/cmp_library_keywords.cpp
eeschema/cmp_library_keywords.h
eeschema/template_fieldnames_keywords.cpp
eeschema/template_fieldnames_keywords.h
pcbnew/dialog_freeroute_exchange_help_html.h
Makefile
CMakeFiles
...
...
@@ -9,4 +11,5 @@ Testing
version.h
config.h
install_manifest.txt
Documentation/doxygen
*.cmake
CHANGELOG.txt
View file @
f3d5c494
...
...
@@ -4,6 +4,32 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
email address.
2010-Jun-17 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++eeschema:
Added "template fieldnames" to eeschema. This is a list of template elements
consisting of {name, value, visibility} which you want shown in the eeschema
component fieldname (property) editors (both schematic and library versions
of the editors). Template fieldnames are forced into the editors'
presentation of the fields even though those fields may not exist in the
component. Entering a non-blank value while in a field editor will cause the
field & value to be retained in the component. Therefore it is unusual to
provide a non-blank '.value' in a template, because a trip through the field
editor will invariably add that field to the component since the template
being applied has initially a non blank 'value'. The current template editor
is only going to last about a week and it does not support adding non-blank
template values yet, nor visibility control, only field '.name'. But the
template fieldnames configuration storage and component field editors do
know how to handle template.visible and template.value already, in addition
to template.name. See the file .eeschema in your home directory for the
configuration storage, keyword: FieldNames. e.g. only field Manufacturer has
a '.value':
FieldNames=(templatefields (field (name "Manufacturer")(value "IBM 12")) (field (name "Vendor")) (field (name "Installed")) (field (name "Ralphy") visible))
DSNLEXER is used to parse the FieldNames record, & OUTPUTFORMATTER to generate it.
2010-jun-15, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
bitmap2component:
...
...
CMakeModules/TokenList2DsnLexer.cmake
View file @
f3d5c494
...
...
@@ -39,23 +39,29 @@
# Usage:
#
# add_custom_command(
# OUTPUT ${CMAKE_BINARY_DIR}/cmp_library_base.h
# OUTPUT ${CMAKE_BINARY_DIR}/cmp_library_keywords.h
# ${CMAKE_BINARY_DIR}/cmp_library_keywords.cpp
# COMMAND ${CMAKE_COMMAND}
# -DinputFile=${CMAKE_CURRENT_SOURCE_DIR}/token_list_file
# -Denum=YOURTOK_T
# -DinputFile=${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.lst
# -P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.lst
# )
#
# Input parameters:
#
# inputFile - The name of the token list file.
# enum - The name of the enum to generate, defaults to DSN_T, but
# you'll get collisions if you don't override it.
# inputFile - The name of the token list file.
# outputPath - Optional output path to save the generated files. If not defined,
# the output path is the same path as the token list file path.
#
set
(
tokens
""
)
set
(
lineCount 0
)
set
(
dsnErrorMsg
"DSN token file generator failure:"
)
if
(
NOT EXISTS
${
inputFile
}
)
message
(
FATAL_ERROR
"
${
dsnErrorMsg
}
file
${
inputFile
}
cannot be found."
)
endif
(
NOT EXISTS
${
inputFile
}
)
...
...
@@ -64,14 +70,20 @@ if( NOT EXISTS ${outputPath} )
get_filename_component
(
outputPath
"
${
inputFile
}
"
PATH
)
endif
(
NOT EXISTS
${
outputPath
}
)
if
(
NOT DEFINED enum
)
set
(
enum DSN_T
)
endif
()
#message( STATUS "enum: ${enum}" )
# Separate the file name without extension from the full file path.
get_filename_component
(
result
"
${
inputFile
}
"
NAME_WE
)
message
(
STATUS
"Extracted file name
${
result
}
from path
${
inputFile
}
"
)
# Create include and source file name from the list file name.
set
(
includeFileName
"
${
outputPath
}
/
${
result
}
_
base
.h"
)
set
(
sourceFileName
"
${
outputPath
}
/
${
result
}
_
base
.cpp"
)
set
(
includeFileName
"
${
outputPath
}
/
${
result
}
_
keywords
.h"
)
set
(
sourceFileName
"
${
outputPath
}
/
${
result
}
_
keywords
.cpp"
)
# Create tag for generating header file.
string
(
TOUPPER
"
${
result
}
"
fileNameTag
)
...
...
@@ -91,7 +103,7 @@ set( includeFileHeader
namespace DSN {
enum
DSN_T
{
enum
${
enum
}
{
// these first few are negative special ones for syntax, and are
// inherited from DSNLEXER.
...
...
@@ -122,7 +134,7 @@ set( sourceFileHeader
#include
\"
fctsys.h
\"
#include
\"
macros.h
\"
#include
\"
${
result
}
_
base
.h
\"
#include
\"
${
result
}
_
keywords
.h
\"
namespace DSN {
...
...
@@ -130,7 +142,6 @@ namespace DSN {
#define TOKDEF(x) { #x, T_##x }
const KEYWORD
${
result
}
_keywords[] = {
"
)
...
...
@@ -193,8 +204,10 @@ endforeach( token ${tokens} )
file
(
APPEND
"
${
includeFileName
}
"
"};
extern const KEYWORD
${
result
}
_keywords[];
extern const unsigned
${
result
}
_keyword_count;
}
// End namespace DSN
} // End namespace DSN
#endif // End
${
headerTag
}
...
...
@@ -208,6 +221,6 @@ file( APPEND "${sourceFileName}"
const unsigned
${
result
}
_keyword_count = DIM(
${
result
}
_keywords );
}
// End namespace DSN
} // End namespace DSN
"
)
common/dsnlexer.cpp
View file @
f3d5c494
...
...
@@ -182,6 +182,16 @@ const char* DSNLEXER::GetTokenText( int aTok )
}
wxString
DSNLEXER
::
GetTokenString
(
int
aTok
)
{
wxString
ret
;
ret
<<
wxT
(
"'"
)
<<
CONV_FROM_UTF8
(
GetTokenText
(
aTok
)
)
<<
wxT
(
"'"
);
return
ret
;
}
void
DSNLEXER
::
ThrowIOError
(
wxString
aText
,
int
charOffset
)
throw
(
IOError
)
{
// append to aText, do not overwrite
...
...
@@ -193,6 +203,38 @@ void DSNLEXER::ThrowIOError( wxString aText, int charOffset ) throw (IOError)
}
void
DSNLEXER
::
Expecting
(
int
aTok
)
throw
(
IOError
)
{
wxString
errText
(
_
(
"Expecting"
)
);
errText
<<
wxT
(
" "
)
<<
GetTokenString
(
aTok
);
ThrowIOError
(
errText
,
CurOffset
()
);
}
void
DSNLEXER
::
Expecting
(
const
wxString
&
text
)
throw
(
IOError
)
{
wxString
errText
(
_
(
"Expecting"
)
);
errText
<<
wxT
(
" '"
)
<<
text
<<
wxT
(
"'"
);
ThrowIOError
(
errText
,
CurOffset
()
);
}
void
DSNLEXER
::
Unexpected
(
int
aTok
)
throw
(
IOError
)
{
wxString
errText
(
_
(
"Unexpected"
)
);
errText
<<
wxT
(
" "
)
<<
GetTokenString
(
aTok
);
ThrowIOError
(
errText
,
CurOffset
()
);
}
void
DSNLEXER
::
Unexpected
(
const
wxString
&
text
)
throw
(
IOError
)
{
wxString
errText
(
_
(
"Unexpected"
)
);
errText
<<
wxT
(
" '"
)
<<
text
<<
wxT
(
"'"
);
ThrowIOError
(
errText
,
CurOffset
()
);
}
/**
* Function isspace
* strips the upper bits of the int to ensure the value passed to ::isspace() is
...
...
eeschema/CMakeLists.txt
View file @
f3d5c494
...
...
@@ -124,6 +124,8 @@ set(EESCHEMA_SRCS
symbdraw.cpp
symbedit.cpp
edit_graphic_bodyitem_text.cpp
template_fieldnames_keywords.cpp
template_fieldnames.cpp
tool_lib.cpp
tool_sch.cpp
tool_viewlib.cpp
...
...
@@ -155,20 +157,34 @@ endif(APPLE)
# Generate DSN lexer header and source files for the component library file
# format.
add_custom_command
(
OUTPUT
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library_base.h
OUTPUT
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library_keywords.h
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library_keywords.cpp
COMMAND
${
CMAKE_COMMAND
}
-DinputFile=
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library.lst
-P
${
CMAKE_MODULE_PATH
}
/TokenList2DsnLexer.cmake
DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library.lst
COMMENT
"creating
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library_
base
.h(.cpp)
COMMENT
"creating
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library_
keywords
.h(.cpp)
from
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library.lst"
)
set_source_files_properties
(
cmp_library_lexer.cpp
PROPERTIES
OBJECT_DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library_base.h
OBJECT_DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library_keywords.h
)
add_custom_command
(
OUTPUT
${
CMAKE_CURRENT_SOURCE_DIR
}
/template_fieldnames_keywords.h
${
CMAKE_CURRENT_SOURCE_DIR
}
/template_fieldnames_keywords.cpp
COMMAND
${
CMAKE_COMMAND
}
-Denum=TFIELD_T
-DinputFile=
${
CMAKE_CURRENT_SOURCE_DIR
}
/template_fieldnames.lst
-P
${
CMAKE_MODULE_PATH
}
/TokenList2DsnLexer.cmake
DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/template_fieldnames.lst
COMMENT
"creating
${
CMAKE_CURRENT_SOURCE_DIR
}
/template_fieldnames_keywords.h(.cpp)
from
${
CMAKE_CURRENT_SOURCE_DIR
}
/template_fieldnames.lst"
)
add_executable
(
eeschema WIN32 MACOSX_BUNDLE
${
EESCHEMA_SRCS
}
${
EESCHEMA_EXTRA_SRCS
}
${
EESCHEMA_RESOURCES
}
)
...
...
eeschema/class_libentry.cpp
View file @
f3d5c494
...
...
@@ -188,13 +188,15 @@ LIB_COMPONENT::LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary ) :
m_DrawPinNum
=
1
;
m_DrawPinName
=
1
;
/* The minimum requirements for a component are a value and a reference
* designator field.
*/
// Add the MANDATORY_FIELDS in RAM only. These are assumed to be present
// when the field editors are invoked.
LIB_FIELD
*
value
=
new
LIB_FIELD
(
this
,
VALUE
);
value
->
m_Text
=
aName
;
drawings
.
push_back
(
value
);
drawings
.
push_back
(
new
LIB_FIELD
(
this
,
REFERENCE
)
);
drawings
.
push_back
(
new
LIB_FIELD
(
this
,
FOOTPRINT
)
);
drawings
.
push_back
(
new
LIB_FIELD
(
this
,
DATASHEET
)
);
}
...
...
@@ -388,19 +390,17 @@ void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* aItem,
{
wxASSERT
(
aItem
!=
NULL
);
/* Value and reference fields cannot be removed. */
// none of the MANDATOR_FIELDS may be removed in RAM, but they may be
// omitted when saving to disk.
if
(
aItem
->
Type
()
==
COMPONENT_FIELD_DRAW_TYPE
)
{
LIB_FIELD
*
field
=
(
LIB_FIELD
*
)
aItem
;
LIB_FIELD
*
field
=
(
LIB_FIELD
*
)
aItem
;
if
(
field
->
m_FieldId
==
VALUE
||
field
->
m_FieldId
==
REFERENCE
)
if
(
field
->
m_FieldId
<
MANDATORY_FIELDS
)
{
wxString
fieldType
=
(
field
->
m_FieldId
==
VALUE
)
?
_
(
"value"
)
:
_
(
"reference"
);
wxLogWarning
(
_
(
"An attempt was made to remove the %s field \
from component %s in library %s."
),
GetChars
(
fieldType
),
GetChars
(
GetName
()
),
wxLogWarning
(
_
(
"An attempt was made to remove the %s field "
"from component %s in library %s."
),
GetChars
(
field
->
m_Name
),
GetChars
(
GetName
()
),
GetChars
(
GetLibraryName
()
)
);
return
;
}
...
...
@@ -518,8 +518,8 @@ LIB_PIN* LIB_COMPONENT::GetPin( const wxString& aNumber, int aUnit, int aConvert
bool
LIB_COMPONENT
::
Save
(
FILE
*
aFile
)
{
size_t
i
;
LIB_FIELD
&
value
=
GetValueField
();
size_t
i
;
LIB_FIELD
&
value
=
GetValueField
();
/* First line: it s a comment (component name for readers) */
if
(
fprintf
(
aFile
,
"#
\n
# %s
\n
#
\n
"
,
CONV_TO_UTF8
(
value
.
m_Text
)
)
<
0
)
...
...
@@ -567,13 +567,33 @@ bool LIB_COMPONENT::Save( FILE* aFile )
LIB_FIELD_LIST
fields
;
GetFields
(
fields
);
for
(
i
=
0
;
i
<
fields
.
size
();
i
++
)
// Fixed fields:
// may have their own save policy so there is a separate loop for them.
for
(
i
=
0
;
i
<
MANDATORY_FIELDS
;
++
i
)
{
if
(
fields
[
i
].
m_Text
.
IsEmpty
()
&&
fields
[
i
].
m_Name
.
IsEmpty
()
)
continue
;
if
(
!
fields
[
i
].
m_Text
.
IsEmpty
()
)
{
if
(
!
fields
[
i
].
Save
(
aFile
)
)
return
false
;
}
}
if
(
!
fields
[
i
].
Save
(
aFile
)
)
return
false
;
// User defined fields:
// may have their own save policy so there is a separate loop for them.
int
fieldId
=
MANDATORY_FIELDS
;
// really wish this would go away.
for
(
i
=
MANDATORY_FIELDS
;
i
<
fields
.
size
();
++
i
)
{
// There is no need to save empty fields, i.e. no reason to preserve field
// names now that fields names come in dynamically through the template
// fieldnames.
if
(
!
fields
[
i
].
m_Text
.
IsEmpty
()
)
{
fields
[
i
].
m_FieldId
=
fieldId
++
;
if
(
!
fields
[
i
].
Save
(
aFile
)
)
return
false
;
}
}
/* Save the alias list: a line starting by "ALIAS" */
...
...
@@ -623,6 +643,7 @@ bool LIB_COMPONENT::Save( FILE* aFile )
{
if
(
item
.
Type
()
==
COMPONENT_FIELD_DRAW_TYPE
)
continue
;
if
(
!
item
.
Save
(
aFile
)
)
return
false
;
}
...
...
@@ -637,6 +658,7 @@ bool LIB_COMPONENT::Save( FILE* aFile )
return
true
;
}
bool
LIB_COMPONENT
::
Load
(
FILE
*
aFile
,
char
*
aLine
,
int
*
aLineNum
,
wxString
&
aErrorMsg
)
{
...
...
@@ -832,8 +854,8 @@ bool LIB_COMPONENT::LoadDrawEntries( FILE* aFile, char* aLine,
{
if
(
GetLine
(
aFile
,
aLine
,
aLineNum
,
LINE_BUFFER_LEN_LARGE
)
==
NULL
)
{
aErrorMsg
=
wxT
(
"file ended prematurely while attempting
\
to flush to end of drawing section."
);
aErrorMsg
=
wxT
(
"file ended prematurely while attempting
"
"
to flush to end of drawing section."
);
return
false
;
}
}
while
(
strncmp
(
aLine
,
"ENDDRAW"
,
7
)
!=
0
);
...
...
@@ -868,21 +890,26 @@ bool LIB_COMPONENT::LoadField( char* aLine, wxString& aErrorMsg )
{
LIB_FIELD
*
field
=
new
LIB_FIELD
(
this
);
if
(
!
field
->
Load
(
aLine
,
aErrorMsg
)
)
if
(
!
field
->
Load
(
aLine
,
aErrorMsg
)
)
{
SAFE_DELETE
(
field
);
return
false
;
}
if
(
field
->
m_FieldId
==
REFERENCE
)
{
GetReferenceField
()
=
*
field
;
SAFE_DELETE
(
field
);
}
else
if
(
field
->
m_FieldId
==
VALUE
)
if
(
field
->
m_FieldId
<
MANDATORY_FIELDS
)
{
GetValueField
()
=
*
field
;
name
=
field
->
m_Text
;
LIB_FIELD
*
fixedField
=
GetField
(
field
->
m_FieldId
);
// this will fire only if somebody broke a constructor or editor.
// MANDATORY_FIELDS are alway present in ram resident components, no
// exceptions, and they always have their names set, even fixed fields.
wxASSERT
(
fixedField
);
*
fixedField
=
*
field
;
if
(
field
->
m_FieldId
==
VALUE
)
name
=
field
->
m_Text
;
SAFE_DELETE
(
field
);
}
else
...
...
@@ -932,6 +959,7 @@ EDA_Rect LIB_COMPONENT::GetBoundaryBox( int aUnit, int aConvert )
if
(
(
item
.
m_Unit
>
0
)
&&
(
(
unitCount
>
1
)
&&
(
aUnit
>
0
)
&&
(
aUnit
!=
item
.
m_Unit
)
)
)
continue
;
if
(
item
.
m_Convert
>
0
&&
(
(
aConvert
>
0
)
&&
(
aConvert
!=
item
.
m_Convert
)
)
)
continue
;
...
...
@@ -947,48 +975,69 @@ EDA_Rect LIB_COMPONENT::GetBoundaryBox( int aUnit, int aConvert )
}
/** Function SetFields
* initialize fields from a vector of fields
* @param aFields a std::vector <LIB_FIELD> to import.
*/
void
LIB_COMPONENT
::
SetFields
(
const
std
::
vector
<
LIB_FIELD
>
aFields
)
void
LIB_COMPONENT
::
deleteAllFields
()
{
LIB_
FIELD
*
field
;
LIB_
DRAW_ITEM_LIST
::
iterator
it
;
for
(
size_t
i
=
0
;
i
<
aFields
.
size
();
i
++
)
for
(
it
=
drawings
.
begin
();
it
!=
drawings
.
end
();
/* deleting */
)
{
field
=
GetField
(
aFields
[
i
].
m_FieldId
);
if
(
field
)
if
(
it
->
Type
()
!=
COMPONENT_FIELD_DRAW_TYPE
)
{
*
field
=
aFields
[
i
];
if
(
(
int
)
i
==
VALUE
)
name
=
field
->
m_Text
;
++
it
;
continue
;
}
/* If the field isn't set, don't add it to the component. */
if
(
aFields
[
i
].
m_Text
.
IsEmpty
()
)
continue
;
// 'it' is not advanced, but should point to next in list after erase()
drawings
.
erase
(
it
);
}
}
void
LIB_COMPONENT
::
SetFields
(
const
std
::
vector
<
LIB_FIELD
>&
aFields
)
{
deleteAllFields
();
for
(
unsigned
i
=
0
;
i
<
aFields
.
size
();
++
i
)
{
// drawings is a ptr_vector, new and copy an object on the heap.
LIB_FIELD
*
field
=
new
LIB_FIELD
(
aFields
[
i
]
);
field
=
new
LIB_FIELD
(
aFields
[
i
]
);
drawings
.
push_back
(
field
);
}
drawings
.
sort
();
drawings
.
sort
();
// would be nice to know why...
}
void
LIB_COMPONENT
::
GetFields
(
LIB_FIELD_LIST
&
aList
)
{
LIB_FIELD
*
field
;
// The only caller of this function is the library field editor, so it
// establishes policy here.
// Grab the MANDATORY_FIELDS first, in expected order given by
// enum NumFieldType
for
(
int
id
=
0
;
id
<
MANDATORY_FIELDS
;
++
id
)
{
field
=
GetField
(
id
);
// the MANDATORY_FIELDS are exactly that in RAM.
wxASSERT
(
field
);
aList
.
push_back
(
*
field
);
}
// Now grab all the rest of fields.
BOOST_FOREACH
(
LIB_DRAW_ITEM
&
item
,
drawings
)
{
if
(
item
.
Type
()
!=
COMPONENT_FIELD_DRAW_TYPE
)
continue
;
LIB_FIELD
*
field
=
(
LIB_FIELD
*
)
&
item
;
field
=
(
LIB_FIELD
*
)
&
item
;
if
(
(
unsigned
)
field
->
m_FieldId
<
MANDATORY_FIELDS
)
continue
;
// was added above
aList
.
push_back
(
*
field
);
}
}
...
...
@@ -1011,6 +1060,23 @@ LIB_FIELD* LIB_COMPONENT::GetField( int aId )
}
LIB_FIELD
*
LIB_COMPONENT
::
FindField
(
const
wxString
&
aFieldName
)
{
BOOST_FOREACH
(
LIB_DRAW_ITEM
&
item
,
drawings
)
{
if
(
item
.
Type
()
!=
COMPONENT_FIELD_DRAW_TYPE
)
continue
;
LIB_FIELD
*
field
=
(
LIB_FIELD
*
)
&
item
;
if
(
field
->
m_Name
==
aFieldName
)
return
field
;
}
return
NULL
;
}
LIB_FIELD
&
LIB_COMPONENT
::
GetValueField
()
{
LIB_FIELD
*
field
=
GetField
(
VALUE
);
...
...
eeschema/class_libentry.h
View file @
f3d5c494
...
...
@@ -118,9 +118,9 @@ public:
}
};
typedef
boost
::
ptr_vector
<
CMP_LIB_ENTRY
>
LIB_ENTRY_LIST
;
extern
bool
operator
<
(
const
CMP_LIB_ENTRY
&
aItem1
,
const
CMP_LIB_ENTRY
&
aItem2
);
extern
int
LibraryEntryCompare
(
const
CMP_LIB_ENTRY
*
aItem1
,
const
CMP_LIB_ENTRY
*
aItem2
);
...
...
@@ -183,6 +183,9 @@ private:
* Used only by the component editor LibEdit
* to store aliases info during edition
* usually void outside the component editor */
void
deleteAllFields
();
public
:
LIB_COMPONENT
(
const
wxString
&
aName
,
CMP_LIBRARY
*
aLibrary
=
NULL
);
LIB_COMPONENT
(
LIB_COMPONENT
&
aComponent
,
CMP_LIBRARY
*
aLibrary
=
NULL
);
...
...
@@ -301,19 +304,32 @@ public:
void
SetNormal
()
{
m_options
=
ENTRY_NORMAL
;
}
/**
* Initialize fields from a vector of fields.
* Function SetFields
* overwrites all the existing in this component with fields supplied
* in \a aFieldsList. The only known caller of this function is the
* library component field editor, and it establishes needed behavior.
*
* @param aFields
- a std::vector <LIB_FIELD> to import
.
* @param aFields
List is a set of fields to import, removing all previous fields
.
*/
void
SetFields
(
const
std
::
vector
<
LIB_FIELD
>
aFields
);
void
SetFields
(
const
std
::
vector
<
LIB_FIELD
>
&
aFieldsList
);
/**
* Return list of field references of component.
* Function GetFields
* returns a list of fields withing this component. The only known caller of
* this function is the library component field editor, and it establishes
* needed behavior.
*
* @param aList - List to add field
references to.
* @param aList - List to add field
s to
*/
void
GetFields
(
LIB_FIELD_LIST
&
aList
);
/**
* Function FindField
* finds a field within this component matching \a aFieldName and returns
* it or NULL if not found.
*/
LIB_FIELD
*
FindField
(
const
wxString
&
aFieldName
);
/**
* Return pointer to the requested field.
*
...
...
eeschema/class_libentry_fields.cpp
View file @
f3d5c494
...
...
@@ -3,6 +3,7 @@
/**********************************************************/
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "gr_basic.h"
#include "common.h"
#include "base_struct.h"
...
...
@@ -35,8 +36,8 @@
*
* 0 = REFERENCE
* 1 = VALUE
*
3
= FOOTPRINT (default Footprint)
*
4
= DOCUMENTATION (user doc link)
*
2
= FOOTPRINT (default Footprint)
*
3
= DOCUMENTATION (user doc link)
*
* others = free fields
*/
...
...
@@ -81,6 +82,11 @@ void LIB_FIELD::Init( int id )
m_FieldId
=
id
;
m_Size
.
x
=
m_Size
.
y
=
DEFAULT_SIZE_TEXT
;
m_typeName
=
_
(
"Field"
);
// fields in RAM must always have names, because we are trying to get
// less dependent on field ids and more dependent on names.
// Plus assumptions are made in the field editors.
m_Name
=
TEMPLATE_FIELDNAME
::
GetDefaultFieldName
(
id
);
}
...
...
@@ -94,13 +100,16 @@ bool LIB_FIELD::Save( FILE* ExportFile )
hjustify
=
'L'
;
else
if
(
m_HJustify
==
GR_TEXT_HJUSTIFY_RIGHT
)
hjustify
=
'R'
;
vjustify
=
'C'
;
if
(
m_VJustify
==
GR_TEXT_VJUSTIFY_BOTTOM
)
vjustify
=
'B'
;
else
if
(
m_VJustify
==
GR_TEXT_VJUSTIFY_TOP
)
vjustify
=
'T'
;
if
(
text
.
IsEmpty
()
)
text
=
wxT
(
"~"
);
if
(
fprintf
(
ExportFile
,
"F%d
\"
%s
\"
%d %d %d %c %c %c %c%c%c"
,
m_FieldId
,
CONV_TO_UTF8
(
text
),
m_Pos
.
x
,
m_Pos
.
y
,
m_Size
.
x
,
m_Orient
==
0
?
'H'
:
'V'
,
...
...
@@ -115,8 +124,10 @@ bool LIB_FIELD::Save( FILE* ExportFile )
* Just because default name depends on the language and can change from
* a country to an other
*/
wxString
defName
=
TEMPLATE_FIELDNAME
::
GetDefaultFieldName
(
m_FieldId
);
if
(
m_FieldId
>=
FIELD1
&&
!
m_Name
.
IsEmpty
()
&&
m_Name
!=
ReturnDefaultFieldName
(
m_FieldId
)
&&
m_Name
!=
defName
&&
fprintf
(
ExportFile
,
"
\"
%s
\"
"
,
CONV_TO_UTF8
(
m_Name
)
)
<
0
)
return
false
;
...
...
@@ -177,8 +188,7 @@ bool LIB_FIELD::Load( char* line, wxString& errorMsg )
if
(
cnt
<
5
)
{
errorMsg
.
Printf
(
wxT
(
"field %d does not have the correct number of \
parameters"
),
errorMsg
.
Printf
(
wxT
(
"field %d does not have the correct number of parameters"
),
m_FieldId
);
return
false
;
}
...
...
@@ -192,8 +202,7 @@ parameters" ),
m_Orient
=
TEXT_ORIENT_VERT
;
else
{
errorMsg
.
Printf
(
wxT
(
"field %d text orientation parameter <%c> is \
not valid"
),
errorMsg
.
Printf
(
wxT
(
"field %d text orientation parameter <%c> is not valid"
),
textOrient
);
return
false
;
}
...
...
@@ -204,8 +213,7 @@ not valid" ),
m_Attributs
|=
TEXT_NO_VISIBLE
;
else
{
errorMsg
.
Printf
(
wxT
(
"field %d text visible parameter <%c> is not \
valid"
),
errorMsg
.
Printf
(
wxT
(
"field %d text visible parameter <%c> is not valid"
),
textVisible
);
return
false
;
}
...
...
@@ -223,9 +231,9 @@ valid" ),
m_HJustify
=
GR_TEXT_HJUSTIFY_RIGHT
;
else
{
errorMsg
.
Printf
(
wxT
(
"field %d text horizontal justification \
parameter <%c> is not valid"
),
textHJustify
);
errorMsg
.
Printf
(
wxT
(
"field %d text horizontal justification
parameter <%c> is not valid"
),
textHJustify
);
return
false
;
}
...
...
@@ -237,9 +245,9 @@ parameter <%c> is not valid" ),
m_VJustify
=
GR_TEXT_VJUSTIFY_TOP
;
else
{
errorMsg
.
Printf
(
wxT
(
"field %d text vertical justification \
parameter <%c> is not valid"
),
textVJustify
[
0
]
);
errorMsg
.
Printf
(
wxT
(
"field %d text vertical justification
parameter <%c> is not valid"
),
textVJustify
[
0
]
);
return
false
;
}
...
...
@@ -249,7 +257,15 @@ parameter <%c> is not valid" ),
m_Bold
=
true
;
}
if
(
m_FieldId
>=
FIELD1
)
// fields in RAM must always have names.
if
(
m_FieldId
<
MANDATORY_FIELDS
)
{
// Fields in RAM must always have names, because we are trying to get
// less dependent on field ids and more dependent on names.
// Plus assumptions are made in the field editors.
m_Name
=
TEMPLATE_FIELDNAME
::
GetDefaultFieldName
(
m_FieldId
);
}
else
{
ReadDelimitedText
(
fieldUserName
,
line
,
sizeof
(
fieldUserName
)
);
m_Name
=
CONV_FROM_UTF8
(
fieldUserName
);
...
...
@@ -259,7 +275,6 @@ parameter <%c> is not valid" ),
}
/** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
...
...
@@ -346,7 +361,9 @@ bool LIB_FIELD::HitTest( const wxPoint& refPos )
return
HitTest
(
refPos
,
0
,
DefaultTransformMatrix
);
}
/** Function HitTest
/**
* Function HitTest
* @return true if the point aPosRef is near this object
* @param aPosRef = a wxPoint to test
* @param aThreshold = unused here (TextHitTest calculates its threshold )
...
...
@@ -527,34 +544,3 @@ EDA_Rect LIB_FIELD::GetBoundingBox()
return
rect
;
}
/**
* Function ReturnDefaultFieldName
* Return the default field name from its index (REFERENCE, VALUE ..)
* FieldDefaultNameList is not static, because we want the text translation
* for I18n
* @param aFieldNdx = Filed number (>= 0)
*/
wxString
ReturnDefaultFieldName
(
int
aFieldNdx
)
{
// avoid unnecessarily copying wxStrings at runtime.
static
const
wxString
defaults
[]
=
{
_
(
"Reference"
),
// Reference of part, i.e. "IC21"
_
(
"Value"
),
// Value of part, i.e. "3.3K" and name in lib
// for lib entries
_
(
"Footprint"
),
// Footprint, used by cvpcb or pcbnew, i.e.
// "16DIP300"
_
(
"Datasheet"
),
// A link to an user document, if wanted
};
if
(
(
unsigned
)
aFieldNdx
<=
DATASHEET
)
return
defaults
[
aFieldNdx
];
else
{
wxString
ret
=
_
(
"Field"
);
ret
<<
(
aFieldNdx
-
FIELD1
+
1
);
return
ret
;
}
}
eeschema/class_libentry_fields.h
View file @
f3d5c494
...
...
@@ -9,32 +9,19 @@
#include "classes_body_items.h"
class
LIB_FIELD
;
typedef
std
::
vector
<
LIB_FIELD
>
LIB_FIELD_LIST
;
/* Fields , same as component fields.
* can be defined in libraries (mandatory for ref and value, ca be useful for
* footprints)
* 2 Fields are always defined :
* Prefix (U, IC..) with gives the reference in schematic)
* Name (74LS00..) used to find the component in libraries, and give the
* default value in schematic
/**
* Class LIB_FIELD
* is used in symbol libraries. At least MANDATORY_FIELDS are always present
* in a ram resident library symbol. All constructors must ensure this because
* the component property editor assumes it.
* @see enum NumFieldType
*/
class
LIB_FIELD
:
public
LIB_DRAW_ITEM
,
public
EDA_TextStruct
{
public
:
int
m_FieldId
;
/* 0 = REFERENCE
* 1 = VALUE
* 3 = FOOTPRINT (default Footprint)
* 4 = DOCUMENTATION (user doc link)
* others = free fields
*/
wxString
m_Name
;
/* Field Name (not the field text itself, that is
* .m_Text) */
int
m_FieldId
;
///< @see enum NumFieldType
wxString
m_Name
;
///< Name (not the field text value itself, that is .m_Text)
public
:
...
...
@@ -84,7 +71,8 @@ public:
int
aColor
,
int
aDrawMode
,
void
*
aData
,
const
int
aTransformMatrix
[
2
][
2
]
);
/** Function IsVisible
/**
* Function IsVisible
* @return true is this field is visible, false if flagged invisible
*/
bool
IsVisible
()
...
...
@@ -174,4 +162,6 @@ protected:
virtual
void
DoSetWidth
(
int
width
)
{
m_Width
=
width
;
}
};
typedef
std
::
vector
<
LIB_FIELD
>
LIB_FIELD_LIST
;
#endif // CLASS_LIBENTRY_FIELDS_H
eeschema/class_sch_cmp_field.h
View file @
f3d5c494
...
...
@@ -28,19 +28,18 @@ class LIB_FIELD;
class
SCH_FIELD
:
public
SCH_ITEM
,
public
EDA_TextStruct
{
public
:
int
m_FieldId
;
/* Field indicator type (REFERENCE, VALUE or
* other id) */
int
m_FieldId
;
///< Field index, @see enum NumFieldType
wxString
m_Name
;
/* Field name (ref, value,pcb, sheet, filed 1..
* and for fields 1 to 8 the name is editable
*/
bool
m_AddExtraText
;
/* Mainly for REFERENCE, add extra info
wxString
m_Name
;
bool
m_AddExtraText
;
/**< for REFERENCE, add extra info
* (for REFERENCE: add part selection text */
public
:
SCH_FIELD
(
const
wxPoint
&
aPos
,
int
aFieldId
,
SCH_COMPONENT
*
aParent
,
wxString
aName
=
wxEmptyString
);
~
SCH_FIELD
();
virtual
wxString
GetClass
()
const
...
...
eeschema/class_sch_component.cpp
View file @
f3d5c494
...
...
@@ -3,6 +3,7 @@
/**************************************************************/
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "class_drawpanel.h"
#include "gr_basic.h"
#include "common.h"
...
...
@@ -63,7 +64,6 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent,
const
wxPoint
&
pos
,
bool
setNewItemFlag
)
:
SCH_ITEM
(
NULL
,
TYPE_SCH_COMPONENT
)
{
Init
(
pos
);
m_Multi
=
unit
;
...
...
@@ -74,42 +74,39 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent,
if
(
setNewItemFlag
)
m_Flags
=
IS_NEW
|
IS_MOVED
;
// Import
pre
defined fields from the library component:
// Import
user
defined fields from the library component:
LIB_FIELD_LIST
libFields
;
libComponent
.
GetFields
(
libFields
);
for
(
size_t
i
=
0
;
i
<
libFields
.
size
();
i
++
)
for
(
LIB_FIELD_LIST
::
iterator
it
=
libFields
.
begin
();
it
!=
libFields
.
end
();
++
it
)
{
if
(
libFields
[
i
].
m_Text
.
IsEmpty
()
&&
libFields
[
i
].
m_Name
.
IsEmpty
()
)
// Can no longer insert an empty name, since names are now keys. The
// field index is not used beyond the first MANDATORY_FIELDS
if
(
it
->
m_Name
.
IsEmpty
()
)
continue
;
int
field_idx
=
libFields
[
i
].
m_FieldId
;
/* Add extra fields if library component has more than the default
* number of fields.
*/
if
(
field_idx
>=
GetFieldCount
()
)
// See if field by same name already exists.
SCH_FIELD
*
schField
=
FindField
(
it
->
m_Name
);
if
(
!
schField
)
{
while
(
field_idx
>=
GetFieldCount
()
)
{
SCH_FIELD
field
(
wxPoint
(
0
,
0
),
GetFieldCount
(),
this
,
ReturnDefaultFieldName
(
field_idx
)
);
AddField
(
field
);
}
SCH_FIELD
fld
(
wxPoint
(
0
,
0
),
GetFieldCount
(),
this
,
it
->
m_Name
);
schField
=
AddField
(
fld
);
}
SCH_FIELD
*
schField
=
GetField
(
field_idx
);
schField
->
m_Pos
=
m_Pos
+
libFields
[
i
].
m_Pos
;
schField
->
ImportValues
(
libFields
[
i
]
);
schField
->
m_Text
=
libFields
[
i
].
m_Text
;
schField
->
m_Name
=
(
field_idx
<
FIELD1
)
?
ReturnDefaultFieldName
(
field_idx
)
:
libFields
[
i
].
m_Name
;
}
schField
->
m_Pos
=
m_Pos
+
it
->
m_Pos
;
schField
->
ImportValues
(
*
it
);
schField
->
m_Text
=
it
->
m_Text
;
}
wxString
msg
=
libComponent
.
GetReferenceField
().
m_Text
;
if
(
msg
.
IsEmpty
()
)
msg
=
wxT
(
"U"
);
m_PrefixString
=
msg
;
// update the reference -- just the prefix for now.
...
...
@@ -147,20 +144,19 @@ SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aTemplate ) :
void
SCH_COMPONENT
::
Init
(
const
wxPoint
&
pos
)
{
m_Pos
=
pos
;
m_Multi
=
0
;
/
* In multi unit chip - which unit to draw. */
m_Convert
=
0
;
/
* De Morgan Handling */
m_Multi
=
0
;
/
/ In multi unit chip - which unit to draw.
m_Convert
=
0
;
/
/ De Morgan Handling
/
* The rotation/mirror transformation matrix. pos normal */
/
/ The rotation/mirror transformation matrix. pos normal
m_Transform
[
0
][
0
]
=
1
;
m_Transform
[
0
][
1
]
=
0
;
m_Transform
[
1
][
0
]
=
0
;
m_Transform
[
1
][
1
]
=
-
1
;
m_Fields
.
reserve
(
DEFAULT_NUMBER_OF_FIELDS
);
for
(
int
i
=
0
;
i
<
DEFAULT_NUMBER_OF_FIELDS
;
++
i
)
// construct only the mandatory fields, which are the first 4 only.
for
(
int
i
=
0
;
i
<
MANDATORY_FIELDS
;
++
i
)
{
SCH_FIELD
field
(
pos
,
i
,
this
,
Return
DefaultFieldName
(
i
)
);
SCH_FIELD
field
(
pos
,
i
,
this
,
TEMPLATE_FIELDNAME
::
Get
DefaultFieldName
(
i
)
);
if
(
i
==
REFERENCE
)
field
.
SetLayer
(
LAYER_REFERENCEPART
);
...
...
@@ -300,7 +296,7 @@ wxString SCH_COMPONENT::ReturnFieldName( int aFieldNdx ) const
if
(
!
field
->
m_Name
.
IsEmpty
()
)
return
field
->
m_Name
;
else
return
Return
DefaultFieldName
(
aFieldNdx
);
return
TEMPLATE_FIELDNAME
::
Get
DefaultFieldName
(
aFieldNdx
);
}
return
wxEmptyString
;
...
...
@@ -504,14 +500,27 @@ SCH_FIELD* SCH_COMPONENT::GetField( int aFieldNdx ) const
wxASSERT
(
field
);
// use cas
e
to remove const-ness
// use cas
t
to remove const-ness
return
(
SCH_FIELD
*
)
field
;
}
void
SCH_COMPONENT
::
AddField
(
const
SCH_FIELD
&
aField
)
SCH_FIELD
*
SCH_COMPONENT
::
AddField
(
const
SCH_FIELD
&
aField
)
{
int
newNdx
=
m_Fields
.
size
();
m_Fields
.
push_back
(
aField
);
return
&
m_Fields
[
newNdx
];
}
SCH_FIELD
*
SCH_COMPONENT
::
FindField
(
const
wxString
&
aFieldName
)
{
for
(
unsigned
i
=
0
;
i
<
m_Fields
.
size
();
++
i
)
{
if
(
aFieldName
==
m_Fields
[
i
].
m_Name
)
return
&
m_Fields
[
i
];
}
return
NULL
;
}
...
...
@@ -607,7 +616,7 @@ void SCH_COMPONENT::SwapData( SCH_COMPONENT* copyitem )
{
GetField
(
ii
)
->
SetParent
(
this
);
}
EXCHG
(
m_PathsAndReferences
,
copyitem
->
m_PathsAndReferences
);
}
...
...
@@ -1038,17 +1047,34 @@ bool SCH_COMPONENT::Save( FILE* f ) const
}
}
for
(
int
fieldNdx
=
0
;
fieldNdx
<
GetFieldCount
();
++
fieldNdx
)
// update the ugly field index, which I would like to see go away someday soon.
for
(
unsigned
i
=
0
;
i
<
m_Fields
.
size
();
++
i
)
{
SCH_FIELD
*
field
=
GetField
(
fieldNdx
);
wxString
defaultName
=
ReturnDefaultFieldName
(
fieldNdx
);
SCH_FIELD
*
fld
=
GetField
(
i
);
fld
->
m_FieldId
=
i
;
// we don't need field Ids, please be gone.
}
// only save the field if there is a value in the field or if field name
// is different than the default field name
if
(
field
->
m_Text
.
IsEmpty
()
&&
defaultName
==
field
->
m_Name
)
continue
;
// Fixed fields:
// Save fixed fields which are non blank.
for
(
unsigned
i
=
0
;
i
<
MANDATORY_FIELDS
;
++
i
)
{
SCH_FIELD
*
fld
=
GetField
(
i
);
if
(
!
fld
->
m_Text
.
IsEmpty
()
)
{
if
(
!
fld
->
Save
(
f
)
)
return
false
;
}
}
if
(
!
field
->
Save
(
f
)
)
// User defined fields:
// The *policy* about which user defined fields are part of a symbol is now
// only in the dialog editors. No policy should be enforced here, simply
// save all the user defined fields, they are present because a dialog editor
// thought they should be. If you disagree, go fix the dialog editors.
for
(
unsigned
i
=
MANDATORY_FIELDS
;
i
<
m_Fields
.
size
();
++
i
)
{
SCH_FIELD
*
fld
=
GetField
(
i
);
if
(
!
fld
->
Save
(
f
)
)
return
false
;
}
...
...
eeschema/class_sch_component.h
View file @
f3d5c494
...
...
@@ -31,32 +31,6 @@ struct Error
}
};
/**
* Enum NumFieldType
* is the numbered set of all fields a SCH_COMPONENT can hold
* Note more than 8 user fields are allowed, but for efficiency reasons
* the defualt number of users fields is 8
*/
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
,
DEFAULT_NUMBER_OF_FIELDS
};
/// A container for several SCH_FIELD items
typedef
std
::
vector
<
SCH_FIELD
>
SCH_FIELDS
;
...
...
@@ -230,6 +204,8 @@ public:
*/
EDA_Rect
GetBoundingBox
();
//-----<Fields>-----------------------------------------------------------
/**
* Function ReturnFieldName
* returns the Field name given a field index like (REFERENCE, VALUE ..)
...
...
@@ -241,7 +217,7 @@ public:
/**
* Function GetField
* returns a field.
* @param aFieldNdx An index into the array of fields
* @param aFieldNdx An index into the array of fields
, not a field id.
* @return SCH_FIELD* - the field value or NULL if does not exist
*/
SCH_FIELD
*
GetField
(
int
aFieldNdx
)
const
;
...
...
@@ -251,14 +227,22 @@ public:
* adds a field to the component. The field is copied as it is put into
* the component.
* @param aField A const reference to the SCH_FIELD to add.
* @return SCH_FIELD* - the newly inserted field.
*/
SCH_FIELD
*
AddField
(
const
SCH_FIELD
&
aField
);
/**
* Function FindField
* searches for SCH_FIELD with \a aFieldName and returns it if found, else NULL.
*/
void
AddField
(
const
SCH_FIELD
&
aField
);
SCH_FIELD
*
FindField
(
const
wxString
&
aFieldName
);
void
SetFields
(
const
SCH_FIELDS
&
aFields
)
{
m_Fields
=
aFields
;
// vector copying, length is changed possibly
}
//-----</Fields>----------------------------------------------------------
/**
* Function GetFieldCount
...
...
eeschema/cmp_library_lexer.cpp
View file @
f3d5c494
...
...
@@ -3,4 +3,4 @@
* library file DSN lexer which will replace the current library and library
* document file formats.
*/
#include "cmp_library_
base
.cpp"
#include "cmp_library_
keywords
.cpp"
eeschema/dialog_edit_component_in_schematic.cpp
View file @
f3d5c494
This diff is collapsed.
Click to expand it.
eeschema/dialog_edit_component_in_schematic.h
View file @
f3d5c494
...
...
@@ -67,6 +67,8 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEM
void
deleteFieldButtonHandler
(
wxCommandEvent
&
event
);
void
moveUpButtonHandler
(
wxCommandEvent
&
event
);
SCH_FIELD
*
findField
(
const
wxString
&
aFieldName
);
protected
:
...
...
@@ -92,12 +94,6 @@ private:
for
(
unsigned
ii
=
FIELD1
;
ii
<
m_FieldsBuf
.
size
();
ii
++
)
setRowItem
(
ii
,
m_FieldsBuf
[
ii
]
);
}
/** Function reinitializeFieldsIdAndDefaultNames
* Calculates the field id and default name, after deleting a field
* or moving a field
*/
void
reinitializeFieldsIdAndDefaultNames
();
};
#endif // __dialog_edit_component_in_schematic__
eeschema/dialog_edit_libentry_fields_in_lib.cpp
View file @
f3d5c494
This diff is collapsed.
Click to expand it.
eeschema/dialog_eeschema_options.cpp
View file @
f3d5c494
...
...
@@ -40,3 +40,89 @@ void DIALOG_EESCHEMA_OPTIONS::SetGridSizes( const GridArray& grid_sizes,
m_choiceGridSize
->
SetSelection
(
select
);
}
void
DIALOG_EESCHEMA_OPTIONS
::
SetFieldName
(
int
aNdx
,
wxString
aName
)
{
switch
(
aNdx
)
{
case
0
:
m_fieldName1
->
SetValue
(
aName
);
break
;
case
1
:
m_fieldName2
->
SetValue
(
aName
);
break
;
case
2
:
m_fieldName3
->
SetValue
(
aName
);
break
;
case
3
:
m_fieldName4
->
SetValue
(
aName
);
break
;
case
4
:
m_fieldName5
->
SetValue
(
aName
);
break
;
case
5
:
m_fieldName6
->
SetValue
(
aName
);
break
;
case
6
:
m_fieldName7
->
SetValue
(
aName
);
break
;
case
7
:
m_fieldName8
->
SetValue
(
aName
);
break
;
default
:
break
;
}
}
wxString
DIALOG_EESCHEMA_OPTIONS
::
GetFieldName
(
int
aNdx
)
{
wxString
nme
;
switch
(
aNdx
)
{
case
0
:
nme
=
m_fieldName1
->
GetValue
();
break
;
case
1
:
nme
=
m_fieldName2
->
GetValue
();
break
;
case
2
:
nme
=
m_fieldName3
->
GetValue
();
break
;
case
3
:
nme
=
m_fieldName4
->
GetValue
();
break
;
case
4
:
nme
=
m_fieldName5
->
GetValue
();
break
;
case
5
:
nme
=
m_fieldName6
->
GetValue
();
break
;
case
6
:
nme
=
m_fieldName7
->
GetValue
();
break
;
case
7
:
nme
=
m_fieldName8
->
GetValue
();
break
;
default
:
break
;
}
return
nme
;
}
eeschema/dialog_eeschema_options.h
View file @
f3d5c494
...
...
@@ -11,7 +11,7 @@
class
DIALOG_EESCHEMA_OPTIONS
:
public
DIALOG_EESCHEMA_OPTIONS_BASE
{
public
:
DIALOG_EESCHEMA_OPTIONS
(
wxWindow
*
parent
);
DIALOG_EESCHEMA_OPTIONS
(
wxWindow
*
parent
);
void
SetUnits
(
const
wxArrayString
&
units
,
int
select
=
0
);
int
GetUnitsSelection
(
void
)
{
return
m_choiceUnits
->
GetSelection
();
}
...
...
@@ -91,6 +91,13 @@ public:
{
return
m_checkPageLimits
->
GetValue
();
}
/** Set the field \a aNdx textctrl to \a aName */
void
SetFieldName
(
int
aNdx
,
wxString
aName
);
/** Get the field \a aNdx name from the fields textctrl */
wxString
GetFieldName
(
int
aNdx
);
};
#endif // __dialog_eeschema_options__
eeschema/dialog_eeschema_options_base.cpp
View file @
f3d5c494
This diff is collapsed.
Click to expand it.
eeschema/dialog_eeschema_options_base.fbp
View file @
f3d5c494
This diff is collapsed.
Click to expand it.
eeschema/dialog_eeschema_options_base.h
View file @
f3d5c494
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_eeschema_options_base__
#define __dialog_eeschema_options_base__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/choice.h>
#include <wx/spinctrl.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_EESCHEMA_OPTIONS_BASE
///////////////////////////////////////////////////////////////////////////////
class
DIALOG_EESCHEMA_OPTIONS_BASE
:
public
wxDialog
{
DECLARE_EVENT_TABLE
()
private
:
// Private event handlers
void
_wxFB_OnChooseUnits
(
wxCommandEvent
&
event
){
OnChooseUnits
(
event
);
}
protected
:
wxStaticText
*
m_staticText2
;
wxChoice
*
m_choiceUnits
;
wxStaticText
*
m_staticText3
;
wxChoice
*
m_choiceGridSize
;
wxStaticText
*
m_staticGridUnits
;
wxStaticText
*
m_staticText5
;
wxSpinCtrl
*
m_spinLineWidth
;
wxStaticText
*
m_staticLineWidthUnits
;
wxStaticText
*
m_staticText7
;
wxSpinCtrl
*
m_spinTextSize
;
wxStaticText
*
m_staticTextSizeUnits
;
wxStaticText
*
m_staticText9
;
wxSpinCtrl
*
m_spinRepeatHorizontal
;
wxStaticText
*
m_staticRepeatXUnits
;
wxStaticText
*
m_staticText12
;
wxSpinCtrl
*
m_spinRepeatVertical
;
wxStaticText
*
m_staticRepeatYUnits
;
wxStaticText
*
m_staticText16
;
wxSpinCtrl
*
m_spinRepeatLabel
;
wxCheckBox
*
m_checkShowGrid
;
wxCheckBox
*
m_checkShowHiddenPins
;
wxCheckBox
*
m_checkAutoPan
;
wxCheckBox
*
m_checkHVOrientation
;
wxCheckBox
*
m_checkPageLimits
;
wxStdDialogButtonSizer
*
m_sdbSizer1
;
wxButton
*
m_sdbSizer1OK
;
wxButton
*
m_sdbSizer1Cancel
;
// Virtual event handlers, overide them in your derived class
virtual
void
OnChooseUnits
(
wxCommandEvent
&
event
){
event
.
Skip
();
}
public
:
DIALOG_EESCHEMA_OPTIONS_BASE
(
wxWindow
*
parent
,
wxWindowID
id
=
wxID_ANY
,
const
wxString
&
title
=
_
(
"Schematic Editor Options"
),
const
wxPoint
&
pos
=
wxDefaultPosition
,
const
wxSize
&
size
=
wxDefaultSize
,
long
style
=
wxDEFAULT_DIALOG_STYLE
|
wxRESIZE_BORDER
);
~
DIALOG_EESCHEMA_OPTIONS_BASE
();
};
#endif //__dialog_eeschema_options_base__
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 21 2009)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_eeschema_options_base__
#define __dialog_eeschema_options_base__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/choice.h>
#include <wx/spinctrl.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/panel.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/textctrl.h>
#include <wx/notebook.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_EESCHEMA_OPTIONS_BASE
///////////////////////////////////////////////////////////////////////////////
class
DIALOG_EESCHEMA_OPTIONS_BASE
:
public
wxDialog
{
DECLARE_EVENT_TABLE
()
private
:
// Private event handlers
void
_wxFB_OnChooseUnits
(
wxCommandEvent
&
event
){
OnChooseUnits
(
event
);
}
protected
:
wxNotebook
*
m_notebook1
;
wxPanel
*
m_panel1
;
wxStaticText
*
m_staticText2
;
wxChoice
*
m_choiceUnits
;
wxStaticText
*
m_staticText3
;
wxChoice
*
m_choiceGridSize
;
wxStaticText
*
m_staticGridUnits
;
wxStaticText
*
m_staticText5
;
wxSpinCtrl
*
m_spinLineWidth
;
wxStaticText
*
m_staticLineWidthUnits
;
wxStaticText
*
m_staticText7
;
wxSpinCtrl
*
m_spinTextSize
;
wxStaticText
*
m_staticTextSizeUnits
;
wxStaticText
*
m_staticText9
;
wxSpinCtrl
*
m_spinRepeatHorizontal
;
wxStaticText
*
m_staticRepeatXUnits
;
wxStaticText
*
m_staticText12
;
wxSpinCtrl
*
m_spinRepeatVertical
;
wxStaticText
*
m_staticRepeatYUnits
;
wxStaticText
*
m_staticText16
;
wxSpinCtrl
*
m_spinRepeatLabel
;
wxCheckBox
*
m_checkShowGrid
;
wxCheckBox
*
m_checkShowHiddenPins
;
wxCheckBox
*
m_checkAutoPan
;
wxCheckBox
*
m_checkHVOrientation
;
wxCheckBox
*
m_checkPageLimits
;
wxPanel
*
m_panel2
;
wxStaticText
*
m_staticText211
;
wxStaticText
*
m_staticText15
;
wxTextCtrl
*
m_fieldName1
;
wxStaticText
*
m_staticText161
;
wxTextCtrl
*
m_fieldName2
;
wxStaticText
*
m_staticText17
;
wxTextCtrl
*
m_fieldName3
;
wxStaticText
*
m_staticText18
;
wxTextCtrl
*
m_fieldName4
;
wxStaticText
*
m_staticText19
;
wxTextCtrl
*
m_fieldName5
;
wxStaticText
*
m_staticText20
;
wxTextCtrl
*
m_fieldName6
;
wxStaticText
*
m_staticText21
;
wxTextCtrl
*
m_fieldName7
;
wxStaticText
*
m_staticText22
;
wxTextCtrl
*
m_fieldName8
;
wxStdDialogButtonSizer
*
m_sdbSizer1
;
wxButton
*
m_sdbSizer1OK
;
wxButton
*
m_sdbSizer1Cancel
;
// Virtual event handlers, overide them in your derived class
virtual
void
OnChooseUnits
(
wxCommandEvent
&
event
)
{
event
.
Skip
();
}
public
:
DIALOG_EESCHEMA_OPTIONS_BASE
(
wxWindow
*
parent
,
wxWindowID
id
=
wxID_ANY
,
const
wxString
&
title
=
_
(
"Schematic Editor Options"
),
const
wxPoint
&
pos
=
wxDefaultPosition
,
const
wxSize
&
size
=
wxDefaultSize
,
long
style
=
wxDEFAULT_DIALOG_STYLE
|
wxRESIZE_BORDER
);
~
DIALOG_EESCHEMA_OPTIONS_BASE
();
};
#endif //__dialog_eeschema_options_base__
eeschema/eeschema_config.cpp
View file @
f3d5c494
...
...
@@ -22,16 +22,16 @@
#include <wx/fdrepdlg.h>
#define HOTKEY_FILENAME wxT( "eeschema" )
#define HOTKEY_FILENAME
wxT( "eeschema" )
#define FR_HISTORY_LIST_CNT 10 ///< Maximum number of find and replace strings.
#define FR_HISTORY_LIST_CNT
10 ///< Maximum number of find and replace strings.
void
WinEDA_LibeditFrame
::
Process_Config
(
wxCommandEvent
&
event
)
{
int
id
=
event
.
GetId
();
wxPoint
pos
;
wxFileName
fn
;
WinEDA_SchematicFrame
*
schFrame
=
(
WinEDA_SchematicFrame
*
)
GetParent
();
WinEDA_SchematicFrame
*
schFrame
=
(
WinEDA_SchematicFrame
*
)
GetParent
();
wxGetMousePosition
(
&
pos
.
x
,
&
pos
.
y
);
...
...
@@ -187,6 +187,7 @@ void WinEDA_SchematicFrame::OnSetOptions( wxCommandEvent& event )
wxLogDebug
(
wxT
(
"Current grid array index %d."
),
grid_list
.
Index
(
GetBaseScreen
()
->
GetGrid
()
)
);
units
.
Add
(
GetUnitsLabel
(
INCHES
)
);
units
.
Add
(
GetUnitsLabel
(
MILLIMETRE
)
);
...
...
@@ -206,12 +207,24 @@ void WinEDA_SchematicFrame::OnSetOptions( wxCommandEvent& event )
dlg
.
Fit
();
dlg
.
SetMinSize
(
dlg
.
GetSize
()
);
const
TEMPLATE_FIELDNAMES
&
tfnames
=
m_TemplateFieldNames
.
GetTemplateFieldNames
();
for
(
unsigned
i
=
0
;
i
<
tfnames
.
size
();
++
i
)
{
D
(
printf
(
"dlg.SetFieldName(%d, '%s')
\n
"
,
i
,
CONV_TO_UTF8
(
tfnames
[
i
].
m_Name
)
);)
dlg
.
SetFieldName
(
i
,
tfnames
[
i
].
m_Name
);
}
if
(
dlg
.
ShowModal
()
==
wxID_CANCEL
)
return
;
g_UnitMetric
=
dlg
.
GetUnitsSelection
();
GetBaseScreen
()
->
SetGrid
(
grid_list
[
(
size_t
)
dlg
.
GetGridSelection
()
].
m_Size
);
g_DrawDefaultLineThickness
=
dlg
.
GetLineWidth
();
g_DefaultTextLabelSize
=
dlg
.
GetTextSize
();
g_RepeatStep
.
x
=
dlg
.
GetRepeatHorizontal
();
...
...
@@ -222,6 +235,27 @@ void WinEDA_SchematicFrame::OnSetOptions( wxCommandEvent& event )
DrawPanel
->
m_AutoPAN_Enable
=
dlg
.
GetEnableAutoPan
();
g_HVLines
=
dlg
.
GetEnableHVBusOrientation
();
g_ShowPageLimits
=
dlg
.
GetShowPageLimits
();
wxString
templateFieldName
;
// @todo this will change when the template field editor is redone to
// look like the component field property editor, showing visibility and value also
DeleteAllTemplateFieldNames
();
for
(
int
i
=
0
;
i
<
8
;
++
i
)
// no. fields in this dialog window
{
templateFieldName
=
dlg
.
GetFieldName
(
i
);
if
(
!
templateFieldName
.
IsEmpty
()
)
{
TEMPLATE_FIELDNAME
fld
(
dlg
.
GetFieldName
(
i
)
);
// @todo set visibility and value also from a better editor
AddTemplateFieldName
(
fld
);
}
}
DrawPanel
->
Refresh
(
true
);
}
...
...
@@ -438,7 +472,7 @@ static const wxString FindStringEntry( wxT( "LastFindString" ) );
static
const
wxString
ReplaceStringEntry
(
wxT
(
"LastReplaceString"
)
);
static
const
wxString
FindStringHistoryEntry
(
wxT
(
"FindStringHistoryList%d"
)
);
static
const
wxString
ReplaceStringHistoryEntry
(
wxT
(
"ReplaceStringHistoryList%d"
)
);
static
const
wxString
FieldNamesEntry
(
wxT
(
"FieldNames"
)
);
/*
* Return the EESchema applications settings list.
...
...
@@ -614,6 +648,26 @@ void WinEDA_SchematicFrame::LoadSettings()
if
(
!
tmpHistory
.
IsEmpty
()
)
m_replaceStringHistoryList
.
Add
(
tmpHistory
);
}
wxString
templateFieldNames
=
cfg
->
Read
(
FieldNamesEntry
,
wxEmptyString
);
if
(
!
templateFieldNames
.
IsEmpty
()
)
{
std
::
string
dsnTxt
=
CONV_TO_UTF8
(
templateFieldNames
);
DSNLEXER
lexer
(
dsnTxt
,
DSN
::
template_fieldnames_keywords
,
DSN
::
template_fieldnames_keyword_count
);
try
{
m_TemplateFieldNames
.
Parse
(
&
lexer
);
}
catch
(
IOError
e
)
{
// @todo show error msg
D
(
printf
(
"templatefieldnames parsing error: '%s'
\n
"
,
CONV_TO_UTF8
(
e
.
errorText
)
);)
}
}
}
...
...
@@ -660,7 +714,7 @@ void WinEDA_SchematicFrame::SaveSettings()
/* Save the find and replace string history list. */
size_t
i
;
wxString
tmpHistory
;
wxString
entry
;
wxString
entry
;
// invoke constructor outside of any loops
for
(
i
=
0
;
i
<
m_findStringHistoryList
.
GetCount
()
&&
i
<
FR_HISTORY_LIST_CNT
;
i
++
)
{
...
...
@@ -673,4 +727,17 @@ void WinEDA_SchematicFrame::SaveSettings()
entry
.
Printf
(
ReplaceStringHistoryEntry
,
i
);
cfg
->
Write
(
entry
,
m_replaceStringHistoryList
[
i
]
);
}
// Save template fieldnames
STRINGFORMATTER
sf
;
m_TemplateFieldNames
.
Format
(
&
sf
,
0
);
wxString
record
=
CONV_FROM_UTF8
(
sf
.
GetString
().
c_str
()
);
record
.
Replace
(
wxT
(
"
\n
"
),
wxT
(
""
),
true
);
// strip all newlines
record
.
Replace
(
wxT
(
" "
),
wxT
(
" "
),
true
);
// double space to single
cfg
->
Write
(
FieldNamesEntry
,
record
);
}
eeschema/read_from_file_schematic_items_descriptions.cpp
View file @
f3d5c494
...
...
@@ -506,7 +506,6 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, wxString& aMsgDiag,
char
*
ptcar
;
wxString
fieldName
;
component
=
new
SCH_COMPONENT
();
component
->
m_Convert
=
1
;
...
...
@@ -703,7 +702,7 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, wxString& aMsgDiag,
ReadDelimitedText
(
FieldUserName
,
ptcar
,
sizeof
(
FieldUserName
)
);
if
(
!
FieldUserName
[
0
]
)
fieldName
=
Return
DefaultFieldName
(
fieldNdx
);
fieldName
=
TEMPLATE_FIELDNAME
::
Get
DefaultFieldName
(
fieldNdx
);
else
fieldName
=
CONV_FROM_UTF8
(
FieldUserName
);
...
...
eeschema/template_fieldnames.cpp
0 → 100644
View file @
f3d5c494
#include "template_fieldnames.h"
//#include "class_sch_component.h"
#include "dsnlexer.h"
#include "macros.h"
using
namespace
DSN
;
// enum TFIELD_T is in this namespace
wxString
TEMPLATE_FIELDNAME
::
GetDefaultFieldName
(
int
aFieldNdx
)
{
// Fixed values for the first few default fields used by EESCHEMA
static
const
wxString
fixedNames
[]
=
{
_
(
"Reference"
),
// The component reference, R1, C1, etc.
_
(
"Value"
),
// The component value + name
_
(
"Footprint"
),
// The footprint for use with PCBNEW
_
(
"Datasheet"
),
// Link to a datasheet for component
};
if
(
(
unsigned
)
aFieldNdx
<
DIM
(
fixedNames
)
)
return
fixedNames
[
aFieldNdx
];
else
{
wxString
fieldName
=
_
(
"Field"
);
fieldName
<<
aFieldNdx
;
return
fieldName
;
}
}
void
TEMPLATE_FIELDNAME
::
Format
(
OUTPUTFORMATTER
*
out
,
int
nestLevel
)
const
throw
(
IOError
)
{
// user may want spaces in his field name, ug, so quote them for the parser.
out
->
Print
(
nestLevel
,
"(field (name
\"
%s
\"
)"
,
CONV_TO_UTF8
(
m_Name
)
);
if
(
!
m_Value
.
IsEmpty
()
)
out
->
Print
(
0
,
"(value
\"
%s
\"
)"
,
CONV_TO_UTF8
(
m_Value
)
);
if
(
m_Visible
)
out
->
Print
(
0
,
" visible"
);
out
->
Print
(
0
,
")
\n
"
);
}
void
TEMPLATE_FIELDNAME
::
Parse
(
DSNLEXER
*
in
)
throw
(
IOError
)
{
TFIELD_T
tok
;
if
(
(
tok
=
(
TFIELD_T
)
in
->
NextTok
())
!=
T_LEFT
)
in
->
Expecting
(
T_LEFT
);
if
(
(
tok
=
(
TFIELD_T
)
in
->
NextTok
())
!=
T_name
)
in
->
Expecting
(
T_name
);
if
(
(
tok
=
(
TFIELD_T
)
in
->
NextTok
())
!=
T_SYMBOL
&&
tok
!=
T_STRING
)
in
->
Expecting
(
_
(
"field's name"
)
);
m_Name
=
CONV_FROM_UTF8
(
in
->
CurText
()
);
if
(
(
tok
=
(
TFIELD_T
)
in
->
NextTok
())
!=
T_RIGHT
)
in
->
Expecting
(
T_RIGHT
);
while
(
(
tok
=
(
TFIELD_T
)
in
->
NextTok
()
)
!=
T_RIGHT
&&
tok
!=
T_EOF
)
{
if
(
tok
==
T_LEFT
)
tok
=
(
TFIELD_T
)
in
->
NextTok
();
switch
(
tok
)
{
case
T_value
:
if
(
(
tok
=
(
TFIELD_T
)
in
->
NextTok
())
!=
T_SYMBOL
&&
tok
!=
T_STRING
)
in
->
Expecting
(
_
(
"field's value"
)
);
m_Value
=
CONV_FROM_UTF8
(
in
->
CurText
()
);
if
(
(
tok
=
(
TFIELD_T
)
in
->
NextTok
())
!=
T_RIGHT
)
in
->
Expecting
(
T_RIGHT
);
break
;
case
T_visible
:
m_Visible
=
true
;
break
;
default
:
in
->
Unexpected
(
CONV_FROM_UTF8
(
in
->
CurText
()
)
);
break
;
}
}
}
void
TEMPLATES
::
Format
(
OUTPUTFORMATTER
*
out
,
int
nestLevel
)
const
throw
(
IOError
)
{
// We'll keep this general even though the only know use at this time
// will not want the newlines or the indentation.
out
->
Print
(
nestLevel
,
"(templatefields"
);
for
(
unsigned
i
=
0
;
i
<
m_Fields
.
size
();
++
i
)
m_Fields
[
i
].
Format
(
out
,
nestLevel
+
1
);
out
->
Print
(
0
,
")
\n
"
);
}
void
TEMPLATES
::
Parse
(
DSNLEXER
*
in
)
throw
(
IOError
)
{
TFIELD_T
tok
;
while
(
(
tok
=
(
TFIELD_T
)
in
->
NextTok
()
)
!=
T_RIGHT
&&
tok
!=
T_EOF
)
{
if
(
tok
==
T_LEFT
)
tok
=
(
TFIELD_T
)
in
->
NextTok
();
switch
(
tok
)
{
case
T_templatefields
:
// a token indicating class TEMPLATES.
// Be flexible regarding the starting point of the DSNLEXER
// stream. Caller may not have read the first two tokens out of the
// stream: T_LEFT and T_templatefields, so ignore them if seen here.
break
;
case
T_field
:
{
// instantiate on stack, so if exception is thrown,
// destructor runs
TEMPLATE_FIELDNAME
field
;
field
.
Parse
(
in
);
// add the field
AddTemplateFieldName
(
field
);
}
break
;
default
:
in
->
Unexpected
(
CONV_FROM_UTF8
(
in
->
CurText
()
)
);
break
;
}
}
D
(
printf
(
"tok:%d
\n
"
,
tok
);)
}
int
TEMPLATES
::
AddTemplateFieldName
(
const
TEMPLATE_FIELDNAME
&
aFieldName
)
{
// Ensure that the template fieldname does not match a fixed fieldname.
for
(
int
i
=
0
;
i
<
MANDATORY_FIELDS
;
++
i
)
{
if
(
TEMPLATE_FIELDNAME
::
GetDefaultFieldName
(
i
)
==
aFieldName
.
m_Name
)
{
return
-
1
;
}
}
// ensure uniqueness, overwrite any template fieldname by the same name.
for
(
unsigned
i
=
0
;
i
<
m_Fields
.
size
();
++
i
)
{
if
(
m_Fields
[
i
].
m_Name
==
aFieldName
.
m_Name
)
{
D
(
printf
(
"inserting template fieldname:'%s' at %d
\n
"
,
CONV_TO_UTF8
(
aFieldName
.
m_Name
),
i
);)
m_Fields
[
i
]
=
aFieldName
;
return
i
;
// return the container index
}
}
// D(printf("appending template fieldname:'%s'\n", CONV_TO_UTF8(aFieldName.m_Name) );)
// the name is legal and not previously added to the config container, append
// it and return its index within the container.
m_Fields
.
push_back
(
aFieldName
);
return
m_Fields
.
size
()
-
1
;
// return the index of insertion.
}
eeschema/template_fieldnames.h
0 → 100644
View file @
f3d5c494
#ifndef _TEMPLATE_FIELDNAME_H_
#define _TEMPLATE_FIELDNAME_H_
#include "richio.h"
#include "wxstruct.h"
#include "macros.h"
#include "template_fieldnames_keywords.h"
class
DSNLEXER
;
/**
* Enum NumFieldType
* is the set of all field indices assuming an array like sequence that a
* SCH_COMPONENT or LIB_COMPONENT can hold.
* The first fields are called fixed fields and the quantity of them is
* given by MANDATORY_FIELDS. After that come an unlimited number of
* user defined fields, only some of which have indices defined here.
*/
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
MANDATORY_FIELDS
,
///< the first 4 are mandatory or fixed, and instantiated in FIELD constructors
FIELD1
=
MANDATORY_FIELDS
,
FIELD2
,
FIELD3
,
FIELD4
,
FIELD5
,
FIELD6
,
FIELD7
,
FIELD8
,
};
/**
* Struct TEMPLATE_FIELDNAME
* holds a name of a component's field, field value, and default visibility.
* Template fieldnames are wanted fieldnames for use in the symbol/component
* property editors.
*/
struct
TEMPLATE_FIELDNAME
{
wxString
m_Name
;
///< The field name
wxString
m_Value
;
///< The default value or empty
bool
m_Visible
;
///< If first appearance of the field's editor has as visible.
TEMPLATE_FIELDNAME
()
:
m_Visible
(
false
)
{
}
TEMPLATE_FIELDNAME
(
const
wxString
&
aName
)
:
m_Name
(
aName
),
m_Visible
(
false
)
{
}
/**
* Function Format
* serializes this object out as text into the given OUTPUTFORMATTER.
*/
void
Format
(
OUTPUTFORMATTER
*
out
,
int
nestLevel
)
const
throw
(
IOError
);
/**
* Function Parse
* fills this object from information in the input stream \a aSpec, which
* is a DSNLEXER. The entire textual element spec is <br>
* (field (name _yourfieldname_)(value _yourvalue_) visible)) <br>
* The presence of value is optional, the presence of visible is optional.
* When this function is called, the input token stream given by \a aSpec
* is assumed to be positioned at the '^' in the following example, i.e. just after the
* identifying keyword and before the content specifying stuff.<br>
* (field ^ (....) )
*
* @param aSpec is the input token stream of keywords and symbols.
*/
void
Parse
(
DSNLEXER
*
aSpec
)
throw
(
IOError
);
/**
* Function GetDefaultFieldName
* returns a default symbol field name for field \a aFieldNdx for all components.
* These fieldnames are not modifiable, but template fieldnames are.
* @param aFieldNdx The field number index, > 0
*/
static
wxString
GetDefaultFieldName
(
int
aFieldNdx
);
};
typedef
std
::
vector
<
TEMPLATE_FIELDNAME
>
TEMPLATE_FIELDNAMES
;
class
TEMPLATES
{
private
:
TEMPLATE_FIELDNAMES
m_Fields
;
public
:
/**
* Function Format
* serializes this object out as text into the given OUTPUTFORMATTER.
*/
void
Format
(
OUTPUTFORMATTER
*
out
,
int
nestLevel
)
const
throw
(
IOError
);
/**
* Function Parse
* fills this object from information in the input stream handled by DSNLEXER
*/
void
Parse
(
DSNLEXER
*
in
)
throw
(
IOError
);
/**
* Function AddTemplateFieldName
* inserts or appends a wanted symbol field name into the fieldnames
* template. Should be used for any symbol property editor. If the name
* already exists, it overwrites the same name.
*
* @param aFieldName is a full description of the wanted field, and it must not match
* any of the default fieldnames.
* @return int - the index within the config container at which aFieldName was
* added, or -1 if the name is illegal because it matches a default fieldname.
*/
int
AddTemplateFieldName
(
const
TEMPLATE_FIELDNAME
&
aFieldName
);
/**
* Function DeleteAllTemplateFieldNames
* deletes the entire contents.
*/
void
DeleteAllTemplateFieldNames
()
{
m_Fields
.
clear
();
}
/**
* Function GetTemplateFieldName
* returns a template fieldnames list for read only access.
*/
const
TEMPLATE_FIELDNAMES
&
GetTemplateFieldNames
()
{
return
m_Fields
;
}
};
#endif // _TEMPLATE_FIELDNAME_H_
eeschema/template_fieldnames.lst
0 → 100644
View file @
f3d5c494
field
name
templatefields
value
visible
include/dsnlexer.h
View file @
f3d5c494
...
...
@@ -230,13 +230,53 @@ public:
void
ThrowIOError
(
wxString
aText
,
int
charOffset
)
throw
(
IOError
);
/**
* Function GetTokenString
* Function Expecting
* throws an IOError exception with an input file specific error message.
* @param aTok is the token/keyword type which was expected at the current input location.
* @throw IOError with the location within the input file of the problem.
*/
void
Expecting
(
int
aTok
)
throw
(
IOError
);
/**
* Function Expecting
* throws an IOError exception with an input file specific error message.
* @param aErrorMsg is the token/keyword type which was expected at the
* current input location.
* @throw IOError with the location within the input file of the problem.
*/
void
Expecting
(
const
wxString
&
aErrorMsg
)
throw
(
IOError
);
/**
* Function Unexpected
* throws an IOError exception with an input file specific error message.
* @param aTok is the token/keyword type which was not expected at the
* current input location.
* @throw IOError with the location within the input file of the problem.
*/
void
Unexpected
(
int
aTok
)
throw
(
IOError
);
/**
* Function Unexpected
* throws an IOError exception with an input file specific error message.
* @param aErrorMsg is the token/keyword type which was not expected at the
* current input location.
* @throw IOError with the location within the input file of the problem.
*/
void
Unexpected
(
const
wxString
&
aErrorMsg
)
throw
(
IOError
);
/**
* Function GetTokenText
* returns the C string representation of a DSN_T value.
*/
const
char
*
GetTokenText
(
int
aTok
);
static
const
char
*
Syntax
(
int
aTok
);
/**
* Function GetTokenString
* returns a quote wrapped wxString representation of a token value.
*/
wxString
GetTokenString
(
int
aTok
);
static
const
char
*
Syntax
(
int
aTok
);
/**
* Function CurText
...
...
include/param_config.h
View file @
f3d5c494
...
...
@@ -11,8 +11,8 @@
#include <boost/ptr_container/ptr_vector.hpp>
/*
definifition des types de parametre des files de configuration
*/
enum
paramcfg_id
/* type du parametre dans la structure ParamConfig */
/*
* Type of parameter in the configuration file
*/
enum
paramcfg_id
{
PARAM_INT
,
PARAM_SETCOLOR
,
...
...
@@ -20,7 +20,8 @@ enum paramcfg_id /* type du parametre dans la structure ParamConfig */
PARAM_BOOL
,
PARAM_LIBNAME_LIST
,
PARAM_WXSTRING
,
PARAM_COMMAND_ERASE
PARAM_COMMAND_ERASE
,
PARAM_FIELDNAME_LIST
,
};
#define MAX_COLOR 0x8001F
...
...
@@ -29,36 +30,50 @@ enum paramcfg_id /* type du parametre dans la structure ParamConfig */
#define INT_MINVAL 0x80000000
#define INT_MAXVAL 0x7FFFFFFF
/**
* Class PARAM_CFG_BASE
* is a base class which establishes the virtual functions ReadParam and SaveParam,
* which are re-implemented by a number of base classes, and these function's
* doxygen comments are inherited also.
*/
class
PARAM_CFG_BASE
{
public
:
const
wxChar
*
m_Ident
;
/* Keyword in config data */
paramcfg_id
m_Type
;
/* Type of parameter */
const
wxChar
*
m_Group
;
/* Group name (tjis is like a path in the config data) */
bool
m_Setup
;
/* TRUE -> setup parameter (used for all projects), FALSE = parameter relative to a project */
const
wxChar
*
m_Ident
;
///< Keyword in config data
paramcfg_id
m_Type
;
///< Type of parameter
const
wxChar
*
m_Group
;
///< Group name (this is like a path in the config data)
bool
m_Setup
;
///< Install or Project based parameter, true == install
public
:
PARAM_CFG_BASE
(
const
wxChar
*
ident
,
const
paramcfg_id
type
,
const
wxChar
*
group
=
NULL
);
/** ReadParam
* read the value of parameter thi stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter
/**
* Function ReadParam
* reads the value of the parameter stored in aConfig
* @param aConfig = the wxConfigBase that holds the parameter
*/
virtual
void
ReadParam
(
wxConfigBase
*
aConfig
)
{};
/** SaveParam
* the the value of parameter thi stored in aConfig
/**
* Function SaveParam
* saves the value of the parameter stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter
*/
virtual
void
SaveParam
(
wxConfigBase
*
aConfig
)
{};
};
/**
* Configuration parameter - Integer Class
*
*/
class
PARAM_CFG_INT
:
public
PARAM_CFG_BASE
{
public
:
int
*
m_Pt_param
;
/* pointeur sur le parametre a configurer */
int
m_Min
,
m_Max
;
/* valeurs extremes du parametre */
int
m_Default
;
/* valeur par defaut */
int
*
m_Pt_param
;
///< Pointer to the parameter value
int
m_Min
,
m_Max
;
///< Minimum and maximum values of the param type
int
m_Default
;
///< The default value of the parameter
public
:
PARAM_CFG_INT
(
const
wxChar
*
ident
,
int
*
ptparam
,
...
...
@@ -68,24 +83,20 @@ public:
int
default_val
=
0
,
int
min
=
INT_MINVAL
,
int
max
=
INT_MAXVAL
,
const
wxChar
*
group
=
NULL
);
/** ReadParam
* read the value of parameter thi stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter
*/
virtual
void
ReadParam
(
wxConfigBase
*
aConfig
);
/** SaveParam
* the the value of parameter thi stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter
*/
virtual
void
SaveParam
(
wxConfigBase
*
aConfig
);
};
/**
* Configuration parameter - SetColor Class
*
*/
class
PARAM_CFG_SETCOLOR
:
public
PARAM_CFG_BASE
{
public
:
int
*
m_Pt_param
;
/* pointeur sur le parametre a configurer */
int
m_Default
;
/* valeur par defaut */
int
*
m_Pt_param
;
///< Pointer to the parameter value
int
m_Default
;
///< The default value of the parameter
public
:
PARAM_CFG_SETCOLOR
(
const
wxChar
*
ident
,
int
*
ptparam
,
...
...
@@ -93,25 +104,21 @@ public:
PARAM_CFG_SETCOLOR
(
bool
Insetup
,
const
wxChar
*
ident
,
int
*
ptparam
,
int
default_val
,
const
wxChar
*
group
=
NULL
);
/** ReadParam
* read the value of parameter thi stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter
*/
virtual
void
ReadParam
(
wxConfigBase
*
aConfig
);
/** SaveParam
* the the value of parameter thi stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter
*/
virtual
void
SaveParam
(
wxConfigBase
*
aConfig
);
};
/**
* Configuration parameter - Double Precision Class
*
*/
class
PARAM_CFG_DOUBLE
:
public
PARAM_CFG_BASE
{
public
:
double
*
m_Pt_param
;
/* pointeur sur le parametre a configurer */
double
m_Default
;
/* valeur par defaut */
double
m_Min
,
m_Max
;
/* valeurs extremes du parametre */
double
*
m_Pt_param
;
///< Pointer to the parameter value
double
m_Default
;
///< The default value of the parameter
double
m_Min
,
m_Max
;
///< Minimum and maximum values of the param type
public
:
PARAM_CFG_DOUBLE
(
const
wxChar
*
ident
,
double
*
ptparam
,
...
...
@@ -121,24 +128,20 @@ public:
double
default_val
=
0
.
0
,
double
min
=
0
.
0
,
double
max
=
10000
.
0
,
const
wxChar
*
group
=
NULL
);
/** ReadParam
* read the value of parameter thi stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter
*/
virtual
void
ReadParam
(
wxConfigBase
*
aConfig
);
/** SaveParam
* the the value of parameter thi stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter
*/
virtual
void
SaveParam
(
wxConfigBase
*
aConfig
);
};
/**
* Configuration parameter - Boolean Class
*
*/
class
PARAM_CFG_BOOL
:
public
PARAM_CFG_BASE
{
public
:
bool
*
m_Pt_param
;
/* pointeur sur le parametre a configurer */
int
m_Default
;
/* valeur par defaut */
bool
*
m_Pt_param
;
///< Pointer to the parameter value
int
m_Default
;
///< The default value of the parameter
public
:
PARAM_CFG_BOOL
(
const
wxChar
*
ident
,
bool
*
ptparam
,
...
...
@@ -146,24 +149,19 @@ public:
PARAM_CFG_BOOL
(
bool
Insetup
,
const
wxChar
*
ident
,
bool
*
ptparam
,
int
default_val
=
FALSE
,
const
wxChar
*
group
=
NULL
);
/** ReadParam
* read the value of parameter thi stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter
*/
virtual
void
ReadParam
(
wxConfigBase
*
aConfig
);
/** SaveParam
* the the value of parameter thi stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter
*/
virtual
void
SaveParam
(
wxConfigBase
*
aConfig
);
};
/**
* Configuration parameter - wxString Class
*
*/
class
PARAM_CFG_WXSTRING
:
public
PARAM_CFG_BASE
{
public
:
wxString
*
m_Pt_param
;
/* pointeur sur le parametre a configurer */
wxString
*
m_Pt_param
;
///< Pointer to the parameter value
public
:
PARAM_CFG_WXSTRING
(
const
wxChar
*
ident
,
wxString
*
ptparam
,
const
wxChar
*
group
=
NULL
);
...
...
@@ -171,42 +169,28 @@ public:
const
wxChar
*
ident
,
wxString
*
ptparam
,
const
wxChar
*
group
=
NULL
);
/** ReadParam
* read the value of parameter thi stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter
*/
virtual
void
ReadParam
(
wxConfigBase
*
aConfig
);
/** SaveParam
* the the value of parameter thi stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter
*/
virtual
void
ReadParam
(
wxConfigBase
*
aConfig
);
virtual
void
SaveParam
(
wxConfigBase
*
aConfig
);
};
class
PARAM_CFG_LIBNAME_LIST
:
public
PARAM_CFG_BASE
{
public
:
wxArrayString
*
m_Pt_param
;
/
* pointeur sur le parametre a configurer */
wxArrayString
*
m_Pt_param
;
/
//< Pointer to the parameter value
public
:
PARAM_CFG_LIBNAME_LIST
(
const
wxChar
*
ident
,
wxArrayString
*
ptparam
,
const
wxChar
*
group
=
NULL
);
/** ReadParam
* read the value of parameter thi stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter
*/
virtual
void
ReadParam
(
wxConfigBase
*
aConfig
);
/** SaveParam
* the the value of parameter thi stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter
*/
virtual
void
SaveParam
(
wxConfigBase
*
aConfig
);
};
/** A list of parameters type */
typedef
boost
::
ptr_vector
<
PARAM_CFG_BASE
>
PARAM_CFG_ARRAY
;
#endif
/* __PARAM_CONFIG_H__ */
include/wxEeschemaStruct.h
View file @
f3d5c494
...
...
@@ -8,6 +8,7 @@
#include "wxstruct.h"
#include "param_config.h"
#include "class_undoredo_container.h"
#include "template_fieldnames.h"
class
WinEDA_LibeditFrame
;
...
...
@@ -51,6 +52,7 @@ enum fl_rot_cmp
CMP_MIRROR_Y
=
0x200
// Mirror around Y axis
};
/**
* Schematic editor (EESchema) main window.
*/
...
...
@@ -68,6 +70,8 @@ public:
wxString
m_UserLibraryPath
;
wxArrayString
m_ComponentLibFiles
;
protected
:
TEMPLATES
m_TemplateFieldNames
;
private
:
wxString
m_DefaultSchematicFileName
;
...
...
@@ -108,6 +112,49 @@ public:
void
SaveProjectFile
(
wxWindow
*
displayframe
,
bool
askoverwrite
=
true
);
bool
LoadProjectFile
(
const
wxString
&
CfgFileName
,
bool
ForceRereadConfig
);
/**
* Function GetDefaultFieldName
* returns a default symbol field name for field \a aFieldNdx for all components.
* These fieldnames are not modifiable, but template fieldnames are.
* @param aFieldNdx The field number index
*/
static
wxString
GetDefaultFieldName
(
int
aFieldNdx
);
/**
* Function AddTemplateFieldName
* inserts or appends a wanted symbol field name into the fieldnames
* template. Should be used for any symbol property editor. If the name
* already exists, it overwrites the same name.
*
* @param aFieldName is a full description of the wanted field, and it must not match
* any of the default fieldnames.
* @return int - the index within the config container at which aFieldName was
* added, or -1 if the name is illegal because it matches a default fieldname.
*/
int
AddTemplateFieldName
(
const
TEMPLATE_FIELDNAME
&
aFieldName
)
{
return
m_TemplateFieldNames
.
AddTemplateFieldName
(
aFieldName
);
}
/**
* Function GetTemplateFieldName
* returns a template fieldnames list for read only access.
*/
const
TEMPLATE_FIELDNAMES
&
GetTemplateFieldNames
()
{
return
m_TemplateFieldNames
.
GetTemplateFieldNames
();
}
/**
* Function DeleteAllTemplateFieldNames
* removes all template fieldnames.
*/
void
DeleteAllTemplateFieldNames
()
{
m_TemplateFieldNames
.
DeleteAllTemplateFieldNames
();
}
PARAM_CFG_ARRAY
&
GetConfigurationSettings
(
void
);
void
LoadSettings
();
void
SaveSettings
();
...
...
pcbnew/specctra.cpp
View file @
f3d5c494
...
...
@@ -549,30 +549,24 @@ void SPECCTRA_DB::ThrowIOError( const wxChar* fmt, ... ) throw( IOError )
void
SPECCTRA_DB
::
expecting
(
DSN_T
aTok
)
throw
(
IOError
)
{
wxString
errText
(
_
(
"Expecting"
)
);
errText
<<
wxT
(
" "
)
<<
GetTokenString
(
aTok
);
lexer
->
ThrowIOError
(
errText
,
lexer
->
CurOffset
()
);
lexer
->
Expecting
(
aTok
);
}
void
SPECCTRA_DB
::
expecting
(
const
char
*
text
)
throw
(
IOError
)
{
wxString
errText
(
_
(
"Expecting"
)
);
errText
<<
wxT
(
" '"
)
<<
CONV_FROM_UTF8
(
text
)
<<
wxT
(
"'"
);
lexer
->
ThrowIOError
(
errText
,
lexer
->
CurOffset
()
);
wxString
errText
=
CONV_FROM_UTF8
(
text
);
lexer
->
Expecting
(
errText
);
}
void
SPECCTRA_DB
::
unexpected
(
DSN_T
aTok
)
throw
(
IOError
)
{
wxString
errText
(
_
(
"Unexpected"
)
);
errText
<<
wxT
(
" "
)
<<
GetTokenString
(
aTok
);
lexer
->
ThrowIOError
(
errText
,
lexer
->
CurOffset
()
);
lexer
->
Expecting
(
aTok
);
}
void
SPECCTRA_DB
::
unexpected
(
const
char
*
text
)
throw
(
IOError
)
{
wxString
errText
(
_
(
"Unexpected"
)
);
errText
<<
wxT
(
" '"
)
<<
CONV_FROM_UTF8
(
text
)
<<
wxT
(
"'"
);
lexer
->
ThrowIOError
(
errText
,
lexer
->
CurOffset
()
);
wxString
errText
=
CONV_FROM_UTF8
(
text
);
lexer
->
Unexpected
(
errText
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment