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
4b144155
Commit
4b144155
authored
Dec 15, 2012
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3d viewer: code cleaning. Display options are now stored in config.
parent
97ea4e83
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
311 additions
and
219 deletions
+311
-219
3d_aux.cpp
3d-viewer/3d_aux.cpp
+4
-3
3d_canvas.cpp
3d-viewer/3d_canvas.cpp
+3
-3
3d_canvas.h
3d-viewer/3d_canvas.h
+159
-0
3d_draw.cpp
3d-viewer/3d_draw.cpp
+1
-0
3d_frame.cpp
3d-viewer/3d_frame.cpp
+121
-84
3d_viewer.h
3d-viewer/3d_viewer.h
+23
-129
No files found.
3d-viewer/3d_aux.cpp
View file @
4b144155
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, j
ean-pierre.charras@ujf-grenoble
.fr
* Copyright (C) 201
1
Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-201
1
KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2012 Jean-Pierre Charras, j
p.charras at wanadoo
.fr
* Copyright (C) 201
2
Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-201
2
KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
...
...
@@ -41,6 +41,7 @@
#include <class_pcb_text.h>
#include <3d_viewer.h>
#include <3d_canvas.h>
#include <info3d_visu.h>
#include <trackball.h>
...
...
3d-viewer/3d_canvas.cpp
View file @
4b144155
...
...
@@ -17,6 +17,7 @@
#include <gestfich.h>
#include <3d_viewer.h>
#include <3d_canvas.h>
#include <info3d_visu.h>
#include <trackball.h>
#include <3d_viewer_id.h>
...
...
@@ -73,12 +74,11 @@ END_EVENT_TABLE()
EDA_3D_CANVAS
::
EDA_3D_CANVAS
(
EDA_3D_FRAME
*
parent
,
int
*
attribList
)
:
wxGLCanvas
(
parent
,
-
1
,
attribList
,
wxDefaultPosition
,
wxDefaultSize
,
wxGLCanvas
(
parent
,
wxID_ANY
,
attribList
,
wxDefaultPosition
,
wxDefaultSize
,
wxFULL_REPAINT_ON_RESIZE
)
{
m_init
=
false
;
m_gllist
=
0
;
m_ortho
=
false
;
// Explicitly create a new rendering context instance for this canvas.
m_glRC
=
new
wxGLContext
(
this
);
...
...
@@ -517,7 +517,7 @@ void EDA_3D_CANVAS::InitGL()
if
(
g_Parm_3D_Visu
.
m_Zoom
>
MAX_VIEW_ANGLE
)
g_Parm_3D_Visu
.
m_Zoom
=
MAX_VIEW_ANGLE
;
if
(
ModeIsOrtho
()
)
if
(
Parent
()
->
ModeIsOrtho
()
)
{
// OrthoReductionFactor is chosen so as to provide roughly the same size as
// Perspective View
...
...
3d-viewer/3d_canvas.h
0 → 100644
View file @
4b144155
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file 3d_viewer.h
*/
#ifndef _3D_CANVAS_H_
#define _3D_CANVAS_H_
#include <wxBasePcbFrame.h> // for m_auimanager member.
#include <layers_id_colors_and_visibility.h> // Layers id definitions
#include <PolyLine.h> // for CPolyPt
#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
#endif
#include <wx/glcanvas.h>
#ifdef __WXMAC__
# ifdef __DARWIN__
# include <OpenGL/glu.h>
# else
# include <glu.h>
# endif
#else
# include <GL/glu.h>
#endif
#include <3d_struct.h>
class
BOARD_DESIGN_SETTINGS
;
class
TRACK
;
class
TEXTE_PCB
;
class
DRAWSEGMENT
;
class
ZONE_CONTAINER
;
class
EDA_3D_FRAME
;
class
S3D_VERTEX
;
class
SEGVIA
;
class
EDA_3D_CANVAS
:
public
wxGLCanvas
{
private
:
bool
m_init
;
GLuint
m_gllist
;
wxGLContext
*
m_glRC
;
wxRealPoint
m_draw3dOffset
;
// offset to draw the 3 mesh.
double
m_ZBottom
;
// position of the back layer
double
m_ZTop
;
// position of the front layer
public
:
EDA_3D_CANVAS
(
EDA_3D_FRAME
*
parent
,
int
*
attribList
=
0
);
~
EDA_3D_CANVAS
();
EDA_3D_FRAME
*
Parent
()
{
return
(
EDA_3D_FRAME
*
)
GetParent
();
}
void
ClearLists
();
// Event functions:
void
OnPaint
(
wxPaintEvent
&
event
);
void
OnEraseBackground
(
wxEraseEvent
&
event
);
void
OnChar
(
wxKeyEvent
&
event
);
void
OnMouseWheel
(
wxMouseEvent
&
event
);
void
OnMouseMove
(
wxMouseEvent
&
event
);
void
OnRightClick
(
wxMouseEvent
&
event
);
void
OnPopUpMenu
(
wxCommandEvent
&
event
);
void
TakeScreenshot
(
wxCommandEvent
&
event
);
void
OnEnterWindow
(
wxMouseEvent
&
event
);
// Display functions
GLuint
DisplayCubeforTest
();
// Just a test function
void
SetView3D
(
int
keycode
);
void
DisplayStatus
();
void
Redraw
(
bool
finish
=
false
);
void
Render
();
/**
* Function CreateDrawGL_List
* creates the OpenGL draw list items.
*/
GLuint
CreateDrawGL_List
();
void
InitGL
();
void
SetLights
();
void
SetOffset
(
double
aPosX
,
double
aPosY
)
{
m_draw3dOffset
.
x
=
aPosX
;
m_draw3dOffset
.
y
=
aPosY
;
}
void
DrawGrid
(
double
aGriSizeMM
);
/**
* Function Draw3D_Track
* @param aTrack = the aTrack to draw
*/
void
Draw3D_Track
(
TRACK
*
aTrack
);
/**
* Function Draw3D_Via
* draws 3D via as a cylinder and filled circles.
*/
void
Draw3D_Via
(
SEGVIA
*
via
);
/**
* Function Draw3D_DrawSegment
* draws a 3D segment (line, arc or circle).
*/
void
Draw3D_DrawSegment
(
DRAWSEGMENT
*
segment
);
/**
* Function Draw3D_Zone
* draw all solid areas in aZone
* @param aZone = the zone to draw
*/
void
Draw3D_Zone
(
ZONE_CONTAINER
*
aZone
);
/**
* Function Draw3D_DrawText
* draws 3D segments to create text objects.
* When DrawGraphicText is called to draw a text to an OpenGL DC
* it calls Draw3dTextSegm to each segment to draw.
* 2 parameters used by Draw3D_FilledSegment are not handled by DrawGraphicText
* but are used in Draw3D_FilledSegment().
* they are 2 local variables. This is an ugly, but trivial code.
* Using DrawGraphicText to draw all texts ensure texts have the same shape
* in all contexts
*/
void
Draw3D_DrawText
(
TEXTE_PCB
*
text
);
//int Get3DLayerEnable(int act_layer);
DECLARE_EVENT_TABLE
()
};
#endif
/* _3D_CANVAS_H_ */
3d-viewer/3d_draw.cpp
View file @
4b144155
...
...
@@ -43,6 +43,7 @@
#include <convert_basic_shapes_to_polygon.h>
#include <3d_viewer.h>
#include <3d_canvas.h>
#include <info3d_visu.h>
#include <trackball.h>
#include <3d_draw_basic_functions.h>
...
...
3d-viewer/3d_frame.cpp
View file @
4b144155
This diff is collapsed.
Click to expand it.
3d-viewer/3d_viewer.h
View file @
4b144155
...
...
@@ -52,142 +52,25 @@
#include <3d_struct.h>
class
BOARD_DESIGN_SETTINGS
;
class
TRACK
;
class
TEXTE_PCB
;
class
DRAWSEGMENT
;
class
ZONE_CONTAINER
;
class
EDA_3D_CANVAS
;
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS
#define LIB3D_PATH wxT( "packages3d" )
class
EDA_3D_FRAME
;
class
S3D_VERTEX
;
class
SEGVIA
;
class
EDA_3D_CANVAS
:
public
wxGLCanvas
{
private
:
bool
m_init
;
GLuint
m_gllist
;
/// Tracks whether to use Orthographic or Perspective projection
// TODO: Does this belong here, or in EDA_3D_FRAME ???
bool
m_ortho
;
wxGLContext
*
m_glRC
;
wxRealPoint
m_draw3dOffset
;
// offset to draw the 3 mesh.
double
m_ZBottom
;
// position of the back layer
double
m_ZTop
;
// position of the front layer
public
:
EDA_3D_CANVAS
(
EDA_3D_FRAME
*
parent
,
int
*
attribList
=
0
);
~
EDA_3D_CANVAS
();
EDA_3D_FRAME
*
Parent
()
{
return
(
EDA_3D_FRAME
*
)
GetParent
();
}
void
ClearLists
();
// Event functions:
void
OnPaint
(
wxPaintEvent
&
event
);
void
OnEraseBackground
(
wxEraseEvent
&
event
);
void
OnChar
(
wxKeyEvent
&
event
);
void
OnMouseWheel
(
wxMouseEvent
&
event
);
void
OnMouseMove
(
wxMouseEvent
&
event
);
void
OnRightClick
(
wxMouseEvent
&
event
);
void
OnPopUpMenu
(
wxCommandEvent
&
event
);
void
TakeScreenshot
(
wxCommandEvent
&
event
);
void
OnEnterWindow
(
wxMouseEvent
&
event
);
// Display functions
GLuint
DisplayCubeforTest
();
// Just a test function
void
SetView3D
(
int
keycode
);
void
DisplayStatus
();
void
Redraw
(
bool
finish
=
false
);
void
Render
();
/**
* Function CreateDrawGL_List
* creates the OpenGL draw list items.
*/
GLuint
CreateDrawGL_List
();
void
InitGL
();
void
SetLights
();
void
SetOffset
(
double
aPosX
,
double
aPosY
)
{
m_draw3dOffset
.
x
=
aPosX
;
m_draw3dOffset
.
y
=
aPosY
;
}
void
DrawGrid
(
double
aGriSizeMM
);
/**
* Function Draw3D_Track
* @param aTrack = the aTrack to draw
*/
void
Draw3D_Track
(
TRACK
*
aTrack
);
/**
* Function Draw3D_Via
* draws 3D via as a cylinder and filled circles.
*/
void
Draw3D_Via
(
SEGVIA
*
via
);
/**
* Function Draw3D_DrawSegment
* draws a 3D segment (line, arc or circle).
*/
void
Draw3D_DrawSegment
(
DRAWSEGMENT
*
segment
);
/**
* Function Draw3D_Zone
* draw all solid areas in aZone
* @param aZone = the zone to draw
*/
void
Draw3D_Zone
(
ZONE_CONTAINER
*
aZone
);
/**
* Function Draw3D_DrawText
* draws 3D segments to create text objects.
* When DrawGraphicText is called to draw a text to an OpenGL DC
* it calls Draw3dTextSegm to each segment to draw.
* 2 parameters used by Draw3D_FilledSegment are not handled by DrawGraphicText
* but are used in Draw3D_FilledSegment().
* they are 2 local variables. This is an ugly, but trivial code.
* Using DrawGraphicText to draw all texts ensure texts have the same shape
* in all contexts
*/
void
Draw3D_DrawText
(
TEXTE_PCB
*
text
);
/// Toggles orthographic projection on and off
void
ToggleOrtho
(){
m_ortho
=
!
m_ortho
;
Refresh
(
true
);};
/// Returns the orthographic projection flag
bool
ModeIsOrtho
()
{
return
m_ortho
;};
//int Get3DLayerEnable(int act_layer);
DECLARE_EVENT_TABLE
()
};
class
EDA_3D_FRAME
:
public
wxFrame
{
private
:
wxString
m_
F
rameName
;
// name used for writing and reading setup. It is "Frame3D"
EDA_3D_CANVAS
*
m_
C
anvas
;
wxString
m_
f
rameName
;
// name used for writing and reading setup. It is "Frame3D"
EDA_3D_CANVAS
*
m_
c
anvas
;
wxAuiToolBar
*
m_HToolBar
;
wxAuiToolBar
*
m_VToolBar
;
wxPoint
m_
F
ramePos
;
wxSize
m_
F
rameSize
;
wxPoint
m_
f
ramePos
;
wxSize
m_
f
rameSize
;
wxAuiManager
m_auimgr
;
bool
m_reloadRequest
;
wxString
m_defaultFileName
;
/// Filename to propose for screenshot
/// Tracks whether to use Orthographic or Perspective projection
bool
m_ortho
;
public
:
EDA_3D_FRAME
(
PCB_BASE_FRAME
*
parent
,
const
wxString
&
title
,
...
...
@@ -219,9 +102,23 @@ public:
void
SetDefaultFileName
(
const
wxString
&
aFn
)
{
m_defaultFileName
=
aFn
;
}
const
wxString
&
GetDefaultFileName
()
const
{
return
m_defaultFileName
;
}
/// Toggles orthographic projection on and off
void
ToggleOrtho
(){
m_ortho
=
!
m_ortho
;
Refresh
(
true
);};
/// Returns the orthographic projection flag
bool
ModeIsOrtho
()
{
return
m_ortho
;};
private
:
// Event handlers:
void
Exit3DFrame
(
wxCommandEvent
&
event
);
void
OnCloseWindow
(
wxCloseEvent
&
Event
);
void
Process_Special_Functions
(
wxCommandEvent
&
event
);
void
On3DGridSelection
(
wxCommandEvent
&
event
);
void
Process_Zoom
(
wxCommandEvent
&
event
);
void
OnActivate
(
wxActivateEvent
&
event
);
// initialisation
void
ReCreateMenuBar
();
void
ReCreateHToolbar
();
void
ReCreateVToolbar
();
...
...
@@ -229,15 +126,12 @@ private:
void
GetSettings
();
void
SaveSettings
();
// Other functions
void
OnLeftClick
(
wxDC
*
DC
,
const
wxPoint
&
MousePos
);
void
OnRightClick
(
const
wxPoint
&
MousePos
,
wxMenu
*
PopMenu
);
void
OnKeyEvent
(
wxKeyEvent
&
event
);
double
BestZoom
();
void
RedrawActiveWindow
(
wxDC
*
DC
,
bool
EraseBg
);
void
Process_Special_Functions
(
wxCommandEvent
&
event
);
void
On3DGridSelection
(
wxCommandEvent
&
event
);
void
Process_Zoom
(
wxCommandEvent
&
event
);
void
OnActivate
(
wxActivateEvent
&
event
);
void
Set3DBgColor
();
...
...
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