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
00008579
Commit
00008579
authored
Jun 21, 2010
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor enhancement
parent
7d2ff522
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
18 deletions
+40
-18
bitmap2cmp_gui.cpp
bitmap2component/bitmap2cmp_gui.cpp
+40
-18
No files found.
bitmap2component/bitmap2cmp_gui.cpp
View file @
00008579
...
...
@@ -23,6 +23,7 @@
*/
#include "wx/wx.h"
#include "wx/config.h"
#include "wx/filename.h"
#include "bitmap2cmp_gui_base.h"
...
...
@@ -32,10 +33,12 @@
#include "bitmap2component.xpm"
#define KEYWORD_FRAME_POSX wxT( "bmconverter_Pos_x" )
#define KEYWORD_FRAME_POSY wxT( "bmconverter_Pos_y" )
#define KEYWORD_FRAME_SIZEX wxT( "bmconverter_Size_x" )
#define KEYWORD_FRAME_SIZEY wxT( "bmconverter_Size_y" )
#define KEYWORD_FRAME_POSX wxT( "Bmconverter_Pos_x" )
#define KEYWORD_FRAME_POSY wxT( "Bmconverter_Pos_y" )
#define KEYWORD_FRAME_SIZEX wxT( "Bmconverter_Size_x" )
#define KEYWORD_FRAME_SIZEY wxT( "Bmconverter_Size_y" )
#define KEYWORD_LAST_INPUT_FILE wxT( "Last_input" )
#define KEYWORD_LAST_OUTPUT_FILE wxT( "Last_output" )
extern
int
bitmap2component
(
potrace_bitmap_t
*
aPotrace_bitmap
,
FILE
*
aOutfile
,
int
aFormat
);
...
...
@@ -51,7 +54,8 @@ private:
wxBitmap
m_Greyscale_Bitmap
;
wxImage
m_NB_Image
;
wxBitmap
m_BN_Bitmap
;
wxString
m_ImgFileName
;
wxString
m_BitmapFileName
;
wxString
m_ConvertedFileName
;
wxSize
m_FrameSize
;
wxPoint
m_FramePos
;
wxConfig
*
m_Config
;
...
...
@@ -81,6 +85,8 @@ BM2CMP_FRAME::BM2CMP_FRAME() : BM2CMP_FRAME_BASE( NULL )
m_Config
->
Read
(
KEYWORD_FRAME_POSY
,
&
m_FramePos
.
y
,
-
1
);
m_Config
->
Read
(
KEYWORD_FRAME_SIZEX
,
&
m_FrameSize
.
x
,
-
1
);
m_Config
->
Read
(
KEYWORD_FRAME_SIZEY
,
&
m_FrameSize
.
y
,
-
1
);
m_Config
->
Read
(
KEYWORD_LAST_INPUT_FILE
,
&
m_BitmapFileName
);
m_Config
->
Read
(
KEYWORD_LAST_OUTPUT_FILE
,
&
m_ConvertedFileName
);
#ifdef __WINDOWS__
SetIcon
(
wxICON
(
bitmap2component_icon
)
);
...
...
@@ -89,8 +95,8 @@ BM2CMP_FRAME::BM2CMP_FRAME() : BM2CMP_FRAME_BASE( NULL )
#endif
wxString
msg
(
wxT
(
"000000"
)
);
m_gridInfo
->
SetCellValue
(
0
,
0
,
msg
);
m_gridInfo
->
SetCellValue
(
1
,
0
,
msg
);
m_gridInfo
->
SetCellValue
(
2
,
0
,
msg
);
if
(
GetSizer
()
)
{
GetSizer
()
->
SetSizeHints
(
this
);
...
...
@@ -114,6 +120,8 @@ BM2CMP_FRAME::~BM2CMP_FRAME()
m_Config
->
Write
(
KEYWORD_FRAME_POSY
,
(
long
)
m_FramePos
.
y
);
m_Config
->
Write
(
KEYWORD_FRAME_SIZEX
,
(
long
)
m_FrameSize
.
x
);
m_Config
->
Write
(
KEYWORD_FRAME_SIZEY
,
(
long
)
m_FrameSize
.
y
);
m_Config
->
Write
(
KEYWORD_LAST_INPUT_FILE
,
m_BitmapFileName
);
m_Config
->
Write
(
KEYWORD_LAST_OUTPUT_FILE
,
m_ConvertedFileName
);
delete
m_Config
;
...
...
@@ -142,18 +150,24 @@ void BM2CMP_FRAME::OnPaint( wxPaintEvent& event )
*/
void
BM2CMP_FRAME
::
OnLoadFile
(
wxCommandEvent
&
event
)
{
wxFileDialog
FileDlg
(
this
,
_
(
"Choose Image"
),
::
wxGetCwd
(),
wxEmptyString
,
wxFileName
fn
(
m_BitmapFileName
);
wxString
path
=
fn
.
GetPath
();
if
(
path
.
IsEmpty
()
||
!
wxDirExists
(
path
)
)
path
=
wxGetCwd
();
wxFileDialog
FileDlg
(
this
,
_
(
"Choose Image"
),
path
,
wxEmptyString
,
_
(
"Image Files "
)
+
wxImage
::
GetImageExtWildcard
(),
wxFD_OPEN
);
int
diag
=
FileDlg
.
ShowModal
();
if
(
diag
!=
wxID_OK
)
return
;
m_ImgFileName
=
FileDlg
.
GetPath
();
if
(
!
m_Pict_Image
.
LoadFile
(
m_ImgFileName
)
)
m_BitmapFileName
=
FileDlg
.
GetPath
();
if
(
!
m_Pict_Image
.
LoadFile
(
m_BitmapFileName
)
)
{
wxMessageBox
(
_
(
"Couldn't load image from
'%s'."
),
m_Img
FileName
.
c_str
()
);
wxMessageBox
(
_
(
"Couldn't load image from
<%s>"
),
m_Bitmap
FileName
.
c_str
()
);
return
;
}
...
...
@@ -242,22 +256,26 @@ void BM2CMP_FRAME::OnThresholdChange( wxScrollEvent& event )
void
BM2CMP_FRAME
::
OnExportEeschema
(
wxCommandEvent
&
event
)
{
wxFileName
fn
(
m_ConvertedFileName
);
wxString
path
=
fn
.
GetPath
();
if
(
path
.
IsEmpty
()
||
!
wxDirExists
(
path
)
)
path
=
::
wxGetCwd
();
wxString
msg
=
_
(
"Schematic lib file (*.lib)|*.lib"
);
wxFileDialog
FileDlg
(
this
,
_
(
"Create lib file"
),
::
wxGetCwd
()
,
wxEmptyString
,
wxFileDialog
FileDlg
(
this
,
_
(
"Create lib file"
),
path
,
wxEmptyString
,
msg
,
wxFD_SAVE
|
wxFD_OVERWRITE_PROMPT
);
int
diag
=
FileDlg
.
ShowModal
();
if
(
diag
!=
wxID_OK
)
return
;
wxString
filen
ame
=
FileDlg
.
GetPath
();
m_ConvertedFileN
ame
=
FileDlg
.
GetPath
();
FILE
*
outfile
;
outfile
=
wxFopen
(
filen
ame
,
wxT
(
"w"
)
);
outfile
=
wxFopen
(
m_ConvertedFileN
ame
,
wxT
(
"w"
)
);
if
(
outfile
==
NULL
)
{
wxString
msg
;
msg
.
Printf
(
_
(
"File %s could not be created"
),
filen
ame
.
c_str
()
);
msg
.
Printf
(
_
(
"File %s could not be created"
),
m_ConvertedFileN
ame
.
c_str
()
);
wxMessageBox
(
msg
);
return
;
}
...
...
@@ -269,22 +287,26 @@ void BM2CMP_FRAME::OnExportEeschema( wxCommandEvent& event )
void
BM2CMP_FRAME
::
OnExportPcbnew
(
wxCommandEvent
&
event
)
{
wxFileName
fn
(
m_ConvertedFileName
);
wxString
path
=
fn
.
GetPath
();
if
(
path
.
IsEmpty
()
||
!
wxDirExists
(
path
)
)
path
=
::
wxGetCwd
();
wxString
msg
=
_
(
"Footprint export file (*.emp)|*.emp"
);
wxFileDialog
FileDlg
(
this
,
_
(
"Create footprint export file"
),
::
wxGetCwd
()
,
wxEmptyString
,
wxFileDialog
FileDlg
(
this
,
_
(
"Create footprint export file"
),
path
,
wxEmptyString
,
msg
,
wxFD_SAVE
|
wxFD_OVERWRITE_PROMPT
);
int
diag
=
FileDlg
.
ShowModal
();
if
(
diag
!=
wxID_OK
)
return
;
wxString
filen
ame
=
FileDlg
.
GetPath
();
m_ConvertedFileN
ame
=
FileDlg
.
GetPath
();
FILE
*
outfile
;
outfile
=
wxFopen
(
filen
ame
,
wxT
(
"w"
)
);
outfile
=
wxFopen
(
m_ConvertedFileN
ame
,
wxT
(
"w"
)
);
if
(
outfile
==
NULL
)
{
wxString
msg
;
msg
.
Printf
(
_
(
"File %s could not be created"
),
filen
ame
.
c_str
()
);
msg
.
Printf
(
_
(
"File %s could not be created"
),
m_ConvertedFileN
ame
.
c_str
()
);
wxMessageBox
(
msg
);
return
;
}
...
...
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