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
57126e83
Commit
57126e83
authored
Mar 21, 2008
by
dickelbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beautify
parent
198b10cf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
217 additions
and
200 deletions
+217
-200
3d_frame.cpp
3d-viewer/3d_frame.cpp
+217
-200
No files found.
3d-viewer/3d_frame.cpp
View file @
57126e83
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Name: 3d_frame.cpp
// Name: 3d_frame.cpp
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
...
@@ -25,25 +26,26 @@
...
@@ -25,25 +26,26 @@
#include "trackball.h"
#include "trackball.h"
BEGIN_EVENT_TABLE
(
WinEDA3D_DrawFrame
,
wxFrame
)
BEGIN_EVENT_TABLE
(
WinEDA3D_DrawFrame
,
wxFrame
)
EVT_TOOL_RANGE
(
ID_ZOOM_IN_BUTT
,
ID_ZOOM_PAGE_BUTT
,
EVT_TOOL_RANGE
(
ID_ZOOM_IN_BUTT
,
ID_ZOOM_PAGE_BUTT
,
WinEDA3D_DrawFrame
::
Process_Zoom
)
WinEDA3D_DrawFrame
::
Process_Zoom
)
EVT_TOOL_RANGE
(
ID_START_COMMAND_3D
,
ID_END_COMMAND_3D
,
EVT_TOOL_RANGE
(
ID_START_COMMAND_3D
,
ID_END_COMMAND_3D
,
WinEDA3D_DrawFrame
::
Process_Special_Functions
)
WinEDA3D_DrawFrame
::
Process_Special_Functions
)
EVT_MENU
(
wxID_EXIT
,
WinEDA3D_DrawFrame
::
Exit3DFrame
)
EVT_MENU
(
wxID_EXIT
,
WinEDA3D_DrawFrame
::
Exit3DFrame
)
EVT_MENU
(
ID_MENU_SCREENCOPY_PNG
,
WinEDA3D_DrawFrame
::
Process_Special_Functions
)
EVT_MENU
(
ID_MENU_SCREENCOPY_PNG
,
WinEDA3D_DrawFrame
::
Process_Special_Functions
)
EVT_MENU
(
ID_MENU_SCREENCOPY_JPEG
,
WinEDA3D_DrawFrame
::
Process_Special_Functions
)
EVT_MENU
(
ID_MENU_SCREENCOPY_JPEG
,
WinEDA3D_DrawFrame
::
Process_Special_Functions
)
EVT_CLOSE
(
WinEDA3D_DrawFrame
::
OnCloseWindow
)
EVT_CLOSE
(
WinEDA3D_DrawFrame
::
OnCloseWindow
)
END_EVENT_TABLE
()
END_EVENT_TABLE
()
/*******************************************************************/
/*******************************************************************/
WinEDA3D_DrawFrame
::
WinEDA3D_DrawFrame
(
WinEDA_BasePcbFrame
*
parent
,
WinEDA3D_DrawFrame
::
WinEDA3D_DrawFrame
(
WinEDA_BasePcbFrame
*
parent
,
WinEDA_App
*
app_parent
,
const
wxString
&
title
,
long
style
)
:
WinEDA_App
*
app_parent
,
const
wxString
&
title
,
wxFrame
(
parent
,
DISPLAY3D_FRAME
,
title
,
long
style
)
:
wxPoint
(
-
1
,
-
1
),
wxSize
(
-
1
,
-
1
),
style
)
wxFrame
(
parent
,
DISPLAY3D_FRAME
,
title
,
wxPoint
(
-
1
,
-
1
),
wxSize
(
-
1
,
-
1
),
style
)
/*******************************************************************/
/*******************************************************************/
{
{
m_FrameName
=
wxT
(
"Frame3D"
);
m_FrameName
=
wxT
(
"Frame3D"
);
m_Canvas
=
NULL
;
m_Canvas
=
NULL
;
m_Parent
=
parent
;
m_Parent
=
parent
;
m_ParentAppl
=
app_parent
;
m_ParentAppl
=
app_parent
;
...
@@ -52,41 +54,44 @@ WinEDA3D_DrawFrame::WinEDA3D_DrawFrame(WinEDA_BasePcbFrame * parent,
...
@@ -52,41 +54,44 @@ WinEDA3D_DrawFrame::WinEDA3D_DrawFrame(WinEDA_BasePcbFrame * parent,
m_InternalUnits
=
10000
;
// Unites internes = 1/10000 inch
m_InternalUnits
=
10000
;
// Unites internes = 1/10000 inch
// Give it an icon
// Give it an icon
SetIcon
(
wxICON
(
icon_w3d
)
);
SetIcon
(
wxICON
(
icon_w3d
)
);
GetSettings
();
GetSettings
();
SetSize
(
m_FramePos
.
x
,
m_FramePos
.
y
,
m_FrameSize
.
x
,
m_FrameSize
.
y
);
SetSize
(
m_FramePos
.
x
,
m_FramePos
.
y
,
m_FrameSize
.
x
,
m_FrameSize
.
y
);
// Create the status line
// Create the status line
int
dims
[
5
]
=
{
-
1
,
100
,
100
,
100
,
140
};
int
dims
[
5
]
=
{
-
1
,
100
,
100
,
100
,
140
};
CreateStatusBar
(
5
);
CreateStatusBar
(
5
);
SetStatusWidths
(
5
,
dims
);
SetStatusWidths
(
5
,
dims
);
ReCreateMenuBar
();
ReCreateMenuBar
();
ReCreateHToolbar
();
ReCreateHToolbar
();
// ReCreateAuxiliaryToolbar();
// ReCreateAuxiliaryToolbar();
ReCreateVToolbar
();
ReCreateVToolbar
();
// Make a Pcb3D_GLCanvas
// Make a Pcb3D_GLCanvas
m_Canvas
=
new
Pcb3D_GLCanvas
(
this
,
-
1
,
gl_attrib
);
m_Canvas
=
new
Pcb3D_GLCanvas
(
this
,
-
1
,
gl_attrib
);
/* init OpenGL once */
/* init OpenGL once */
m_Canvas
->
InitGL
();
m_Canvas
->
InitGL
();
}
}
/***********************************************************/
/***********************************************************/
void
WinEDA3D_DrawFrame
::
Exit3DFrame
(
wxCommandEvent
&
event
)
void
WinEDA3D_DrawFrame
::
Exit3DFrame
(
wxCommandEvent
&
event
)
/***********************************************************/
/***********************************************************/
{
{
Close
(
TRUE
);
Close
(
TRUE
);
}
}
/***********************************************************/
/***********************************************************/
void
WinEDA3D_DrawFrame
::
OnCloseWindow
(
wxCloseEvent
&
Event
)
void
WinEDA3D_DrawFrame
::
OnCloseWindow
(
wxCloseEvent
&
Event
)
/***********************************************************/
/***********************************************************/
{
{
SaveSettings
();
SaveSettings
();
if
(
m_Parent
)
if
(
m_Parent
)
{
{
m_Parent
->
m_Draw3DFrame
=
NULL
;
m_Parent
->
m_Draw3DFrame
=
NULL
;
}
}
...
@@ -98,75 +103,83 @@ void WinEDA3D_DrawFrame::OnCloseWindow(wxCloseEvent & Event)
...
@@ -98,75 +103,83 @@ void WinEDA3D_DrawFrame::OnCloseWindow(wxCloseEvent & Event)
void
WinEDA3D_DrawFrame
::
GetSettings
()
void
WinEDA3D_DrawFrame
::
GetSettings
()
/******************************************/
/******************************************/
{
{
wxString
text
;
wxString
text
;
wxConfig
*
Config
=
m_ParentAppl
->
m_EDA_Config
;
// Current config used by application
wxConfig
*
Config
=
m_ParentAppl
->
m_EDA_Config
;
// Current config used by application
if
(
m_ParentAppl
->
m_EDA_Config
)
if
(
m_ParentAppl
->
m_EDA_Config
)
{
{
text
=
m_FrameName
+
wxT
(
"Pos_x"
);
text
=
m_FrameName
+
wxT
(
"Pos_x"
);
Config
->
Read
(
text
,
&
m_FramePos
.
x
);
Config
->
Read
(
text
,
&
m_FramePos
.
x
);
text
=
m_FrameName
+
wxT
(
"Pos_y"
);
text
=
m_FrameName
+
wxT
(
"Pos_y"
);
Config
->
Read
(
text
,
&
m_FramePos
.
y
);
Config
->
Read
(
text
,
&
m_FramePos
.
y
);
text
=
m_FrameName
+
wxT
(
"Size_x"
);
text
=
m_FrameName
+
wxT
(
"Size_x"
);
Config
->
Read
(
text
,
&
m_FrameSize
.
x
,
600
);
Config
->
Read
(
text
,
&
m_FrameSize
.
x
,
600
);
text
=
m_FrameName
+
wxT
(
"Size_y"
);
text
=
m_FrameName
+
wxT
(
"Size_y"
);
Config
->
Read
(
text
,
&
m_FrameSize
.
y
,
400
);
Config
->
Read
(
text
,
&
m_FrameSize
.
y
,
400
);
Config
->
Read
(
wxT
(
"BgColor_Red"
),
&
g_Parm_3D_Visu
.
m_BgColor
.
m_Red
,
0.0
);
Config
->
Read
(
wxT
(
"BgColor_Red"
),
&
g_Parm_3D_Visu
.
m_BgColor
.
m_Red
,
0.0
);
Config
->
Read
(
wxT
(
"BgColor_Green"
),
&
g_Parm_3D_Visu
.
m_BgColor
.
m_Green
,
0.0
);
Config
->
Read
(
wxT
(
"BgColor_Green"
),
&
g_Parm_3D_Visu
.
m_BgColor
.
m_Green
,
0.0
);
Config
->
Read
(
wxT
(
"BgColor_Blue"
),
&
g_Parm_3D_Visu
.
m_BgColor
.
m_Blue
,
0.0
);
Config
->
Read
(
wxT
(
"BgColor_Blue"
),
&
g_Parm_3D_Visu
.
m_BgColor
.
m_Blue
,
0.0
);
}
}
#ifdef __WXMAC__
#ifdef __WXMAC__
// for macOSX, the window must be below system (macOSX) toolbar
// for macOSX, the window must be below system (macOSX) toolbar
if
(
m_FramePos
.
y
<
GetMBarHeight
()
)
m_FramePos
.
y
=
GetMBarHeight
();
if
(
m_FramePos
.
y
<
GetMBarHeight
()
)
m_FramePos
.
y
=
GetMBarHeight
();
#endif
#endif
}
}
/*******************************************/
/*******************************************/
void
WinEDA3D_DrawFrame
::
SaveSettings
()
void
WinEDA3D_DrawFrame
::
SaveSettings
()
/*******************************************/
/*******************************************/
{
{
wxString
text
;
wxString
text
;
wxConfig
*
Config
=
m_ParentAppl
->
m_EDA_Config
;
// Current config used by application
wxConfig
*
Config
=
m_ParentAppl
->
m_EDA_Config
;
// Current config used by application
if
(
!
Config
)
return
;
if
(
!
Config
)
return
;
Config
->
Write
(
wxT
(
"BgColor_Red"
),
g_Parm_3D_Visu
.
m_BgColor
.
m_Red
);
Config
->
Write
(
wxT
(
"BgColor_Red"
),
g_Parm_3D_Visu
.
m_BgColor
.
m_Red
);
Config
->
Write
(
wxT
(
"BgColor_Green"
),
g_Parm_3D_Visu
.
m_BgColor
.
m_Green
);
Config
->
Write
(
wxT
(
"BgColor_Green"
),
g_Parm_3D_Visu
.
m_BgColor
.
m_Green
);
Config
->
Write
(
wxT
(
"BgColor_Blue"
),
g_Parm_3D_Visu
.
m_BgColor
.
m_Blue
);
Config
->
Write
(
wxT
(
"BgColor_Blue"
),
g_Parm_3D_Visu
.
m_BgColor
.
m_Blue
);
if
(
IsIconized
()
)
return
;
if
(
IsIconized
()
)
return
;
m_FrameSize
=
GetSize
();
m_FrameSize
=
GetSize
();
m_FramePos
=
GetPosition
();
m_FramePos
=
GetPosition
();
text
=
m_FrameName
+
wxT
(
"Pos_x"
);
text
=
m_FrameName
+
wxT
(
"Pos_x"
);
Config
->
Write
(
text
,
(
long
)
m_FramePos
.
x
);
Config
->
Write
(
text
,
(
long
)
m_FramePos
.
x
);
text
=
m_FrameName
+
wxT
(
"Pos_y"
);
text
=
m_FrameName
+
wxT
(
"Pos_y"
);
Config
->
Write
(
text
,
(
long
)
m_FramePos
.
y
);
Config
->
Write
(
text
,
(
long
)
m_FramePos
.
y
);
text
=
m_FrameName
+
wxT
(
"Size_x"
);
text
=
m_FrameName
+
wxT
(
"Size_x"
);
Config
->
Write
(
text
,
(
long
)
m_FrameSize
.
x
);
Config
->
Write
(
text
,
(
long
)
m_FrameSize
.
x
);
text
=
m_FrameName
+
wxT
(
"Size_y"
);
text
=
m_FrameName
+
wxT
(
"Size_y"
);
Config
->
Write
(
text
,
(
long
)
m_FrameSize
.
y
);
Config
->
Write
(
text
,
(
long
)
m_FrameSize
.
y
);
}
}
/***********************************************************/
/***********************************************************/
void
WinEDA3D_DrawFrame
::
Process_Zoom
(
wxCommandEvent
&
event
)
void
WinEDA3D_DrawFrame
::
Process_Zoom
(
wxCommandEvent
&
event
)
/***********************************************************/
/***********************************************************/
{
{
int
ii
;
int
ii
;
switch
(
event
.
GetId
())
switch
(
event
.
GetId
()
)
{
{
case
ID_ZOOM_PAGE_BUTT
:
case
ID_ZOOM_PAGE_BUTT
:
for
(
ii
=
0
;
ii
<
4
;
ii
++
)
g_Parm_3D_Visu
.
m_Rot
[
ii
]
=
0.0
;
for
(
ii
=
0
;
ii
<
4
;
ii
++
)
g_Parm_3D_Visu
.
m_Rot
[
ii
]
=
0.0
;
g_Parm_3D_Visu
.
m_Zoom
=
1.0
;
g_Parm_3D_Visu
.
m_Zoom
=
1.0
;
g_Draw3d_dx
=
g_Draw3d_dy
=
0
;
g_Draw3d_dx
=
g_Draw3d_dy
=
0
;
trackball
(
g_Parm_3D_Visu
.
m_Quat
,
0.0
,
0.0
,
0.0
,
0.0
);
trackball
(
g_Parm_3D_Visu
.
m_Quat
,
0.0
,
0.0
,
0.0
,
0.0
);
break
;
break
;
case
ID_ZOOM_IN_BUTT
:
case
ID_ZOOM_IN_BUTT
:
g_Parm_3D_Visu
.
m_Zoom
/=
1.2
;
g_Parm_3D_Visu
.
m_Zoom
/=
1.2
;
if
(
g_Parm_3D_Visu
.
m_Zoom
<=
0.01
)
if
(
g_Parm_3D_Visu
.
m_Zoom
<=
0.01
)
g_Parm_3D_Visu
.
m_Zoom
=
0.01
;
g_Parm_3D_Visu
.
m_Zoom
=
0.01
;
break
;
break
;
...
@@ -180,28 +193,30 @@ int ii;
...
@@ -180,28 +193,30 @@ int ii;
default
:
default
:
return
;
return
;
}
}
m_Canvas
->
DisplayStatus
();
m_Canvas
->
DisplayStatus
();
m_Canvas
->
Refresh
(
FALSE
);
m_Canvas
->
Refresh
(
FALSE
);
}
}
/************************************************************************/
/************************************************************************/
void
WinEDA3D_DrawFrame
::
OnLeftClick
(
wxDC
*
DC
,
const
wxPoint
&
MousePos
)
void
WinEDA3D_DrawFrame
::
OnLeftClick
(
wxDC
*
DC
,
const
wxPoint
&
MousePos
)
/************************************************************************/
/************************************************************************/
{
{
}
}
/*******************************************************************************/
/*******************************************************************************/
void
WinEDA3D_DrawFrame
::
OnRightClick
(
const
wxPoint
&
MousePos
,
wxMenu
*
PopMenu
)
void
WinEDA3D_DrawFrame
::
OnRightClick
(
const
wxPoint
&
MousePos
,
wxMenu
*
PopMenu
)
/*******************************************************************************/
/*******************************************************************************/
{
{
}
}
/************************************/
/************************************/
int
WinEDA3D_DrawFrame
::
BestZoom
()
int
WinEDA3D_DrawFrame
::
BestZoom
()
/************************************/
/************************************/
// Retourne le meilleur zoom
// Retourne le meilleur zoom
{
{
return
1
;
return
1
;
...
@@ -209,19 +224,19 @@ int WinEDA3D_DrawFrame::BestZoom()
...
@@ -209,19 +224,19 @@ int WinEDA3D_DrawFrame::BestZoom()
/*******************************************************************/
/*******************************************************************/
void
WinEDA3D_DrawFrame
::
RedrawActiveWindow
(
wxDC
*
DC
,
bool
EraseBg
)
void
WinEDA3D_DrawFrame
::
RedrawActiveWindow
(
wxDC
*
DC
,
bool
EraseBg
)
/*******************************************************************/
/*******************************************************************/
{
{
}
}
/************************************************************************/
/************************************************************************/
void
WinEDA3D_DrawFrame
::
Process_Special_Functions
(
wxCommandEvent
&
event
)
void
WinEDA3D_DrawFrame
::
Process_Special_Functions
(
wxCommandEvent
&
event
)
/************************************************************************/
/************************************************************************/
{
{
#define ROT_ANGLE 10.0
#define ROT_ANGLE 10.0
switch
(
event
.
GetId
()
)
switch
(
event
.
GetId
()
)
{
{
case
ID_RELOAD3D_BOARD
:
case
ID_RELOAD3D_BOARD
:
NewDisplay
();
NewDisplay
();
...
@@ -252,25 +267,25 @@ void WinEDA3D_DrawFrame::Process_Special_Functions(wxCommandEvent& event)
...
@@ -252,25 +267,25 @@ void WinEDA3D_DrawFrame::Process_Special_Functions(wxCommandEvent& event)
break
;
break
;
case
ID_MOVE3D_LEFT
:
case
ID_MOVE3D_LEFT
:
m_Canvas
->
SetView3D
(
WXK_LEFT
);
m_Canvas
->
SetView3D
(
WXK_LEFT
);
return
;
return
;
case
ID_MOVE3D_RIGHT
:
case
ID_MOVE3D_RIGHT
:
m_Canvas
->
SetView3D
(
WXK_RIGHT
);
m_Canvas
->
SetView3D
(
WXK_RIGHT
);
return
;
return
;
case
ID_MOVE3D_UP
:
case
ID_MOVE3D_UP
:
m_Canvas
->
SetView3D
(
WXK_UP
);
m_Canvas
->
SetView3D
(
WXK_UP
);
return
;
return
;
case
ID_MOVE3D_DOWN
:
case
ID_MOVE3D_DOWN
:
m_Canvas
->
SetView3D
(
WXK_DOWN
);
m_Canvas
->
SetView3D
(
WXK_DOWN
);
return
;
return
;
case
ID_TOOL_SCREENCOPY_TOCLIBBOARD
:
case
ID_TOOL_SCREENCOPY_TOCLIBBOARD
:
case
ID_MENU_SCREENCOPY_PNG
:
case
ID_MENU_SCREENCOPY_PNG
:
case
ID_MENU_SCREENCOPY_JPEG
:
case
ID_MENU_SCREENCOPY_JPEG
:
m_Canvas
->
TakeScreenshot
(
event
);
m_Canvas
->
TakeScreenshot
(
event
);
break
;
break
;
case
ID_MENU3D_BGCOLOR_SELECTION
:
case
ID_MENU3D_BGCOLOR_SELECTION
:
...
@@ -279,11 +294,12 @@ void WinEDA3D_DrawFrame::Process_Special_Functions(wxCommandEvent& event)
...
@@ -279,11 +294,12 @@ void WinEDA3D_DrawFrame::Process_Special_Functions(wxCommandEvent& event)
default
:
default
:
wxMessageBox
(
wxMessageBox
(
wxT
(
"WinEDA3D_DrawFrame::Process_Special_Functions() error: unknown command"
)
);
wxT
(
"WinEDA3D_DrawFrame::Process_Special_Functions() error: unknown command"
)
);
return
;
return
;
}
}
m_Canvas
->
DisplayStatus
();
m_Canvas
->
DisplayStatus
();
m_Canvas
->
Refresh
(
FALSE
);
m_Canvas
->
Refresh
(
FALSE
);
}
}
...
@@ -294,25 +310,26 @@ void WinEDA3D_DrawFrame::NewDisplay()
...
@@ -294,25 +310,26 @@ void WinEDA3D_DrawFrame::NewDisplay()
m_Canvas
->
ClearLists
();
m_Canvas
->
ClearLists
();
m_Canvas
->
InitGL
();
m_Canvas
->
InitGL
();
m_Canvas
->
DisplayStatus
();
m_Canvas
->
DisplayStatus
();
m_Canvas
->
Refresh
(
FALSE
);
m_Canvas
->
Refresh
(
FALSE
);
}
}
/******************************************/
/******************************************/
void
WinEDA3D_DrawFrame
::
Set3DBgColor
()
void
WinEDA3D_DrawFrame
::
Set3DBgColor
()
/******************************************/
/******************************************/
/* called to set the background color of the 3D scene
/* called to set the background color of the 3D scene
*/
*/
{
{
S3D_Color
color
;
S3D_Color
color
;
wxColour
newcolor
,
oldcolor
;
wxColour
newcolor
,
oldcolor
;
oldcolor
.
Set
((
int
)
round
(
g_Parm_3D_Visu
.
m_BgColor
.
m_Red
*
255
),
oldcolor
.
Set
(
(
int
)
round
(
g_Parm_3D_Visu
.
m_BgColor
.
m_Red
*
255
),
(
int
)
round
(
g_Parm_3D_Visu
.
m_BgColor
.
m_Green
*
255
),
(
int
)
round
(
g_Parm_3D_Visu
.
m_BgColor
.
m_Green
*
255
),
(
int
)
round
(
g_Parm_3D_Visu
.
m_BgColor
.
m_Blue
*
255
)
);
(
int
)
round
(
g_Parm_3D_Visu
.
m_BgColor
.
m_Blue
*
255
)
);
newcolor
=
wxGetColourFromUser
(
this
,
oldcolor
);
newcolor
=
wxGetColourFromUser
(
this
,
oldcolor
);
if
(
newcolor
!=
oldcolor
)
if
(
newcolor
!=
oldcolor
)
{
{
g_Parm_3D_Visu
.
m_BgColor
.
m_Red
=
(
double
)
newcolor
.
Red
()
/
255.0
;
g_Parm_3D_Visu
.
m_BgColor
.
m_Red
=
(
double
)
newcolor
.
Red
()
/
255.0
;
g_Parm_3D_Visu
.
m_BgColor
.
m_Green
=
(
double
)
newcolor
.
Green
()
/
255.0
;
g_Parm_3D_Visu
.
m_BgColor
.
m_Green
=
(
double
)
newcolor
.
Green
()
/
255.0
;
...
...
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