mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-19 18:31:40 +00:00
Initial import of KiCad.
This commit is contained in:
commit
23c40f7e86
3d-viewer
3d_aux.cpp3d_canvas.cpp3d_class.cpp3d_draw.cpp3d_frame.cpp3d_read_mesh.cpp3d_struct.h3d_toolbar.cpp3d_viewer.hbitmaps3d.h
bitmaps3d
axis3d.xpmaxis3d_back.xpmaxis3d_bottom.xpmaxis3d_front.xpmaxis3d_left.xpmaxis3d_right.xpmaxis3d_top.xpmimport3d.xpmrotate+x.xpmrotate+y.xpmrotate+z.xpmrotate-x.xpmrotate-y.xpmrotate-z.xpmzoomoins3d.xpmzoompage3d.xpmzoomplus3d.xpmzoomrefr3d.xpm
makefile.g95makefile.gtkmakefile.includemakefile.macosxtrackball.cpptrackball.hbitmaps
3d.xpmAdd_Arc.xpmAdd_Circle.xpmAdd_Component.xpmAdd_Dashed_Line.xpmAdd_Entry.xpmAdd_GLabel.xpmAdd_Junction.xpmAdd_Line.xpmAdd_Line_Label.xpmAdd_Polygon.xpmAdd_Rectangle.xpmAdd_Text.xpmApply.xpmCancel.xpmCopyBlock.xpmCursor_Shape.xpmDatasheet.xpmDelete_Arc.xpmDelete_Circle.xpmDelete_Cotation.xpmDelete_Field.xpmDelete_Line.xpmDelete_Polygon.xpmDelete_Rectangle.xpmDelete_Segment.xpmDelete_Text.xpmDisplay_Options.xpmEdit.xpmEdit_Text.xpmExit.xpmFile_FootPrint.xpmFonts.xpmInfo.xpmMirror_H.xpmMirror_V.xpmMorgan1.xpmMorgan2.xpmMove.xpmMove_Arc.xpmMove_Circle.xpmMove_Field.xpmMove_Line.xpmMove_Polygon.xpmMove_Rectangle.xpmMove_Text.xpmNew_Library.xpmOpen_Library.xpmOptions_Arc.xpmOptions_Circle.xpmOptions_New_Pad.xpmOptions_Pad.xpmOptions_Rectangle.xpmOptions_Segment.xpmOptions_Text.xpmOrient.xpmPad_Sketch.xpmRead_SetUp.xpmRepaint.xpmRotate+.xpmRotate-.xpmRotate_Field.xpmSave_CmpStuff.xpmSave_Library.xpmSave_NetList.xpmSave_Project.xpmSave_SetUp.xpmText_Sketch.xpmZoom_1.xpmZoom_Center.xpmZoom_In.xpmZoom_Optimal.xpmZoom_Out.xpmZoom_Page.xpmZoom_Select.xpmZoom_Selected.xpmanchor.xpmannotate.xpmauto_associe.xpmbook.xpmcancel_tool.xpmconfig.xpmcopy.xpmcursor.xpmcut.xpmdashline.xpmdel_body.xpmdel_track.xpmdelete.xpmdown.xpmdrc.xpmdrc_off.xpmeeschema.xpmerc.xpmercerr.xpmercgreen.xpmercwarn.xpmexport.xpmfind.xpmgeneral_deletions.xpmgreen.xpmgrid.xpmgrid_select.xpmhammer.xpmhelp.xpmicon_3d.xpmicon_cvpcb.xpmicon_eeschema.xpmicon_gerbview.xpmicon_kicad.xpmicon_modedit.xpmicon_pcbnew.xpmimport.xpmjigsaw.xpmkicad_icon_small.xpmlabel.xpmleft.xpmlibedprt.xpmlibrary.xpmlibrary_update.xpmlibsavem.xpmlibview.xpmmirepcb.xpmmodedit.xpmmodratsnest.xpmmodule.xpmnetlist.xpmnew.xpmnoconn.xpmopen.xpmpad.xpmpalette.xpmpaste.xpmpcbnew.xpmpin.xpmplot.xpmplot_HPG.xpmplot_PS.xpmpolar.xpmpreference.xpmprint.xpmratsnest.xpmred.xpmredo.xpmright.xpmsave.xpmsave_as.xpmschematic.xpmselect_grid.xpmsheetset.xpmshowdcode.xpmshowmodedge.xpmshowtrack.xpmtools.xpmtransistor.xpmtreensel.xpmtreesel.xpmundelete.xpmundo.xpmunit_inch.xpmunit_mm.xpmup.xpmzoom.xpm
common
base_screen.cppbase_struct.cppbasicframe.cppbitmaps.cpp
contrib_makefiles.txtbitmaps
Lang_De.xpmLang_Default.xpmLang_En.xpmLang_Es.xpmLang_Fr.xpmLang_Hu.xpmLang_It.xpmLang_Ko.xpmLang_Po.xpmLang_Pt.xpmLang_Ru.xpmLang_Sl.xpmLanguage.xpm
block_commande.cppcommon.cppcommon_plotHPGL_functions.cppcommon_plotPS_functions.cppcommon_plot_functions.cppconfirm.cppcopy_to_clipboard.cppdcsvg.cppdispllst.cppdrawtxt.cppeda_dde.cppeda_doc.cppedaappl.cppedamenu.cppgestfich.cppget_component_dialog.cppgr_basic.cppmakefile.g95makefile.gtkmakefile.includemakefile.macosxmsgpanel.cppprojet_config.cppselcolor.cppstring.cppsvg_print.cppsvg_print.hsvg_print.pjdtoolbars.cpptrigo.cppworksheet.cppwxwineda.cppcvpcb
affiche.cppautosel.cpp
bitmaps
cfg.cppcfg.hclass_cvpcb.cppcvframe.cppcvpcb.cppcvpcb.hcvpcb.icocvpcb.rcvpcb.rccvstruct.hdialog_cvpcb_config.cppdialog_cvpcb_config.hdialog_cvpcb_config.rcdialog_display_options.cppdialog_display_options.hdialog_display_options.rcdisplayframe.cppgenequiv.cppgenorcad.cppinit.cpplicence.hlistboxes.cpplistlib.cpploadcmp.cppmakefile.g95makefile.gtkmakefile.includemakefile.macosxmemoire.cppmenucfg.cppoptions.cppprotos.hrdorcad.cpprdpcad.cppreadschematicnetlist.cppsavecmp.cppsetvisu.cpptool_cvpcb.cppviewlnet.cppviewlogi.cppvisumod.cppwritenetlistpcbnew.cppeeschema
affiche.cppannotate.cppannotate_dialog.cppannotate_dialog.hannotate_dialog.pjdannotate_dialog.rc
bitmaps
AddBus2Bus.xpmAddLine2Bus.xpmAdd_Bus2Bus.xpmAdd_GLabel.xpmAdd_Junction.xpmAdd_Line2Bus.xpmAdd_Line_Label.xpmAdd_Power.xpmBreak_Bus.xpmBreak_Line.xpmDelete_Bus.xpmDelete_Connection.xpmDelete_GLabel.xpmDelete_Node.xpmDelete_Pin.xpmDelete_Pinsheet.xpmDelete_Sheet.xpmEdit_Comp_Ref.xpmEdit_Comp_Value.xpmEdit_Component.xpmEdit_Part.xpmEdit_Sheet.xpmEnter_Sheet.xpmGL_Change.xpmGLabel2Label.xpmGLabel2Text.xpmHidden_Pin.xpmHierarchy_Nav.xpmHierarchy_cursor.xpmImport_GLabel.xpmLabel2GLabel.xpmLabel2Text.xpmLeave_Sheet.xpmLib_next.xpmLib_previous.xpmLines90.xpmMirror_H.xpmMirror_V.xpmMove_GLabel.xpmMove_Pinsheet.xpmMove_Sheet.xpmNormal.xpmOptions_Pin.xpmOptions_Pinsheet.xpmPin_Name_to.xpmPin_Number_to.xpmPin_Size_to.xpmPin_to.xpmResize_Sheet.xpmRotate_GLabel.xpmRotate_Pin.xpmadd_bus.xpmadd_hierar_pin.xpmadd_hierar_symbol.xpmcvpcb.xpmlibedit.xpmlibedit_icon.xpmlibrary_browse.xpmnew_component.xpmpart_properties.xpmpin2pin.xpmviewlibs_icon.xpm
block.cppblock_libedit.cppbus-wire-junction.cppbusentry.cppclass_hierarchy_sheet.cppclass_screen.cppclass_screen.hclass_text-label.cppcleanup.cppcmpclass.cppcomponent_class.cppcomponent_class.hcontrole.cppdangling_ends.cppdatabase.cppdelete.cppdelsheet.cppdialog_build_BOM.cppdialog_build_BOM.hdialog_build_BOM.pjddialog_cmp_graphic_properties.cppdialog_cmp_graphic_properties.hdialog_cmp_graphic_properties.pjddialog_cmp_graphic_properties.rcdialog_create_component.cppdialog_create_component.hdialog_create_component.pjddialog_create_component.rcdialog_edit_component_in_lib.cppdialog_edit_component_in_lib.hdialog_edit_component_in_lib.pjddialog_edit_component_in_lib.rcdialog_edit_component_in_schematic.cppdialog_edit_component_in_schematic.hdialog_edit_component_in_schematic.pjddialog_edit_component_in_schematic.rcdialog_edit_label.cppdialog_edit_label.hdialog_edit_label.pjddialog_edit_label.rcdialog_eeschema_config.cppdialog_eeschema_config.hdialog_eeschema_config.pjddialog_erc.cppdialog_erc.hdialog_erc.pjddialog_erc.rcdialog_find.cppdialog_find.hdialog_find.pjddialog_find.rcdialog_options.cppdialog_options.hdialog_options.pjddialog_options.rcdialog_set_status.cppdialog_set_status.hdialog_set_status.pjddialog_set_status.rcdivers.cppedit_component_in_lib.cppedit_component_in_schematic.cppedit_label.cppeditpart.cppeeclass.cppeeconfig.cppeeconfig.heecreate.cppeelayer.cppeelibs1.cppeelibs2.cppeeload.cppeeredraw.cppeeschema.cppeeschema.icoeeschema.reeschema.rceestatus.cppeestring.cpperc.cppfieldedi.cppfiles-io.cppfind.cppgeneral.hgenliste.cppgetpart.cpphierarch.cpphotkeys.cpplib_export.cpplibalias.cpplibarch.cpplibclass.cpplibcmp.hlibedit.cpplibedit_icon.icolibedit_onleftclick.cpplibedit_onrightclick.cpplibedit_undo_redo.cpplibedpart.cpplibfield.cpplibframe.cppload_one_schematic_file.cpplocate.cppmakefile.g95makefile.gtkmakefile.includemakefile.macosxmenubar.cppnetform.cppnetlist.cppnetlist.hnetlist_control.cpponleftclick.cpponrightclick.cppoptions.cppoptionsframe.cppoptionsframe.hpinedit-dialog.cpppinedit-dialog.hpinedit-dialog.pjdpinedit-dialog.rcpinedit.cppplot.cppplothpgl.cppplothpgl.hplothpgl.pjdplothpgl.rcplotps.cppplotps.hplotps.pjdplotps.rcplugins
priorque.cpppriorque.hprogram.hprotos.hsave_schemas.cppsavelib.cppschedit.cppschematic_undo_redo.cppschframe.cppselpart.cppsheet.cppsheet.hsheet.pjdsheet.rcsheetlab.cppsymbdraw.cppsymbedit.cppsymbtext.cppsymbtext.hsymbtext.pjdsymbtext.rctool_lib.cpptool_sch.cpptool_viewlib.cppviewlib_frame.cppviewlibs.cppviewlibs_icon.icowxprint.hxx.cppxx.hgerbview
affiche.cppblock.cppcfg.cppcfg.hcontrole.cppdcode.cppdeltrack.cppedit.cppfiles.cppgerberframe.cppgerbview.cppgerbview.hgerbview.icogerbview.rgerbview.rcinitpcb.cpplay2plot.cpplocate.cppmakefile.g95makefile.gtkmakefile.includemakefile.macosxonrightclick.cppoptions.cpppcbplot.cpppcbplot.hpcbtexte.cppprotos.hreadgerb.cppreglage.cpprs274d.cpprs274x.cppset_color.cppset_color.hstruct.cpptool_gerber.cpptracepcb.cpptrpiste.cppundelete.cpp
how-to-build-kicad.txtinclude
appl_wxstruct.hbase_struct.hbitmaps.hbuild_version.hcolors.hcommon.hdcsvg.hdrawpanel_wxstruct.heda_dde.hfctsys.hgr_basic.hgrfonte.hid.hmacros.hpcbstruct.hplot_common.htrigo.hworksheet.hwxstruct.h
install.txtkicad
bitmaps
Browse_Files.xpmEditor.xpmFonts.xpmNew_Project.xpmOpen_Project.xpmSave_Project.xpmunzip.xpmzip.xpmzip_tool.xpm
buildmnu.cppfiles-io.cppkicad.cppkicad.hkicad.icokicad.rkicad.rcmainframe.rcmakefile.g95makefile.gtkmakefile.includemakefile.macosxmdiframe.cppminizip
preferences.cppprjconfig.cppprjconfig.hprotos.htreeprj.cppnsis_win_installer
English.nshFrench.nshInstaller Docs.odtItalian.nshPortuguese.nshRussian.nshSpanish.nshinstall.icoinstall.nsiuninstall.ico
pcbnew
affiche.cppar_protos.hattribut.cppautomove.cppautoplac.cppautorout.cppautorout.hbasepcbframe.cpp
bitmaps
Add_Mires.xpmAdd_Tracks.xpmAdd_Zone.xpmBreak_Line.xpmDelete_Line.xpmDelete_Module.xpmDelete_Net.xpmDelete_Node.xpmDelete_Pad.xpmDelete_Track.xpmDrag_Module.xpmDrag_Pad.xpmEdges_Sketch.xpmEdit_Module.xpmExport_Module.xpmExport_Options_Pad.xpmFlag.xpmGlobal_Options_Pad.xpmImport_Module.xpmInvert_Module.xpmLoad_Module_Board.xpmLoad_Module_Lib.xpmLocked.xpmMode_Module.xpmMode_Track.xpmModul_Edit.xpmModule_Check.xpmModule_Ratsnet.xpmMove_Field.xpmMove_Module.xpmMove_Pad.xpmMove_Pin.xpmNet_HighLight.xpmNet_Locked.xpmNet_UnLocked.xpmNew_FootPrint.xpmNew_Module.xpmOptions_All_Tracks&Vias.xpmOptions_All_Tracks.xpmOptions_All_Vias.xpmOptions_Module.xpmOptions_Track.xpmOptions_Tracks.xpmOptions_Vias.xpmPcbOffset.xpmPost_Compo.xpmPost_Drill.xpmPost_Module.xpmRepl_Module_Board.xpmRotate_Field.xpmRotate_Module+.xpmRotate_Module-.xpmSelect_Layer_Pair.xpmSelect_W_Layer.xpmShow_Zone.xpmSwap_Layer.xpmTrack_Locked.xpmTrack_Sketch.xpmTrack_UnLocked.xpmUnlocked.xpmWidth_Net.xpmWidth_Segment.xpmWidth_Track.xpmWidth_Track_Via.xpmWidth_Vias.xpmadd_cotation.xpmgeneral_ratsnet.xpmlocal_ratsnet.xpmmodule_options.xpmmw_Add_Gap.xpmmw_Add_Line.xpmmw_Add_Shape.xpmmw_Add_Stub.xpmmw_Add_stub_arc.xpmmw_toolbar.xpmnet_hightlight.xpmtool_ratsnet.xpm
block.cppblock_module_editor.cppboard.cppcell.hclass_board.cppclass_cotation.cppclass_cotation.hclass_edge_mod.cppclass_edge_mod.hclass_equipot.cppclass_equipot.hclass_mire.cppclass_mire.hclass_module.cppclass_module.hclass_pad.cppclass_pad.hclass_pcb_text.cppclass_pcb_text.hclass_text_mod.cppclass_text_mod.hclass_track.cppclass_track.hclasspcb.cppclasstrc.cppclean.cppconnect.cppcontrole.cppcotation.cppcursors.cppdeltrack.cppdialog_display_options.cppdialog_display_options.hdialog_display_options.rcdialog_drc.cppdialog_drc.hdialog_edit_mod_text.cppdialog_edit_mod_text.hdialog_edit_module.cppdialog_edit_module.hdialog_general_options.cppdialog_general_options.hdialog_general_options.rcdialog_graphic_items_options.cppdialog_graphic_items_options.hdialog_graphic_items_options.rcdialog_initpcb.cppdialog_initpcb.hdialog_initpcb.rcdialog_module_edit.rcdialog_netlist.cppdialog_netlist.hdialog_netlist.rcdialog_pad_edit.cppdialog_pad_edit.hdialog_pad_edit.rcdialog_setup_libs.cppdialog_setup_libs.hdialog_track_options.cppdialog_track_options.hdialog_track_options.rcdist.cppdocedit.cppdrag.hdragsegm.cppdrc.cppdupltrac.cppedgemod.cppedit.cppedit_track_width.cppeditedge.cppeditmod.cppeditpads.cppeditrack-part2.cppeditrack.cppeditrout.cppedtxtmod.cppedtxtmod.rcessai.cppessai.hessai.rcexport_gencad.cppfiles.cppfind.cppfind.hfind.rcgen_modules_placefile.cppgen_self.hgendrill.cppglobaleditpad.cppgraphpcb.cpphotkeys.cppicon_modedit.icoicon_pcbnew.icoicon_w3d.icoinitpcb.cppioascii.cpplay2plot.cpplibrairi.cpploadcmp.cpplocate.cppmakefile.g95makefile.gtkmakefile.includemakefile.macosxmenubarmodedit.cppmenubarpcb.cppmirepcb.cppmodedit.cppmodedit_onclick.cppmodedit_undo_redo.cppmodeditoptions.cppmoduleframe.cppmodules.cppmove-drag_pads.cppmove_copy_track.cppmuonde.cppmuwave_command.cppnetlist.cpponrightclick.cpppcbcfg.cpppcbcfg.hpcbframe.cpppcbnew.cpppcbnew.hpcbnew.rpcbnew.rcpcbpiste.cpppcbplot.cpppcbplot.hpcbtexte.cppplot_rtn.cppplotgerb.cppplotgerb.hplothpgl.cppplotps.cppprotos.hqueue.cppratsnest.cppreglage.cpprouter.cppsel_layer.cppset_color.cppset_grid.cppset_grid.hset_grid.rcsolve.cppstruct.cppsurbrill.cpptool_modedit.cpptool_onrightclick.cpptool_pcb.cpptr_modif.cpptracemod.cpptracepcb.cpptrack.cpptrpiste.cppundelete.cppvia_edit.cppwork.cppxchgmod.cppzones.cppzones.hzones.rcshare
269
3d-viewer/3d_aux.cpp
Normal file
269
3d-viewer/3d_aux.cpp
Normal file
@ -0,0 +1,269 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: 3d_aux.cpp
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "fctsys.h"
|
||||
|
||||
#if !wxUSE_GLCANVAS
|
||||
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include "trigo.h"
|
||||
|
||||
#include "bitmaps.h"
|
||||
|
||||
#include "3d_viewer.h"
|
||||
#include "3d_struct.h"
|
||||
#include "trackball.h"
|
||||
|
||||
/**************************************************************************/
|
||||
void Struct3D_Master::Set_Object_Coords(S3D_Vertex * coord, int nbcoord )
|
||||
/**************************************************************************/
|
||||
{
|
||||
int ii;
|
||||
|
||||
|
||||
/* adjust object scale, rotation and offset position */
|
||||
for ( ii = 0; ii < nbcoord; ii++ )
|
||||
{
|
||||
coord[ii].x *= m_MatScale.x;
|
||||
coord[ii].y *= m_MatScale.y;
|
||||
coord[ii].z *= m_MatScale.z;
|
||||
/* adjust rotation */
|
||||
if ( m_MatRotation.x )
|
||||
RotatePoint(&coord[ii].y, &coord[ii].z,
|
||||
(int)(m_MatRotation.x * 10));
|
||||
if ( m_MatRotation.y )
|
||||
RotatePoint(&coord[ii].z, &coord[ii].x,
|
||||
(int)(m_MatRotation.y * 10));
|
||||
if ( m_MatRotation.z )
|
||||
RotatePoint(&coord[ii].x, &coord[ii].y,
|
||||
(int)(m_MatRotation.z * 10));
|
||||
/* adjust offset position (offset is given in UNIT 3D (0.1 inch) */
|
||||
#define SCALE_3D_CONV (PCB_INTERNAL_UNIT/UNITS3D_TO_UNITSPCB)
|
||||
coord[ii].x += m_MatPosition.x * SCALE_3D_CONV;
|
||||
coord[ii].y += m_MatPosition.y * SCALE_3D_CONV;
|
||||
coord[ii].z += m_MatPosition.z * SCALE_3D_CONV;
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
void Set_Object_Data(const S3D_Vertex * coord, int nbcoord )
|
||||
/************************************************************/
|
||||
{
|
||||
int ii;
|
||||
GLfloat ax,ay,az,bx,by,bz,nx,ny,nz,r;
|
||||
|
||||
/* ignore faces with less than 3 points */
|
||||
if (nbcoord < 3) return;
|
||||
|
||||
/* calculate normal direction */
|
||||
ax = coord[1].x - coord[0].x;
|
||||
ay = coord[1].y - coord[0].y;
|
||||
az = coord[1].z - coord[0].z;
|
||||
|
||||
bx = coord[nbcoord-1].x - coord[0].x;
|
||||
by = coord[nbcoord-1].y - coord[0].y;
|
||||
bz = coord[nbcoord-1].z - coord[0].z;
|
||||
|
||||
nx = ay * bz - az * by;
|
||||
ny = az * bx - ax * bz;
|
||||
nz = ax * by - ay * bx;
|
||||
|
||||
r = sqrt(nx*nx + ny*ny + nz*nz);
|
||||
if (r >= 0.000001) /* avoid division by zero */
|
||||
{
|
||||
nx /= r; ny /= r; nz /= r;
|
||||
glNormal3f(nx,ny,nz);
|
||||
}
|
||||
|
||||
/* glBegin/glEnd */
|
||||
switch (nbcoord)
|
||||
{
|
||||
case 3:
|
||||
glBegin(GL_TRIANGLES);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
glBegin(GL_QUADS);
|
||||
break;
|
||||
|
||||
default:
|
||||
glBegin(GL_POLYGON);
|
||||
break;
|
||||
}
|
||||
|
||||
/* draw polygon/triangle/quad */
|
||||
for (ii = 0; ii < nbcoord; ii++)
|
||||
{
|
||||
glVertex3f(coord[ii].x * DataScale3D,
|
||||
coord[ii].y * DataScale3D,
|
||||
coord[ii].z * DataScale3D);
|
||||
}
|
||||
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
/**********************************************/
|
||||
GLuint Pcb3D_GLCanvas::DisplayCubeforTest(void)
|
||||
/**********************************************/
|
||||
{
|
||||
GLuint gllist = glGenLists( 1 );
|
||||
|
||||
glNewList( gllist, GL_COMPILE_AND_EXECUTE );
|
||||
/* draw six faces of a cube */
|
||||
glBegin(GL_QUADS);
|
||||
glNormal3f( 0.0F, 0.0F, 1.0F);
|
||||
glVertex3f( 0.5F, 0.5F, 0.5F); glVertex3f(-0.5F, 0.5F, 0.5F);
|
||||
glVertex3f(-0.5F,-0.5F, 0.5F); glVertex3f( 0.5F,-0.5F, 0.5F);
|
||||
|
||||
glNormal3f( 0.0F, 0.0F,-1.0F);
|
||||
glVertex3f(-0.5F,-0.5F,-0.5F); glVertex3f(-0.5F, 0.5F,-0.5F);
|
||||
glVertex3f( 0.5F, 0.5F,-0.5F); glVertex3f( 0.5F,-0.5F,-0.5F);
|
||||
|
||||
glNormal3f( 0.0F, 1.0F, 0.0F);
|
||||
glVertex3f( 0.5F, 0.5F, 0.5F); glVertex3f( 0.5F, 0.5F,-0.5F);
|
||||
glVertex3f(-0.5F, 0.5F,-0.5F); glVertex3f(-0.5F, 0.5F, 0.5F);
|
||||
|
||||
glNormal3f( 0.0F,-1.0F, 0.0F);
|
||||
glVertex3f(-0.5F,-0.5F,-0.5F); glVertex3f( 0.5F,-0.5F,-0.5F);
|
||||
glVertex3f( 0.5F,-0.5F, 0.5F); glVertex3f(-0.5F,-0.5F, 0.5F);
|
||||
|
||||
glNormal3f( 1.0F, 0.0F, 0.0F);
|
||||
glVertex3f( 0.5F, 0.5F, 0.5F); glVertex3f( 0.5F,-0.5F, 0.5F);
|
||||
glVertex3f( 0.5F,-0.5F,-0.5F); glVertex3f( 0.5F, 0.5F,-0.5F);
|
||||
|
||||
glNormal3f(-1.0F, 0.0F, 0.0F);
|
||||
glVertex3f(-0.5F,-0.5F,-0.5F); glVertex3f(-0.5F,-0.5F, 0.5F);
|
||||
glVertex3f(-0.5F, 0.5F, 0.5F); glVertex3f(-0.5F, 0.5F,-0.5F);
|
||||
glEnd();
|
||||
|
||||
glEndList();
|
||||
|
||||
return gllist;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**********************/
|
||||
/* class Info_3D_Visu */
|
||||
/**********************/
|
||||
|
||||
/* Constructor */
|
||||
Info_3D_Visu::Info_3D_Visu(void)
|
||||
{
|
||||
int ii;
|
||||
m_Beginx = m_Beginy = 0.0; /* position of mouse */
|
||||
m_Zoom = 1.0; /* field of view in degrees */
|
||||
trackball( m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||
for ( ii = 0; ii < 4; ii++ ) m_Rot[ii] = 0.0;
|
||||
m_Layers = 1;
|
||||
m_BoardSettings = NULL;
|
||||
}
|
||||
|
||||
|
||||
Info_3D_Visu::~Info_3D_Visu(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
/* Classe pour afficher et editer un Vertex (triplet de valeurs),*/
|
||||
/* en INCHES ou MM ou sans unites */
|
||||
/*****************************************************************/
|
||||
|
||||
WinEDA_VertexCtrl::WinEDA_VertexCtrl(wxWindow *parent, const wxString & title,
|
||||
wxBoxSizer * BoxSizer,
|
||||
int units, int internal_unit)
|
||||
{
|
||||
wxString text;
|
||||
wxStaticText * msgtitle;
|
||||
|
||||
m_Units = units;
|
||||
m_Internal_Unit = internal_unit;
|
||||
|
||||
if ( title.IsEmpty() ) text = _("Vertex ");
|
||||
else text = title;
|
||||
text += ReturnUnitSymbol(units);
|
||||
|
||||
msgtitle = new wxStaticText(parent, -1, text, wxDefaultPosition, wxSize(-1,-1), 0 );
|
||||
BoxSizer->Add(msgtitle, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxADJUST_MINSIZE);
|
||||
|
||||
wxFlexGridSizer * GridSizer = new wxFlexGridSizer(3, 2, 0, 0);
|
||||
BoxSizer->Add(GridSizer, 0, wxGROW|wxALL, 5);
|
||||
|
||||
msgtitle = new wxStaticText(parent, -1, wxT("X:"));
|
||||
GridSizer->Add(msgtitle, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5);
|
||||
m_XValueCtrl = new wxTextCtrl(parent, -1, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0 );
|
||||
GridSizer->Add(m_XValueCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
|
||||
|
||||
msgtitle = new wxStaticText(parent, -1, wxT("Y:"), wxDefaultPosition, wxSize(-1,-1), 0 );
|
||||
GridSizer->Add(msgtitle, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5);
|
||||
m_YValueCtrl = new wxTextCtrl(parent, -1, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0 );
|
||||
GridSizer->Add(m_YValueCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
|
||||
|
||||
msgtitle = new wxStaticText(parent, -1, wxT("Z:"), wxDefaultPosition, wxSize(-1,-1), 0 );
|
||||
GridSizer->Add(msgtitle, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5);
|
||||
m_ZValueCtrl = new wxTextCtrl(parent, -1, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0 );
|
||||
GridSizer->Add(m_ZValueCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
|
||||
}
|
||||
|
||||
WinEDA_VertexCtrl::~WinEDA_VertexCtrl(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*******************************************/
|
||||
S3D_Vertex WinEDA_VertexCtrl::GetValue(void)
|
||||
/*******************************************/
|
||||
/* Retourne (en unites internes) les coordonnes entrees (en unites utilisateur)
|
||||
*/
|
||||
{
|
||||
S3D_Vertex value;
|
||||
double dtmp;
|
||||
|
||||
m_XValueCtrl->GetValue().ToDouble(&dtmp);
|
||||
value.x = dtmp;
|
||||
m_YValueCtrl->GetValue().ToDouble(&dtmp);
|
||||
value.y = dtmp;
|
||||
m_ZValueCtrl->GetValue().ToDouble(&dtmp);
|
||||
value.z = dtmp;
|
||||
return value;
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
void WinEDA_VertexCtrl::SetValue(S3D_Vertex vertex)
|
||||
/**************************************************/
|
||||
{
|
||||
wxString text;
|
||||
|
||||
text.Printf( wxT("%f"), vertex.x);
|
||||
m_XValueCtrl->Clear();
|
||||
m_XValueCtrl->AppendText(text);
|
||||
|
||||
text.Printf(wxT("%f"), vertex.y);
|
||||
m_YValueCtrl->Clear();
|
||||
m_YValueCtrl->AppendText(text);
|
||||
|
||||
text.Printf(wxT("%f"), vertex.z);
|
||||
m_ZValueCtrl->Clear();
|
||||
m_ZValueCtrl->AppendText(text);
|
||||
}
|
||||
|
||||
/*****************************************/
|
||||
void WinEDA_VertexCtrl::Enable(bool onoff)
|
||||
/*****************************************/
|
||||
{
|
||||
m_XValueCtrl->Enable(onoff);
|
||||
m_YValueCtrl->Enable(onoff);
|
||||
m_ZValueCtrl->Enable(onoff);
|
||||
}
|
||||
|
619
3d-viewer/3d_canvas.cpp
Normal file
619
3d-viewer/3d_canvas.cpp
Normal file
@ -0,0 +1,619 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: 3d_canvas.cpp
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "trigo.h"
|
||||
|
||||
#include "wx/image.h"
|
||||
|
||||
#if !wxUSE_GLCANVAS
|
||||
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
|
||||
#endif
|
||||
|
||||
#include "wx/dataobj.h"
|
||||
#include "wx/clipbrd.h"
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "common.h"
|
||||
#include "id.h"
|
||||
|
||||
#include "3d_viewer.h"
|
||||
#include "trackball.h"
|
||||
|
||||
/* Tool and button Bitmaps */
|
||||
#define XPM_3D_MAIN
|
||||
#include "bitmaps3d.h"
|
||||
#include "bitmaps.h"
|
||||
|
||||
enum onrclick_id
|
||||
{
|
||||
ID_POPUP_3D_VIEW_START = 2000,
|
||||
ID_POPUP_ZOOMIN,
|
||||
ID_POPUP_ZOOMOUT,
|
||||
ID_POPUP_VIEW_XPOS,
|
||||
ID_POPUP_VIEW_XNEG,
|
||||
ID_POPUP_VIEW_YPOS,
|
||||
ID_POPUP_VIEW_YNEG,
|
||||
ID_POPUP_VIEW_ZPOS,
|
||||
ID_POPUP_VIEW_ZNEG,
|
||||
ID_POPUP_MOVE3D_LEFT,
|
||||
ID_POPUP_MOVE3D_RIGHT,
|
||||
ID_POPUP_MOVE3D_UP,
|
||||
ID_POPUP_MOVE3D_DOWN,
|
||||
ID_POPUP_3D_VIEW_END
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Pcb3D_GLCanvas implementation
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE(Pcb3D_GLCanvas, wxGLCanvas)
|
||||
EVT_SIZE(Pcb3D_GLCanvas::OnSize)
|
||||
EVT_PAINT(Pcb3D_GLCanvas::OnPaint)
|
||||
EVT_CHAR(Pcb3D_GLCanvas::OnChar)
|
||||
EVT_MOUSE_EVENTS(Pcb3D_GLCanvas::OnMouseEvent)
|
||||
EVT_ERASE_BACKGROUND(Pcb3D_GLCanvas::OnEraseBackground)
|
||||
EVT_MENU_RANGE(ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END,
|
||||
Pcb3D_GLCanvas::OnPopUpMenu)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*************************************************************************/
|
||||
Pcb3D_GLCanvas::Pcb3D_GLCanvas(WinEDA3D_DrawFrame *parent, wxWindowID id,
|
||||
int* gl_attrib):
|
||||
wxGLCanvas(parent, id, wxPoint(-1,-1), wxSize(-1,-1), 0, wxT("Pcb3D_glcanvas"), gl_attrib)
|
||||
/*************************************************************************/
|
||||
{
|
||||
m_init = FALSE;
|
||||
m_gllist = 0;
|
||||
m_Parent = parent;
|
||||
DisplayStatus();
|
||||
}
|
||||
|
||||
|
||||
/*************************************/
|
||||
Pcb3D_GLCanvas::~Pcb3D_GLCanvas(void)
|
||||
/*************************************/
|
||||
{
|
||||
ClearLists();
|
||||
}
|
||||
|
||||
/*************************************/
|
||||
void Pcb3D_GLCanvas::ClearLists(void)
|
||||
/*************************************/
|
||||
{
|
||||
if( m_gllist > 0 )
|
||||
glDeleteLists(m_gllist, 1);
|
||||
m_init = FALSE;
|
||||
m_gllist = 0;
|
||||
}
|
||||
|
||||
/*********************************************/
|
||||
void Pcb3D_GLCanvas::OnChar(wxKeyEvent& event)
|
||||
/*********************************************/
|
||||
{
|
||||
SetView3D(event.GetKeyCode());
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/*********************************************/
|
||||
void Pcb3D_GLCanvas::SetView3D(int keycode)
|
||||
/*********************************************/
|
||||
{
|
||||
int ii;
|
||||
double delta_move = 0.7 * g_Parm_3D_Visu.m_Zoom;
|
||||
|
||||
switch(keycode)
|
||||
{
|
||||
case WXK_LEFT:
|
||||
g_Draw3d_dx -= delta_move;
|
||||
break;
|
||||
case WXK_RIGHT:
|
||||
g_Draw3d_dx += delta_move;
|
||||
break;
|
||||
case WXK_UP:
|
||||
g_Draw3d_dy += delta_move;
|
||||
break;
|
||||
case WXK_DOWN:
|
||||
g_Draw3d_dy -= delta_move;
|
||||
break;
|
||||
|
||||
case WXK_HOME:
|
||||
g_Parm_3D_Visu.m_Zoom = 1.0;
|
||||
g_Draw3d_dx = g_Draw3d_dy = 0;
|
||||
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||
break;
|
||||
|
||||
case WXK_END:
|
||||
break;
|
||||
|
||||
case WXK_F1:
|
||||
g_Parm_3D_Visu.m_Zoom /= 1.4;
|
||||
if ( g_Parm_3D_Visu.m_Zoom <= 0.01)
|
||||
g_Parm_3D_Visu.m_Zoom = 0.01;
|
||||
break;
|
||||
|
||||
case WXK_F2:
|
||||
g_Parm_3D_Visu.m_Zoom *= 1.4;
|
||||
break;
|
||||
|
||||
case '+':
|
||||
break;
|
||||
|
||||
case '-':
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
case 'R':
|
||||
g_Draw3d_dx = g_Draw3d_dy = 0;
|
||||
for ( ii = 0; ii < 4; ii++ )
|
||||
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
||||
trackball(g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
for ( ii = 0; ii < 4; ii++ )
|
||||
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
||||
trackball(g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||
g_Parm_3D_Visu.m_ROTZ = -90;
|
||||
g_Parm_3D_Visu.m_ROTX = -90;
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
for ( ii = 0; ii < 4; ii++ )
|
||||
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
||||
trackball(g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||
g_Parm_3D_Visu.m_ROTZ = 90;
|
||||
g_Parm_3D_Visu.m_ROTX = -90;
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
for ( ii = 0; ii < 4; ii++ )
|
||||
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
||||
trackball(g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||
g_Parm_3D_Visu.m_ROTX = -90;
|
||||
break;
|
||||
|
||||
case 'Y':
|
||||
for ( ii = 0; ii < 4; ii++ )
|
||||
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
||||
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||
g_Parm_3D_Visu.m_ROTX = -90;
|
||||
g_Parm_3D_Visu.m_ROTZ = -180;
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
for ( ii = 0; ii < 4; ii++ )
|
||||
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
||||
trackball(g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||
break;
|
||||
|
||||
case 'Z':
|
||||
for ( ii = 0; ii < 4; ii++ )
|
||||
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
||||
trackball(g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||
g_Parm_3D_Visu.m_ROTX = -180;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
DisplayStatus();
|
||||
Refresh(FALSE);
|
||||
}
|
||||
|
||||
/********************************************************/
|
||||
void Pcb3D_GLCanvas::OnMouseEvent(wxMouseEvent& event)
|
||||
/********************************************************/
|
||||
{
|
||||
wxSize size(GetClientSize());
|
||||
float spin_quat[4];
|
||||
|
||||
|
||||
if( event.RightDown() )
|
||||
{
|
||||
OnRightClick(event); return;
|
||||
}
|
||||
|
||||
if ( event.m_wheelRotation )
|
||||
{
|
||||
if ( event.GetWheelRotation() > 0 )
|
||||
{
|
||||
g_Parm_3D_Visu.m_Zoom /= 1.4;
|
||||
if ( g_Parm_3D_Visu.m_Zoom <= 0.01)
|
||||
g_Parm_3D_Visu.m_Zoom = 0.01;
|
||||
}
|
||||
|
||||
else g_Parm_3D_Visu.m_Zoom *= 1.4;
|
||||
DisplayStatus();
|
||||
Refresh(FALSE);
|
||||
}
|
||||
|
||||
if (event.Dragging())
|
||||
{
|
||||
/* drag in progress, simulate trackball */
|
||||
trackball(spin_quat,
|
||||
(2.0*g_Parm_3D_Visu.m_Beginx - size.x) / size.x,
|
||||
(size.y - 2.0*g_Parm_3D_Visu.m_Beginy) / size.y,
|
||||
( 2.0*event.GetX() - size.x) / size.x,
|
||||
( size.y - 2.0*event.GetY()) / size.y);
|
||||
|
||||
add_quats( spin_quat, g_Parm_3D_Visu.m_Quat, g_Parm_3D_Visu.m_Quat );
|
||||
|
||||
/* orientation has changed, redraw mesh */
|
||||
DisplayStatus();
|
||||
Refresh(FALSE);
|
||||
}
|
||||
|
||||
g_Parm_3D_Visu.m_Beginx = event.GetX();
|
||||
g_Parm_3D_Visu.m_Beginy = event.GetY();
|
||||
}
|
||||
|
||||
/*******************************************************/
|
||||
void Pcb3D_GLCanvas::OnRightClick(wxMouseEvent& event)
|
||||
/*******************************************************/
|
||||
/* Construit et affiche un menu Popup lorsque on actionne le bouton droit
|
||||
de la souris
|
||||
*/
|
||||
{
|
||||
wxPoint pos;
|
||||
wxMenu PopUpMenu;
|
||||
|
||||
pos.x = event.GetX(); pos.y = event.GetY();
|
||||
wxMenuItem *item = new wxMenuItem(&PopUpMenu, ID_POPUP_ZOOMIN,
|
||||
_("Zoom +"));
|
||||
item->SetBitmap(zoom_in_xpm);
|
||||
PopUpMenu.Append(item);
|
||||
|
||||
item = new wxMenuItem(&PopUpMenu, ID_POPUP_ZOOMOUT,
|
||||
_("Zoom -"));
|
||||
item->SetBitmap(zoom_out_xpm);
|
||||
PopUpMenu.Append(item);
|
||||
|
||||
PopUpMenu.AppendSeparator();
|
||||
item = new wxMenuItem(&PopUpMenu, ID_POPUP_VIEW_ZPOS,
|
||||
_("Top View"));
|
||||
item->SetBitmap(axis3d_top_xpm);
|
||||
PopUpMenu.Append(item);
|
||||
|
||||
item = new wxMenuItem(&PopUpMenu, ID_POPUP_VIEW_ZNEG,
|
||||
_("Bottom View"));
|
||||
item->SetBitmap(axis3d_bottom_xpm);
|
||||
PopUpMenu.Append(item);
|
||||
|
||||
PopUpMenu.AppendSeparator();
|
||||
item = new wxMenuItem(&PopUpMenu, ID_POPUP_VIEW_XPOS,
|
||||
_("Right View"));
|
||||
item->SetBitmap(axis3d_right_xpm);
|
||||
PopUpMenu.Append(item);
|
||||
|
||||
item = new wxMenuItem(&PopUpMenu, ID_POPUP_VIEW_XNEG,
|
||||
_("Left View"));
|
||||
item->SetBitmap(axis3d_left_xpm);
|
||||
PopUpMenu.Append(item);
|
||||
|
||||
|
||||
PopUpMenu.AppendSeparator();
|
||||
item = new wxMenuItem(&PopUpMenu, ID_POPUP_VIEW_YPOS,
|
||||
_("Front View"));
|
||||
item->SetBitmap(axis3d_front_xpm);
|
||||
PopUpMenu.Append(item);
|
||||
|
||||
item = new wxMenuItem(&PopUpMenu, ID_POPUP_VIEW_YNEG,
|
||||
_("Back View"));
|
||||
item->SetBitmap(axis3d_back_xpm);
|
||||
PopUpMenu.Append(item);
|
||||
|
||||
PopUpMenu.AppendSeparator();
|
||||
item = new wxMenuItem(&PopUpMenu, ID_POPUP_MOVE3D_LEFT,
|
||||
_("Move left <-"));
|
||||
item->SetBitmap(left_xpm);
|
||||
PopUpMenu.Append(item);
|
||||
|
||||
item = new wxMenuItem(&PopUpMenu, ID_POPUP_MOVE3D_RIGHT,
|
||||
_("Move right ->"));
|
||||
item->SetBitmap(right_xpm);
|
||||
PopUpMenu.Append(item);
|
||||
|
||||
item = new wxMenuItem(&PopUpMenu, ID_POPUP_MOVE3D_UP,
|
||||
_("Move Up ^"));
|
||||
item->SetBitmap(up_xpm);
|
||||
PopUpMenu.Append(item);
|
||||
|
||||
item = new wxMenuItem(&PopUpMenu, ID_POPUP_MOVE3D_DOWN,
|
||||
_("Move Down"));
|
||||
item->SetBitmap(down_xpm);
|
||||
PopUpMenu.Append(item);
|
||||
|
||||
PopupMenu( &PopUpMenu, pos);
|
||||
}
|
||||
|
||||
/*******************************************************/
|
||||
void Pcb3D_GLCanvas::OnPopUpMenu(wxCommandEvent & event)
|
||||
/*******************************************************/
|
||||
{
|
||||
int key = 0;
|
||||
|
||||
switch( event.GetId() )
|
||||
{
|
||||
case ID_POPUP_ZOOMIN:
|
||||
key = WXK_F1;
|
||||
break;
|
||||
|
||||
case ID_POPUP_ZOOMOUT:
|
||||
key = WXK_F2;
|
||||
break;
|
||||
|
||||
case ID_POPUP_VIEW_XPOS:
|
||||
key = 'x';
|
||||
break;
|
||||
|
||||
case ID_POPUP_VIEW_XNEG:
|
||||
key = 'X';
|
||||
break;
|
||||
|
||||
case ID_POPUP_VIEW_YPOS:
|
||||
key = 'y';
|
||||
break;
|
||||
|
||||
case ID_POPUP_VIEW_YNEG:
|
||||
key = 'Y';
|
||||
break;
|
||||
|
||||
case ID_POPUP_VIEW_ZPOS:
|
||||
key = 'z';
|
||||
break;
|
||||
|
||||
case ID_POPUP_VIEW_ZNEG:
|
||||
key = 'Z';
|
||||
break;
|
||||
|
||||
case ID_POPUP_MOVE3D_LEFT:
|
||||
key = WXK_LEFT;
|
||||
break;
|
||||
|
||||
case ID_POPUP_MOVE3D_RIGHT:
|
||||
key = WXK_RIGHT;
|
||||
break;
|
||||
|
||||
case ID_POPUP_MOVE3D_UP:
|
||||
key = WXK_UP;
|
||||
break;
|
||||
|
||||
case ID_POPUP_MOVE3D_DOWN:
|
||||
key = WXK_DOWN;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
SetView3D(key);
|
||||
}
|
||||
|
||||
|
||||
/***************************************/
|
||||
void Pcb3D_GLCanvas::DisplayStatus(void)
|
||||
/***************************************/
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf(wxT("dx %3.2f"), g_Draw3d_dx);
|
||||
m_Parent->SetStatusText(msg,1);
|
||||
|
||||
msg.Printf(wxT("dy %3.2f"), g_Draw3d_dy);
|
||||
m_Parent->SetStatusText(msg,2);
|
||||
|
||||
msg.Printf(wxT("View: %3.1f"), 45 * g_Parm_3D_Visu.m_Zoom);
|
||||
m_Parent->SetStatusText(msg,3);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************/
|
||||
void Pcb3D_GLCanvas::OnPaint( wxPaintEvent& event )
|
||||
/*************************************************/
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
|
||||
#ifndef __WXMOTIF__
|
||||
if (!GetContext()) return;
|
||||
#endif
|
||||
Redraw();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
/**********************************************/
|
||||
void Pcb3D_GLCanvas::OnSize(wxSizeEvent& event)
|
||||
/**********************************************/
|
||||
{
|
||||
// this is also necessary to update the context on some platforms
|
||||
wxGLCanvas::OnSize(event);
|
||||
|
||||
// set GL viewport (not called by wxGLCanvas::OnSize on all platforms...)
|
||||
int w, h;
|
||||
GetClientSize(&w, &h);
|
||||
#ifndef __WXMOTIF__
|
||||
if (GetContext())
|
||||
#endif
|
||||
{
|
||||
SetCurrent();
|
||||
glViewport(0, 0, (GLint) w, (GLint) h);
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
void Pcb3D_GLCanvas::OnEraseBackground(wxEraseEvent& event)
|
||||
/***********************************************************/
|
||||
{
|
||||
// Do nothing, to avoid flashing.
|
||||
}
|
||||
|
||||
|
||||
/****************************/
|
||||
void Pcb3D_GLCanvas::InitGL()
|
||||
/****************************/
|
||||
/* Int parametres generaux pour OPENGL
|
||||
*/
|
||||
{
|
||||
wxSize size = GetClientSize();
|
||||
|
||||
if (! m_init)
|
||||
{
|
||||
m_init = TRUE;
|
||||
g_Parm_3D_Visu.m_Zoom = 1.0;
|
||||
ZBottom = 1.0; ZTop = 10.0;
|
||||
}
|
||||
|
||||
SetCurrent();
|
||||
|
||||
/* set viewing projection */
|
||||
double ratio_HV = (double) size.x / size.y; // Ratio largeur /hauteur de la fenetre d'affichage
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
#define MAX_VIEW_ANGLE 160.0/45.0
|
||||
if ( g_Parm_3D_Visu.m_Zoom > MAX_VIEW_ANGLE)
|
||||
g_Parm_3D_Visu.m_Zoom = MAX_VIEW_ANGLE;
|
||||
gluPerspective( 45.0 * g_Parm_3D_Visu.m_Zoom, ratio_HV, 1 ,10 );
|
||||
|
||||
// glFrustum(-1., 1.1F, -1.1F, 1.1F, ZBottom, ZTop);
|
||||
|
||||
/* position viewer */
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0F, 0.0F, - ( ZBottom +ZTop) / 2);
|
||||
|
||||
/* clear color and depth buffers */
|
||||
glClearColor( g_Parm_3D_Visu.m_BgColor.m_Red,
|
||||
g_Parm_3D_Visu.m_BgColor.m_Green,
|
||||
g_Parm_3D_Visu.m_BgColor.m_Blue, 1 );
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
|
||||
/* Setup light souces: */
|
||||
SetLights();
|
||||
|
||||
|
||||
glDisable(GL_CULL_FACE); // show back faces
|
||||
|
||||
glEnable(GL_DEPTH_TEST); // Enable z-buferring
|
||||
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
|
||||
|
||||
/* speedups */
|
||||
glEnable(GL_DITHER);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||
glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST);
|
||||
|
||||
/* blend */
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
|
||||
/***********************************/
|
||||
void Pcb3D_GLCanvas::SetLights(void)
|
||||
/***********************************/
|
||||
/* Init sources lumineuses pour OPENGL
|
||||
*/
|
||||
{
|
||||
double light;
|
||||
GLfloat light_color[4];
|
||||
|
||||
SetCurrent();
|
||||
|
||||
/* set viewing projection */
|
||||
light_color[3] = 1.0;
|
||||
GLfloat Z_axis_pos[4] = { 0.0, 0.0, 3.0, 0.0 };
|
||||
GLfloat lowZ_axis_pos[4] = { 0.0, 0.0, -3.0, 0.5 };
|
||||
|
||||
/* activate light */
|
||||
light = 1.0;
|
||||
light_color[0] = light_color[1] = light_color[2]= light;
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, Z_axis_pos);
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_color);
|
||||
light = 0.3;
|
||||
light_color[0] = light_color[1] = light_color[2] = light;
|
||||
glLightfv(GL_LIGHT1, GL_POSITION, lowZ_axis_pos);
|
||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, light_color);
|
||||
glEnable(GL_LIGHT0); // White spot on Z axis
|
||||
glEnable(GL_LIGHT1); // White spot on Z axis ( bottom)
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************/
|
||||
void Pcb3D_GLCanvas::TakeScreenshot(wxCommandEvent & event)
|
||||
/**********************************************************/
|
||||
/* Create a Screenshot of the current 3D view.
|
||||
Output file format is png or jpeg, or image is copied on clipboard
|
||||
*/
|
||||
{
|
||||
wxString FullFileName;
|
||||
wxString file_ext, mask;
|
||||
bool fmt_is_jpeg = FALSE;
|
||||
|
||||
if ( event.GetId() == ID_MENU_SCREENCOPY_JPEG ) fmt_is_jpeg = TRUE;
|
||||
if ( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
|
||||
{
|
||||
file_ext = fmt_is_jpeg ? wxT(".jpg") : wxT(".png";)
|
||||
mask = wxT("*") + file_ext;
|
||||
FullFileName = m_Parent->m_Parent->GetScreen()->m_FileName;
|
||||
ChangeFileNameExt(FullFileName,file_ext);
|
||||
|
||||
FullFileName =
|
||||
EDA_FileSelector( _("3D Image filename:"),
|
||||
wxEmptyString, /* Chemin par defaut */
|
||||
FullFileName, /* nom fichier par defaut */
|
||||
file_ext, /* extension par defaut */
|
||||
mask, /* Masque d'affichage */
|
||||
this,
|
||||
wxFD_SAVE,
|
||||
TRUE
|
||||
);
|
||||
if ( FullFileName.IsEmpty() ) return;
|
||||
}
|
||||
wxSize image_size = GetClientSize();
|
||||
wxClientDC dc(this);
|
||||
wxBitmap bitmap(image_size.x, image_size.y );
|
||||
wxMemoryDC memdc;
|
||||
memdc.SelectObject( bitmap );
|
||||
memdc.Blit(0, 0, image_size.x, image_size.y, &dc, 0, 0);
|
||||
memdc.SelectObject( wxNullBitmap );
|
||||
|
||||
if ( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
|
||||
{
|
||||
wxBitmapDataObject *dobjBmp = new wxBitmapDataObject;
|
||||
dobjBmp->SetBitmap(bitmap);
|
||||
if (wxTheClipboard->Open())
|
||||
{
|
||||
if ( !wxTheClipboard->SetData(dobjBmp) )
|
||||
wxLogError( _T("Failed to copy image to clipboard"));
|
||||
wxTheClipboard->Flush(); /* the data on clipboard
|
||||
will stay available after the application exits */
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
wxImage image = bitmap.ConvertToImage();
|
||||
|
||||
if ( !image.SaveFile( FullFileName,
|
||||
fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG))
|
||||
wxLogError(wxT("Can't save file"));
|
||||
|
||||
image.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
119
3d-viewer/3d_class.cpp
Normal file
119
3d-viewer/3d_class.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: 3d_class.cpp
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "fctsys.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "3d_struct.h"
|
||||
#include "3d_viewer.h"
|
||||
|
||||
|
||||
/****************************/
|
||||
S3D_Vertex::S3D_Vertex(void)
|
||||
/****************************/
|
||||
{
|
||||
x = y = z = 0.0;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
S3D_Material::S3D_Material(Struct3D_Master * father, const wxString & name):
|
||||
EDA_BaseStruct( father, -1)
|
||||
/**************************************************************************/
|
||||
{
|
||||
m_DiffuseColor.x = m_DiffuseColor.y = m_DiffuseColor.z = 1.0;
|
||||
m_SpecularColor.x = m_SpecularColor.y = m_SpecularColor.z = 1.0;
|
||||
m_AmbientIntensity = 1.0;
|
||||
m_Transparency = 0.0;
|
||||
m_Shininess = 1.0;
|
||||
m_Name = name;
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
void S3D_Material::SetMaterial(void)
|
||||
/***********************************/
|
||||
{
|
||||
glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
|
||||
glColor4f(m_DiffuseColor.x * m_AmbientIntensity,
|
||||
m_DiffuseColor.y * m_AmbientIntensity,
|
||||
m_DiffuseColor.z * m_AmbientIntensity,
|
||||
1.0 - m_Transparency );
|
||||
#if 0
|
||||
glColorMaterial(GL_FRONT_AND_BACK,GL_SPECULAR);
|
||||
glColor3f(m_SpecularColor.x, m_SpecularColor.y,m_SpecularColor.z);
|
||||
#endif
|
||||
glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
|
||||
}
|
||||
|
||||
/****************************************************/
|
||||
void Struct3D_Master::Copy(Struct3D_Master * pattern)
|
||||
/****************************************************/
|
||||
{
|
||||
m_Shape3DName = pattern->m_Shape3DName;
|
||||
m_MatScale = pattern->m_MatScale;
|
||||
m_MatRotation = pattern->m_MatRotation;
|
||||
m_MatPosition = pattern->m_MatPosition;
|
||||
m_3D_Drawings = NULL;
|
||||
m_Materials = NULL;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
Struct3D_Master::Struct3D_Master(EDA_BaseStruct * StructFather):
|
||||
EDA_BaseStruct( StructFather, -1)
|
||||
/***************************************************************/
|
||||
{
|
||||
m_MatScale.x = m_MatScale.y = m_MatScale.z = 1.0;
|
||||
m_3D_Drawings = NULL;
|
||||
m_Materials = NULL;
|
||||
}
|
||||
|
||||
|
||||
/***************************************/
|
||||
Struct3D_Master:: ~Struct3D_Master(void)
|
||||
/***************************************/
|
||||
{
|
||||
Struct3D_Shape * next;
|
||||
S3D_Material * nextmat;
|
||||
|
||||
for( ; m_3D_Drawings != NULL; m_3D_Drawings = next )
|
||||
{
|
||||
next = (Struct3D_Shape *) m_3D_Drawings->Pnext;
|
||||
delete m_3D_Drawings;
|
||||
}
|
||||
|
||||
for( ; m_Materials != NULL; m_Materials = nextmat )
|
||||
{
|
||||
nextmat = (S3D_Material *) m_Materials->Pnext;
|
||||
delete m_Materials;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************/
|
||||
Struct3D_Shape::Struct3D_Shape(EDA_BaseStruct * StructFather):
|
||||
EDA_BaseStruct( StructFather, -1)
|
||||
/***************************************************************/
|
||||
{
|
||||
m_3D_Coord = NULL;
|
||||
m_3D_CoordIndex = NULL;
|
||||
m_3D_Points = 0;
|
||||
}
|
||||
|
||||
|
||||
/***************************************/
|
||||
Struct3D_Shape:: ~Struct3D_Shape(void)
|
||||
/***************************************/
|
||||
{
|
||||
delete m_3D_Coord;
|
||||
delete m_3D_CoordIndex;
|
||||
}
|
||||
|
787
3d-viewer/3d_draw.cpp
Normal file
787
3d-viewer/3d_draw.cpp
Normal file
@ -0,0 +1,787 @@
|
||||
//////////////////////////////////////
|
||||
// Name: 3d_draw.cpp
|
||||
//////////////////////////////////////
|
||||
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "trigo.h"
|
||||
|
||||
|
||||
#if !wxUSE_GLCANVAS
|
||||
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include "pcbstruct.h"
|
||||
#include "macros.h"
|
||||
|
||||
//#include "pcbnew.h"
|
||||
|
||||
#include "3d_viewer.h"
|
||||
#include "trackball.h"
|
||||
|
||||
#include "3d_struct.h"
|
||||
|
||||
static void Draw3D_FilledCircle(double posx, double posy,
|
||||
double rayon, double hole_rayon, double zpos);
|
||||
static void Draw3D_FilledSegment(double startx, double starty,
|
||||
double endx, double endy,double width, double zpos);
|
||||
static void Draw3D_FilledCylinder(double posx, double posy,
|
||||
double rayon, double height, double zpos);
|
||||
static void Draw3D_FilledSegmentWithHole(double startx, double starty,
|
||||
double endx, double endy,double width,
|
||||
double holex, double holey, double holeradius, double zpos);
|
||||
|
||||
|
||||
/**********************************/
|
||||
void Pcb3D_GLCanvas::Redraw( void )
|
||||
/**********************************/
|
||||
{
|
||||
SetCurrent();
|
||||
|
||||
InitGL();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW); /* position viewer */
|
||||
/* transformations */
|
||||
GLfloat mat[4][4];
|
||||
|
||||
build_rotmatrix( mat, g_Parm_3D_Visu.m_Quat );
|
||||
glMultMatrixf( &mat[0][0] );
|
||||
|
||||
glTranslatef(g_Draw3d_dx, g_Draw3d_dy, 0.0F);
|
||||
|
||||
glRotatef(g_Parm_3D_Visu.m_Rot[0], 1.0, 0.0, 0.0);
|
||||
glRotatef(g_Parm_3D_Visu.m_Rot[1], 0.0, 1.0, 0.0);
|
||||
glRotatef(g_Parm_3D_Visu.m_Rot[2], 0.0, 0.0, 1.0);
|
||||
|
||||
if( m_gllist ) glCallList( m_gllist );
|
||||
else
|
||||
{
|
||||
m_gllist = CreateDrawGL_List();
|
||||
// m_gllist = DisplayCubeforTest(); // Only for test
|
||||
}
|
||||
|
||||
glFlush();
|
||||
SwapBuffers();
|
||||
}
|
||||
|
||||
/**********************************************/
|
||||
GLuint Pcb3D_GLCanvas::CreateDrawGL_List(void)
|
||||
/**********************************************/
|
||||
/* Creation de la liste des elements a afficher
|
||||
*/
|
||||
{
|
||||
GLuint gllist = glGenLists( 1 );
|
||||
WinEDA_BasePcbFrame * pcbframe = m_Parent->m_Parent;
|
||||
BOARD * pcb = pcbframe->m_Pcb;
|
||||
TRACK * pt_piste;
|
||||
int ii;
|
||||
|
||||
wxBusyCursor dummy;
|
||||
|
||||
pcb->ComputeBoundaryBox();
|
||||
g_Parm_3D_Visu.m_BoardSettings = pcb->m_BoardSettings;
|
||||
g_Parm_3D_Visu.m_BoardSize = pcb->m_BoundaryBox.GetSize();
|
||||
g_Parm_3D_Visu.m_BoardPos = pcb->m_BoundaryBox.Centre();
|
||||
g_Parm_3D_Visu.m_BoardPos.y = - g_Parm_3D_Visu.m_BoardPos.y;
|
||||
g_Parm_3D_Visu.m_Layers = pcb->m_BoardSettings->m_CopperLayerCount;
|
||||
g_Parm_3D_Visu.m_BoardScale = 2.0 / MAX(g_Parm_3D_Visu.m_BoardSize.x, g_Parm_3D_Visu.m_BoardSize.y);
|
||||
float epoxy_width = 1.6; // epoxy width in mm
|
||||
g_Parm_3D_Visu.m_Epoxy_Width = epoxy_width/2.54 * 1000
|
||||
* g_Parm_3D_Visu.m_BoardScale;
|
||||
|
||||
/* calcul de l'altitude de chaque couche */
|
||||
for ( ii = 0; ii < 32; ii++ )
|
||||
{
|
||||
if ( ii < g_Parm_3D_Visu.m_Layers )
|
||||
g_Parm_3D_Visu.m_LayerZcoord[ii] = g_Parm_3D_Visu.m_Epoxy_Width * ii
|
||||
/ (g_Parm_3D_Visu.m_Layers-1);
|
||||
else g_Parm_3D_Visu.m_LayerZcoord[ii] = g_Parm_3D_Visu.m_Epoxy_Width;
|
||||
}
|
||||
GLfloat zpos_cu = 500 * g_Parm_3D_Visu.m_BoardScale;
|
||||
GLfloat zpos_cmp = g_Parm_3D_Visu.m_Epoxy_Width + zpos_cu;
|
||||
g_Parm_3D_Visu.m_LayerZcoord[ADHESIVE_N_CU] = -zpos_cu*2;
|
||||
g_Parm_3D_Visu.m_LayerZcoord[ADHESIVE_N_CMP] = zpos_cmp + zpos_cu;
|
||||
g_Parm_3D_Visu.m_LayerZcoord[SILKSCREEN_N_CU] = -zpos_cu;
|
||||
g_Parm_3D_Visu.m_LayerZcoord[SILKSCREEN_N_CMP] = zpos_cmp;
|
||||
g_Parm_3D_Visu.m_LayerZcoord[DRAW_N] = zpos_cmp + zpos_cu;
|
||||
g_Parm_3D_Visu.m_LayerZcoord[COMMENT_N] = zpos_cmp + zpos_cu;
|
||||
g_Parm_3D_Visu.m_LayerZcoord[ECO1_N] = zpos_cmp + zpos_cu;
|
||||
g_Parm_3D_Visu.m_LayerZcoord[ECO2_N] = zpos_cmp + zpos_cu;
|
||||
|
||||
glNewList( gllist, GL_COMPILE_AND_EXECUTE );
|
||||
|
||||
glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
|
||||
|
||||
/* draw axes*/
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
SetGLColor(WHITE);
|
||||
glBegin(GL_LINES);
|
||||
glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis
|
||||
glVertex3f( 0.0 , 0.0, 0.0); glVertex3f(1.0, 0.0, 0.0); // X axis
|
||||
glVertex3f( 0.0 , 0.0, 0.0); glVertex3f(0.0, -1.0, 0.0); // y axis
|
||||
glNormal3f( 1.0, 0.0, 0.0); // Normal is Y axis
|
||||
glVertex3f( 0.0 , 0.0, 0.0); glVertex3f(0.0, 0.0, 0.3); // z axis
|
||||
glEnd();
|
||||
|
||||
/* Draw epoxy limits (do not use, works and test in progress)*/
|
||||
#if 0
|
||||
glEnable(GL_FOG);
|
||||
GLfloat param;
|
||||
// param = GL_LINEAR; glFogfv(GL_FOG_MODE,& param);
|
||||
param = 0.2; glFogfv(GL_FOG_DENSITY,& param);
|
||||
param = g_Parm_3D_Visu.m_LayerZcoord[15]; glFogfv(GL_FOG_END,& param);
|
||||
glBegin(GL_QUADS);
|
||||
SetGLColor(g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[CMP_N]);
|
||||
double sx = DataScale3D * g_Parm_3D_Visu.m_BoardSize.x / 2;
|
||||
double sy = DataScale3D * g_Parm_3D_Visu.m_BoardSize.y / 2;
|
||||
double zpos = g_Parm_3D_Visu.m_LayerZcoord[15];
|
||||
glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis
|
||||
sx = sy = 0.5;
|
||||
glVertex3f( -sx, -sy , zpos);
|
||||
glVertex3f( -sx, sy , zpos);
|
||||
glVertex3f( sx, sy , zpos);
|
||||
glVertex3f( sx, -sy , zpos);
|
||||
glEnd();
|
||||
glBegin(GL_QUADS);
|
||||
SetGLColor(g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[CUIVRE_N]);
|
||||
glNormal3f( 0.0, 0.0, -1.0); // Normal is -Z axis
|
||||
glVertex3f( -sx, -sy , 0);
|
||||
glVertex3f( -sx, sy , 0);
|
||||
glVertex3f( sx, sy , 0);
|
||||
glVertex3f( sx, -sy , 0);
|
||||
glEnd();
|
||||
#endif
|
||||
|
||||
/* Translation du tracé du BOARD pour placer son centre en 0, 0 */
|
||||
glTranslatef(-g_Parm_3D_Visu.m_BoardPos.x * g_Parm_3D_Visu.m_BoardScale,
|
||||
-g_Parm_3D_Visu.m_BoardPos.y * g_Parm_3D_Visu.m_BoardScale,
|
||||
0.0F);
|
||||
|
||||
glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis
|
||||
/* Tracé des pistes : */
|
||||
for (pt_piste = pcb->m_Track ; pt_piste != NULL ; pt_piste = (TRACK*) pt_piste->Pnext )
|
||||
{
|
||||
if ( pt_piste->m_StructType == TYPEVIA )
|
||||
Draw3D_Via((SEGVIA*)pt_piste);
|
||||
else Draw3D_Track( pt_piste);
|
||||
}
|
||||
|
||||
/* Tracé des edges */
|
||||
EDA_BaseStruct * PtStruct;
|
||||
for ( PtStruct = pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Pnext)
|
||||
{
|
||||
#define STRUCT ((DRAWSEGMENT *) PtStruct)
|
||||
if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue;
|
||||
Draw3D_DrawSegment(STRUCT);
|
||||
}
|
||||
|
||||
/* tracé des modules */
|
||||
MODULE * Module = (MODULE*) pcb->m_Modules;
|
||||
for ( ; Module != NULL; Module = (MODULE *) Module->Pnext )
|
||||
{
|
||||
Module->Draw3D(this);
|
||||
}
|
||||
glEndList();
|
||||
|
||||
/* Test for errors */
|
||||
GLenum err = glGetError();
|
||||
if ( err != GL_NO_ERROR )
|
||||
DisplayError(this, wxT("Error in GL commands") );
|
||||
return gllist;
|
||||
}
|
||||
|
||||
/************************************************/
|
||||
void Pcb3D_GLCanvas::Draw3D_Track(TRACK * track)
|
||||
/************************************************/
|
||||
{
|
||||
double zpos;
|
||||
int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[track->m_Layer];
|
||||
int layer = track->m_Layer;
|
||||
double ox, oy, fx, fy;
|
||||
double w;
|
||||
|
||||
if ( color & ITEM_NOT_SHOW ) return;
|
||||
if ( track->m_Layer == CMP_N ) layer = g_Parm_3D_Visu.m_Layers -1;
|
||||
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
|
||||
|
||||
SetGLColor(color);
|
||||
glNormal3f( 0.0, 0.0, (layer == CUIVRE_N) ? -1.0 : 1.0);
|
||||
|
||||
w = track->m_Width * g_Parm_3D_Visu.m_BoardScale;
|
||||
ox = track->m_Start.x * g_Parm_3D_Visu.m_BoardScale;
|
||||
oy = track->m_Start.y * g_Parm_3D_Visu.m_BoardScale;
|
||||
fx = track->m_End.x * g_Parm_3D_Visu.m_BoardScale;
|
||||
fy = track->m_End.y * g_Parm_3D_Visu.m_BoardScale;
|
||||
Draw3D_FilledSegment(ox, -oy, fx, -fy, w, zpos);
|
||||
}
|
||||
|
||||
/********************************************/
|
||||
void Pcb3D_GLCanvas::Draw3D_Via(SEGVIA * via)
|
||||
/*********************************************/
|
||||
/* 3D drawing for a VIA (cylinder + filled circles)
|
||||
*/
|
||||
{
|
||||
double x, y, r, hole;
|
||||
int layer, top_layer, bottom_layer;
|
||||
double zpos, height;
|
||||
int color;
|
||||
|
||||
r = via->m_Width * g_Parm_3D_Visu.m_BoardScale / 2;
|
||||
hole = g_Parm_3D_Visu.m_BoardSettings->m_ViaDrill * g_Parm_3D_Visu.m_BoardScale / 2;
|
||||
x = via->m_Start.x * g_Parm_3D_Visu.m_BoardScale;
|
||||
y = via->m_Start.y * g_Parm_3D_Visu.m_BoardScale;
|
||||
|
||||
via->ReturnLayerPair(&top_layer, &bottom_layer);
|
||||
|
||||
// Drawing filled circles:
|
||||
for ( layer = bottom_layer; layer < g_Parm_3D_Visu.m_Layers; layer++ )
|
||||
{
|
||||
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
|
||||
if ( layer < g_Parm_3D_Visu.m_Layers-1 )
|
||||
color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer];
|
||||
else color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[CMP_N];
|
||||
if ( color & ITEM_NOT_SHOW ) continue;
|
||||
SetGLColor(color);
|
||||
glNormal3f( 0.0, 0.0, (layer == CUIVRE_N) ? -1.0 : 1.0);
|
||||
Draw3D_FilledCircle(x, -y, r, hole, zpos);
|
||||
if ( layer >= top_layer) break;
|
||||
|
||||
}
|
||||
// Drawing hole:
|
||||
SetGLColor(DARKGRAY);
|
||||
height = g_Parm_3D_Visu.m_LayerZcoord[top_layer] - g_Parm_3D_Visu.m_LayerZcoord[bottom_layer];
|
||||
Draw3D_FilledCylinder(x, -y, hole, height, g_Parm_3D_Visu.m_LayerZcoord[bottom_layer]);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************/
|
||||
void Pcb3D_GLCanvas::Draw3D_DrawSegment(DRAWSEGMENT * segment)
|
||||
/*************************************************************/
|
||||
{
|
||||
int layer;
|
||||
double x, y, xf, yf;
|
||||
double zpos, w;
|
||||
int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[segment->m_Layer];
|
||||
|
||||
if ( color & ITEM_NOT_SHOW ) return;
|
||||
|
||||
SetGLColor(color);
|
||||
w = segment->m_Width * g_Parm_3D_Visu.m_BoardScale;
|
||||
x = segment->m_Start.x * g_Parm_3D_Visu.m_BoardScale;
|
||||
y = segment->m_Start.y * g_Parm_3D_Visu.m_BoardScale;
|
||||
xf = segment->m_End.x * g_Parm_3D_Visu.m_BoardScale;
|
||||
yf = segment->m_End.y * g_Parm_3D_Visu.m_BoardScale;
|
||||
|
||||
if ( segment->m_Layer == EDGE_N)
|
||||
{
|
||||
for ( layer = 0; layer < g_Parm_3D_Visu.m_Layers; layer++ )
|
||||
{
|
||||
glNormal3f( 0.0, 0.0, (layer == CUIVRE_N) ? -1.0 : 1.0);
|
||||
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
|
||||
Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
zpos = g_Parm_3D_Visu.m_LayerZcoord[segment->m_Layer];
|
||||
Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*********************************************/
|
||||
void MODULE::Draw3D(Pcb3D_GLCanvas * glcanvas)
|
||||
/*********************************************/
|
||||
{
|
||||
D_PAD * pad = m_Pads;
|
||||
|
||||
#if 0
|
||||
if( ! DisplayOpt.Show_Modules_Cmp )
|
||||
{
|
||||
if(m_Layer == CMP_N) return;
|
||||
}
|
||||
if( ! DisplayOpt.Show_Modules_Cu )
|
||||
{
|
||||
if(m_Layer == CUIVRE_N) return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Draw pads */
|
||||
glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
|
||||
glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis
|
||||
for( ; pad != NULL; pad = (D_PAD*) pad->Pnext )
|
||||
{
|
||||
pad->Draw3D(glcanvas);
|
||||
}
|
||||
|
||||
/* Draw module shape: 3D shape if exists (or module edge if not exists)*/
|
||||
Struct3D_Master * Struct3D = m_3D_Drawings;
|
||||
bool As3dShape = FALSE;
|
||||
glPushMatrix();
|
||||
glTranslatef(m_Pos.x * g_Parm_3D_Visu.m_BoardScale,
|
||||
-m_Pos.y * g_Parm_3D_Visu.m_BoardScale,
|
||||
g_Parm_3D_Visu.m_LayerZcoord[m_Layer] );
|
||||
if ( m_Orient )
|
||||
{
|
||||
glRotatef( (double)m_Orient / 10, 0.0, 0.0, 1.0 );
|
||||
}
|
||||
if ( m_Layer == CUIVRE_N )
|
||||
{
|
||||
glRotatef( 180.0, 0.0, 1.0, 0.0 );
|
||||
glRotatef( 180.0, 0.0, 0.0, 1.0 );
|
||||
}
|
||||
DataScale3D = g_Parm_3D_Visu.m_BoardScale*UNITS3D_TO_UNITSPCB;
|
||||
|
||||
for ( ; Struct3D != NULL; Struct3D = (Struct3D_Master *) Struct3D->Pnext )
|
||||
{
|
||||
if ( ! Struct3D->m_Shape3DName.IsEmpty() )
|
||||
{
|
||||
As3dShape = TRUE;
|
||||
Struct3D->ReadData();
|
||||
}
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
if ( ! As3dShape)
|
||||
{
|
||||
EDA_BaseStruct * Struct = m_Drawings;
|
||||
glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis
|
||||
for( ;Struct != NULL; Struct = Struct->Pnext )
|
||||
{
|
||||
switch( Struct->m_StructType )
|
||||
{
|
||||
case TYPETEXTEMODULE:
|
||||
break;
|
||||
|
||||
case TYPEEDGEMODULE:
|
||||
((EDGE_MODULE *) Struct)->Draw3D(glcanvas);
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************/
|
||||
void EDGE_MODULE::Draw3D(Pcb3D_GLCanvas * glcanvas)
|
||||
/***************************************************/
|
||||
{
|
||||
int ux0, uy0, dx, dy,rayon, StAngle, EndAngle;
|
||||
double scale, x, y, fx, fy, w, zpos ;
|
||||
int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[m_Layer];
|
||||
|
||||
if ( color & ITEM_NOT_SHOW ) return;
|
||||
|
||||
SetGLColor(color);
|
||||
glNormal3f( 0.0, 0.0, (m_Layer == CUIVRE_N) ? -1.0 : 1.0);
|
||||
scale = g_Parm_3D_Visu.m_BoardScale;
|
||||
|
||||
ux0 = m_Start.x;
|
||||
uy0 = m_Start.y;
|
||||
dx = m_End.x;
|
||||
dy = m_End.y;
|
||||
zpos = g_Parm_3D_Visu.m_LayerZcoord[m_Layer];
|
||||
w = m_Width * g_Parm_3D_Visu.m_BoardScale;
|
||||
switch (m_Shape )
|
||||
{
|
||||
case S_SEGMENT:
|
||||
x = m_Start.x * g_Parm_3D_Visu.m_BoardScale;
|
||||
y = m_Start.y * g_Parm_3D_Visu.m_BoardScale;
|
||||
fx = dx * g_Parm_3D_Visu.m_BoardScale;
|
||||
fy = dy * g_Parm_3D_Visu.m_BoardScale;
|
||||
Draw3D_FilledSegment(x, -y, fx, -fy, w, zpos);
|
||||
break ;
|
||||
|
||||
case S_CIRCLE:
|
||||
rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) );
|
||||
/* TO DO */
|
||||
break;
|
||||
|
||||
case S_ARC:
|
||||
rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) );
|
||||
StAngle = (int)ArcTangente( dy-uy0, dx-ux0 );
|
||||
EndAngle = StAngle + m_Angle;
|
||||
/* TO DO */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***********************************************/
|
||||
void D_PAD::Draw3D(Pcb3D_GLCanvas * glcanvas)
|
||||
/***********************************************/
|
||||
/* Dessin 3D des pads avec leur trou de percage
|
||||
*/
|
||||
{
|
||||
int ii, ll, layer, nlmax;
|
||||
int ux0,uy0,
|
||||
dx,dx0,dy,dy0,
|
||||
delta_cx, delta_cy,
|
||||
xc, yc;
|
||||
int angle, delta_angle;
|
||||
int coord[4][2];
|
||||
double fcoord[8][2], f_hole_coord[8][2];
|
||||
float scale;
|
||||
double zpos;
|
||||
wxPoint shape_pos;
|
||||
double x, y, r, w, hole, holeX, holeY;
|
||||
double drillx, drilly;
|
||||
bool Oncu, Oncmp, Both;
|
||||
int color;
|
||||
|
||||
scale = g_Parm_3D_Visu.m_BoardScale;
|
||||
holeX = (double)m_Drill.x * scale / 2;
|
||||
holeY = (double)m_Drill.y * scale / 2;
|
||||
hole = MIN (holeX,holeY);
|
||||
|
||||
/* calcul du centre des formes des pads : */
|
||||
shape_pos = ReturnShapePos();
|
||||
ux0 = shape_pos.x;
|
||||
uy0 = shape_pos.y;
|
||||
xc = ux0;
|
||||
yc = uy0;
|
||||
|
||||
/* le trace depend de la rotation de l'empreinte */
|
||||
dx = dx0 = m_Size.x >> 1 ;
|
||||
dy = dy0 = m_Size.y >> 1 ; /* demi dim dx et dy */
|
||||
|
||||
angle = m_Orient;
|
||||
drillx = m_Pos.x * scale;
|
||||
drilly = m_Pos.y * scale;
|
||||
/* Draw the pad hole (TODO: draw OBLONG hole)*/
|
||||
if ( holeX && holeY )
|
||||
{
|
||||
SetGLColor(DARKGRAY);
|
||||
Draw3D_FilledCylinder(drillx, -drilly, hole, g_Parm_3D_Visu.m_LayerZcoord[CMP_N], 0.0);
|
||||
}
|
||||
|
||||
glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis
|
||||
nlmax = g_Parm_3D_Visu.m_Layers-1;
|
||||
Oncu = (m_Masque_Layer & CUIVRE_LAYER) ? TRUE : FALSE;
|
||||
Oncmp = (m_Masque_Layer & CMP_LAYER) ? TRUE : FALSE;
|
||||
Both = Oncu && Oncmp;
|
||||
switch (m_PadShape & 0x7F)
|
||||
{
|
||||
case CIRCLE :
|
||||
x = xc * scale;
|
||||
y = yc * scale;
|
||||
r = (double)dx * scale;
|
||||
for ( layer = CUIVRE_N; layer <= CMP_N; layer ++)
|
||||
{
|
||||
if (layer && (layer == nlmax) ) layer = CMP_N;
|
||||
if ( (layer == CMP_N) && ! Oncmp ) continue;
|
||||
if ( (layer == CUIVRE_N) && ! Oncu ) continue;
|
||||
if ( (layer > CUIVRE_N) && (layer < CMP_N) && !Both) continue;
|
||||
color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer];
|
||||
if ( color & ITEM_NOT_SHOW ) continue;
|
||||
SetGLColor(color);
|
||||
glNormal3f( 0.0, 0.0, (layer == CUIVRE_N) ? -1.0 : 1.0);
|
||||
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
|
||||
Draw3D_FilledCircle(x, -y, r, hole, zpos);
|
||||
}
|
||||
break;
|
||||
|
||||
case OVALE :
|
||||
/* calcul de l'entraxe de l'ellipse */
|
||||
if( dx > dy ) /* ellipse horizontale */
|
||||
{
|
||||
delta_cx = dx - dy; delta_cy = 0;
|
||||
w = m_Size.y * scale;
|
||||
delta_angle = angle+900;
|
||||
}
|
||||
else /* ellipse verticale */
|
||||
{
|
||||
delta_cx = 0; delta_cy = dy - dx;
|
||||
w = m_Size.x * scale;
|
||||
delta_angle = angle;
|
||||
}
|
||||
RotatePoint(&delta_cx, &delta_cy, angle);
|
||||
{
|
||||
double ox, oy, fx, fy;
|
||||
ox = (double)(ux0 + delta_cx) * scale;
|
||||
oy = (double)(uy0 + delta_cy) * scale;
|
||||
fx = (double)(ux0 - delta_cx) * scale;
|
||||
fy = (double)(uy0 - delta_cy) * scale;
|
||||
for ( layer = CUIVRE_N; layer <= CMP_N; layer ++)
|
||||
{
|
||||
if (layer && (layer == nlmax) ) layer = CMP_N;
|
||||
if ( (layer == CMP_N) && ! Oncmp ) continue;
|
||||
if ( (layer == CUIVRE_N) && ! Oncu ) continue;
|
||||
if ( (layer > CUIVRE_N) && (layer < CMP_N) && !Both) continue;
|
||||
color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer];
|
||||
glNormal3f( 0.0, 0.0, (layer == CUIVRE_N) ? -1.0 : 1.0);
|
||||
if ( color & ITEM_NOT_SHOW ) continue;
|
||||
SetGLColor(color);
|
||||
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
|
||||
Draw3D_FilledSegmentWithHole(ox, -oy, fx, -fy, w, drillx, -drilly, hole, zpos);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RECT :
|
||||
case SPECIAL_PAD:
|
||||
case TRAPEZE:
|
||||
{
|
||||
int ddx, ddy ;
|
||||
ddx = m_DeltaSize.x >> 1 ;
|
||||
ddy = m_DeltaSize.y >> 1 ; /* demi dim dx et dy */
|
||||
|
||||
coord[0][0] = - dx - ddy;
|
||||
coord[0][1] = + dy + ddx;
|
||||
|
||||
coord[1][0] = - dx + ddy;
|
||||
coord[1][1] = - dy - ddx;
|
||||
|
||||
coord[2][0] = + dx - ddy;
|
||||
coord[2][1] = - dy + ddx;
|
||||
|
||||
coord[3][0] = + dx + ddy;
|
||||
coord[3][1] = + dy - ddx;
|
||||
|
||||
for (ii = 0; ii < 4; ii++)
|
||||
{
|
||||
RotatePoint(&coord[ii][0],&coord[ii][1], angle);
|
||||
coord[ii][0] += ux0;
|
||||
coord[ii][1] += uy0;
|
||||
ll = ii*2;
|
||||
fcoord[ll][0] = coord[ii][0] * scale;
|
||||
fcoord[ll][1] = coord[ii][1] * scale;
|
||||
}
|
||||
for (ii = 0; ii < 7; ii+=2)
|
||||
{
|
||||
ll = ii+2; if (ll > 7) ll -= 8;
|
||||
fcoord[ii+1][0] = (fcoord[ii][0] + fcoord[ll][0])/2;
|
||||
fcoord[ii+1][1] = (fcoord[ii][1] + fcoord[ll][1])/2;
|
||||
}
|
||||
for (ii = 0; ii < 8; ii++)
|
||||
{
|
||||
f_hole_coord[ii][0] = -hole*0.707;
|
||||
f_hole_coord[ii][1] = hole*0.707;
|
||||
RotatePoint(&f_hole_coord[ii][0], &f_hole_coord[ii][1],
|
||||
angle -(ii * 450) );
|
||||
f_hole_coord[ii][0] += drillx;
|
||||
f_hole_coord[ii][1] += drilly;
|
||||
}
|
||||
|
||||
for ( layer = CUIVRE_N; layer <= CMP_N; layer ++)
|
||||
{
|
||||
if (layer && (layer == nlmax) ) layer = CMP_N;
|
||||
if ( (layer == CMP_N) && ! Oncmp ) continue;
|
||||
if ( (layer == CUIVRE_N) && ! Oncu ) continue;
|
||||
if ( (layer > CUIVRE_N) && (layer < CMP_N) && !Both) continue;
|
||||
color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer];
|
||||
glNormal3f( 0.0, 0.0, (layer == CUIVRE_N) ? -1.0 : 1.0);
|
||||
if ( color & ITEM_NOT_SHOW ) continue;
|
||||
SetGLColor(color);
|
||||
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for ( ii = 0; ii < 8; ii++ )
|
||||
{
|
||||
glVertex3f( f_hole_coord[ii][0], -f_hole_coord[ii][1] , zpos);
|
||||
glVertex3f( fcoord[ii][0], -fcoord[ii][1] , zpos);
|
||||
}
|
||||
glVertex3f( f_hole_coord[0][0], -f_hole_coord[0][1] , zpos);
|
||||
glVertex3f( fcoord[0][0], -fcoord[0][1] , zpos);
|
||||
glEnd();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*************************/
|
||||
void SetGLColor(int color)
|
||||
/*************************/
|
||||
{
|
||||
double red, green,blue;
|
||||
StructColors colordata = ColorRefs[color & MASKCOLOR];
|
||||
|
||||
red = colordata.m_Red / 255.0;
|
||||
blue = colordata.m_Blue / 255.0;
|
||||
green = colordata.m_Green / 255.0;
|
||||
glColor3f(red, green,blue);
|
||||
}
|
||||
|
||||
/********************************************************/
|
||||
static void Draw3D_FilledCircle(double posx, double posy,
|
||||
double rayon, double hole, double zpos)
|
||||
/********************************************************/
|
||||
{
|
||||
int ii, slice = 16;
|
||||
double x, y;
|
||||
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for ( ii = 0; ii <= slice; ii++ )
|
||||
{
|
||||
x = hole; y = 0.0;
|
||||
RotatePoint(&x, &y, ii * 225);
|
||||
glVertex3f( x + posx, y + posy, zpos);
|
||||
x = rayon; y = 0.0;
|
||||
RotatePoint(&x, &y, ii * 225);
|
||||
glVertex3f( x + posx, y + posy, zpos);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
/*********************************************************/
|
||||
static void Draw3D_FilledCylinder(double posx, double posy,
|
||||
double rayon, double height, double zpos)
|
||||
/*********************************************************/
|
||||
{
|
||||
int ii;
|
||||
double x, y;
|
||||
#define NB_SEGM 12
|
||||
S3D_Vertex coords[4];
|
||||
double tmp = DataScale3D;
|
||||
|
||||
DataScale3D = 1.0; //les coord sont deja a l'echelle pour Set_Object_Data();
|
||||
coords[0].x = coords[1].x = posx + rayon;
|
||||
coords[0].y = coords[1].y = posy;
|
||||
coords[0].z = coords[3].z = zpos;
|
||||
coords[1].z = coords[2].z = zpos + height;
|
||||
|
||||
for ( ii = 0; ii <= NB_SEGM; ii++ )
|
||||
{
|
||||
x = rayon; y = 0.0;
|
||||
RotatePoint(&x, &y, ii * (3600/NB_SEGM));
|
||||
coords[2].x = coords[3].x = posx + x;
|
||||
coords[2].y = coords[3].y = posy + y;
|
||||
Set_Object_Data(coords, 4 );
|
||||
coords[0].x = coords[2].x;
|
||||
coords[0].y = coords[2].y;
|
||||
coords[1].x = coords[3].x;
|
||||
coords[1].y = coords[3].y;
|
||||
}
|
||||
glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis
|
||||
DataScale3D = tmp;
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
static void Draw3D_FilledSegment(double startx, double starty,
|
||||
double endx, double endy,double width, double zpos)
|
||||
/*****************************************************************/
|
||||
/* trace un polygone semblable a un segment a bouts ronds
|
||||
*/
|
||||
{
|
||||
double dx, dy, x, y, firstx=0, firsty=0;
|
||||
int ii, angle;
|
||||
|
||||
/* on va calculer les coordonnées du segment supposé horizontal,
|
||||
puis tourner les cordonnes de l'angle voulu */
|
||||
|
||||
dx = endx - startx; dy = endy - starty;
|
||||
angle = (int)(( atan2( dy, dx ) / M_PI * 1800)+0.5) ;
|
||||
|
||||
RotatePoint(&dx, &dy, angle); // apres rotation: dx = longueur du segment
|
||||
// dy = 0;
|
||||
width /= 2;
|
||||
|
||||
glBegin(GL_POLYGON);
|
||||
// tracé de l'arrondi a droite (1er demi polygone a la fin du segment)
|
||||
for ( ii = 0; ii <= 8; ii++ )
|
||||
{
|
||||
x = 0.0; y =-width;
|
||||
RotatePoint(&x, &y, -ii * 225);
|
||||
x += dx;
|
||||
RotatePoint(&x, &y, -angle);
|
||||
glVertex3f( startx + x, starty+y, zpos);
|
||||
if ( ii == 0 )
|
||||
{
|
||||
firstx = startx + x;
|
||||
firsty = starty + y;
|
||||
}
|
||||
}
|
||||
// tracé de l'arrondi a gauche (2ieme demi polygone a l'origine du segment)
|
||||
for ( ii = 0; ii <= 8; ii++ )
|
||||
{
|
||||
int jj = ii * 225;
|
||||
x = 0.0; y = width;
|
||||
RotatePoint(&x, &y, -angle -jj);
|
||||
glVertex3f( startx + x, starty+y, zpos);
|
||||
}
|
||||
|
||||
glVertex3f( firstx, firsty, zpos);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
static void Draw3D_FilledSegmentWithHole(double startx, double starty,
|
||||
double endx, double endy,double width,
|
||||
double holex, double holey, double holeradius, double zpos)
|
||||
/*****************************************************************/
|
||||
/* trace un polygone semblable a un segment a bouts ronds avec trou
|
||||
*/
|
||||
{
|
||||
double x, y, xin, yin;
|
||||
double firstx=0, firsty=0, firstxin=0, firstyin=0;
|
||||
int ii, angle, theta;
|
||||
|
||||
/* on va calculer les coordonnées du segment supposé horizontal,
|
||||
puis tourner les cordonnes de l'angle voulu
|
||||
Tous des calculs se font avec startx, starty comme origine du tracé */
|
||||
|
||||
endx -= startx; endy -= starty;
|
||||
holex -= startx; holey -= starty;
|
||||
angle = (int)(( atan2( endy, endx ) / M_PI * 1800)+0.5) ;
|
||||
|
||||
RotatePoint(&endx, &endy, angle); // apres rotation: endx = longueur du segment
|
||||
// endy = 0;
|
||||
RotatePoint(&holex, &holey, angle);
|
||||
width /= 2;
|
||||
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
// tracé de l'arrondi a droite (1er demi polygone a la fin du segment)
|
||||
// autour du demi-trou de percage
|
||||
for ( ii = 0; ii <= 8; ii++ )
|
||||
{
|
||||
x = 0.0; y = -width;
|
||||
xin = 0.0; yin = - holeradius;
|
||||
theta = -ii * 225;
|
||||
RotatePoint(&x, &y, theta);
|
||||
RotatePoint(&xin, &yin, theta);
|
||||
x += endx;
|
||||
RotatePoint(&x, &y, -angle);
|
||||
xin += holex;
|
||||
RotatePoint(&xin, &yin, -angle);
|
||||
glVertex3f( startx + xin, starty+yin, zpos);
|
||||
glVertex3f( startx + x, starty+y, zpos);
|
||||
if ( ii == 0 ) // Memorisation du point de départ du tracé
|
||||
{
|
||||
firstx = startx + x;
|
||||
firsty = starty + y;
|
||||
firstxin = startx + xin;
|
||||
firstyin = starty + yin;
|
||||
}
|
||||
}
|
||||
// tracé de l'arrondi a gauche (2ieme demi polygone a l'origine du segment)
|
||||
for ( ii = 0; ii <= 8; ii++ )
|
||||
{
|
||||
theta = - ii * 225;
|
||||
x = 0.0; y = width;
|
||||
RotatePoint(&x, &y, -angle + theta);
|
||||
xin = 0.0; yin = holeradius;
|
||||
RotatePoint(&xin, &yin, theta);
|
||||
xin += holex;
|
||||
RotatePoint(&xin, &yin, -angle);
|
||||
glVertex3f( startx + xin,starty + yin, zpos);
|
||||
glVertex3f( startx + x, starty + y, zpos);
|
||||
}
|
||||
|
||||
glVertex3f( firstxin, firstyin, zpos);
|
||||
glVertex3f( firstx, firsty, zpos);
|
||||
glEnd();
|
||||
}
|
||||
|
322
3d-viewer/3d_frame.cpp
Normal file
322
3d-viewer/3d_frame.cpp
Normal file
@ -0,0 +1,322 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: 3d_frame.cpp
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
|
||||
#include "fctsys.h"
|
||||
|
||||
#include <wx/colordlg.h>
|
||||
|
||||
#if !wxUSE_GLCANVAS
|
||||
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
|
||||
#endif
|
||||
|
||||
#include "bitmaps.h"
|
||||
#include "id.h"
|
||||
|
||||
#define VIEWER_MAIN
|
||||
#include "3d_viewer.h"
|
||||
#include "trackball.h"
|
||||
|
||||
|
||||
BEGIN_EVENT_TABLE(WinEDA3D_DrawFrame, wxFrame)
|
||||
EVT_TOOL_RANGE(ID_ZOOM_PLUS_BUTT, ID_ZOOM_PAGE_BUTT,
|
||||
WinEDA3D_DrawFrame::Process_Zoom)
|
||||
EVT_TOOL_RANGE(ID_START_COMMAND_3D, ID_END_COMMAND_3D,
|
||||
WinEDA3D_DrawFrame::Process_Special_Functions)
|
||||
EVT_MENU(wxID_EXIT, WinEDA3D_DrawFrame::Exit3DFrame)
|
||||
EVT_MENU(ID_MENU_SCREENCOPY_PNG, WinEDA3D_DrawFrame::Process_Special_Functions)
|
||||
EVT_MENU(ID_MENU_SCREENCOPY_JPEG, WinEDA3D_DrawFrame::Process_Special_Functions)
|
||||
EVT_CLOSE(WinEDA3D_DrawFrame::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*******************************************************************/
|
||||
WinEDA3D_DrawFrame::WinEDA3D_DrawFrame(WinEDA_BasePcbFrame * parent,
|
||||
WinEDA_App *app_parent, const wxString& title ):
|
||||
wxFrame(parent, DISPLAY3D_FRAME, title,
|
||||
wxPoint(-1,-1), wxSize(-1,-1) )
|
||||
/*******************************************************************/
|
||||
{
|
||||
m_FrameName = wxT("Frame3D");
|
||||
m_Canvas = NULL;
|
||||
m_Parent = parent;
|
||||
m_ParentAppl = app_parent;
|
||||
m_HToolBar = NULL;
|
||||
m_VToolBar = NULL;
|
||||
m_InternalUnits = 10000; // Unites internes = 1/10000 inch
|
||||
|
||||
// Give it an icon
|
||||
SetIcon(wxICON(icon_w3d));
|
||||
|
||||
GetSettings();
|
||||
SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y);
|
||||
// Create the status line
|
||||
int dims[5] = { -1, 100, 100, 100, 140};
|
||||
CreateStatusBar(5);
|
||||
SetStatusWidths(5,dims);
|
||||
ReCreateMenuBar();
|
||||
ReCreateHToolbar();
|
||||
// ReCreateAuxiliaryToolbar();
|
||||
ReCreateVToolbar();
|
||||
|
||||
// Make a Pcb3D_GLCanvas
|
||||
|
||||
m_Canvas = new Pcb3D_GLCanvas(this, -1, gl_attrib );
|
||||
/* init OpenGL once */
|
||||
m_Canvas->InitGL();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************/
|
||||
void WinEDA3D_DrawFrame::Exit3DFrame(wxCommandEvent& event)
|
||||
/***********************************************************/
|
||||
{
|
||||
Close(TRUE);
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
void WinEDA3D_DrawFrame::OnCloseWindow(wxCloseEvent & Event)
|
||||
/***********************************************************/
|
||||
{
|
||||
SaveSettings();
|
||||
if ( m_Parent )
|
||||
{
|
||||
m_Parent->m_Draw3DFrame = NULL;
|
||||
}
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
||||
/******************************************/
|
||||
void WinEDA3D_DrawFrame::GetSettings(void)
|
||||
/******************************************/
|
||||
{
|
||||
wxString text;
|
||||
wxConfig * Config = m_ParentAppl->m_EDA_Config; // Current config used by application
|
||||
|
||||
if( m_ParentAppl->m_EDA_Config )
|
||||
{
|
||||
text = m_FrameName + wxT("Pos_x");
|
||||
Config->Read(text, &m_FramePos.x);
|
||||
text = m_FrameName + wxT("Pos_y");
|
||||
Config->Read(text, &m_FramePos.y);
|
||||
text = m_FrameName + wxT("Size_x");
|
||||
Config->Read(text, &m_FrameSize.x, 600);
|
||||
text = m_FrameName + wxT("Size_y");
|
||||
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_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);
|
||||
}
|
||||
#ifdef __WXMAC__
|
||||
// for macOSX, the window must be below system (macOSX) toolbar
|
||||
if ( m_FramePos.y < GetMBarHeight() ) m_FramePos.y = GetMBarHeight();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************/
|
||||
void WinEDA3D_DrawFrame::SaveSettings(void)
|
||||
/*******************************************/
|
||||
{
|
||||
wxString text;
|
||||
wxConfig * Config = m_ParentAppl->m_EDA_Config; // Current config used by application
|
||||
|
||||
if( ! Config ) return;
|
||||
|
||||
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_Blue"), g_Parm_3D_Visu.m_BgColor.m_Blue);
|
||||
|
||||
if( IsIconized() ) return;
|
||||
|
||||
m_FrameSize = GetSize();
|
||||
m_FramePos = GetPosition();
|
||||
|
||||
text = m_FrameName + wxT("Pos_x");
|
||||
Config->Write(text, (long)m_FramePos.x);
|
||||
text = m_FrameName + wxT("Pos_y");
|
||||
Config->Write(text, (long)m_FramePos.y);
|
||||
text = m_FrameName + wxT("Size_x");
|
||||
Config->Write(text, (long)m_FrameSize.x);
|
||||
text = m_FrameName + wxT("Size_y");
|
||||
Config->Write(text, (long)m_FrameSize.y);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************/
|
||||
void WinEDA3D_DrawFrame::Process_Zoom(wxCommandEvent& event)
|
||||
/***********************************************************/
|
||||
{
|
||||
int ii;
|
||||
switch(event.GetId())
|
||||
{
|
||||
case ID_ZOOM_PAGE_BUTT:
|
||||
for ( ii = 0; ii < 4; ii++ ) g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
||||
g_Parm_3D_Visu.m_Zoom = 1.0;
|
||||
g_Draw3d_dx = g_Draw3d_dy = 0;
|
||||
trackball(g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
||||
break;
|
||||
|
||||
case ID_ZOOM_PLUS_BUTT:
|
||||
g_Parm_3D_Visu.m_Zoom /= 1.2;
|
||||
if ( g_Parm_3D_Visu.m_Zoom <= 0.01)
|
||||
g_Parm_3D_Visu.m_Zoom = 0.01;
|
||||
break;
|
||||
|
||||
case ID_ZOOM_MOINS_BUTT:
|
||||
g_Parm_3D_Visu.m_Zoom *= 1.2;
|
||||
break;
|
||||
|
||||
case ID_ZOOM_REDRAW_BUTT:
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
m_Canvas->DisplayStatus();
|
||||
m_Canvas->Refresh(FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
void WinEDA3D_DrawFrame::OnLeftClick(wxDC * DC, const wxPoint& MousePos)
|
||||
/************************************************************************/
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************/
|
||||
void WinEDA3D_DrawFrame::OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu)
|
||||
/*******************************************************************************/
|
||||
{
|
||||
}
|
||||
|
||||
/************************************/
|
||||
int WinEDA3D_DrawFrame::BestZoom(void)
|
||||
/************************************/
|
||||
// Retourne le meilleur zoom
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
void WinEDA3D_DrawFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg)
|
||||
/*******************************************************************/
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
void WinEDA3D_DrawFrame::Process_Special_Functions(wxCommandEvent& event)
|
||||
/************************************************************************/
|
||||
{
|
||||
#define ROT_ANGLE 10.0
|
||||
|
||||
switch(event.GetId())
|
||||
{
|
||||
case ID_RELOAD3D_BOARD:
|
||||
NewDisplay();
|
||||
break;
|
||||
|
||||
case ID_ROTATE3D_X_POS:
|
||||
g_Parm_3D_Visu.m_ROTX += ROT_ANGLE;
|
||||
break;
|
||||
|
||||
case ID_ROTATE3D_X_NEG:
|
||||
g_Parm_3D_Visu.m_ROTX -= ROT_ANGLE;
|
||||
break;
|
||||
|
||||
case ID_ROTATE3D_Y_POS:
|
||||
g_Parm_3D_Visu.m_ROTY += ROT_ANGLE;
|
||||
break;
|
||||
|
||||
case ID_ROTATE3D_Y_NEG:
|
||||
g_Parm_3D_Visu.m_ROTY -= ROT_ANGLE;
|
||||
break;
|
||||
|
||||
case ID_ROTATE3D_Z_POS:
|
||||
g_Parm_3D_Visu.m_ROTZ += ROT_ANGLE;
|
||||
break;
|
||||
|
||||
case ID_ROTATE3D_Z_NEG:
|
||||
g_Parm_3D_Visu.m_ROTZ -= ROT_ANGLE;
|
||||
break;
|
||||
|
||||
case ID_MOVE3D_LEFT:
|
||||
m_Canvas->SetView3D(WXK_LEFT);
|
||||
return;
|
||||
|
||||
case ID_MOVE3D_RIGHT:
|
||||
m_Canvas->SetView3D(WXK_RIGHT);
|
||||
return;
|
||||
|
||||
case ID_MOVE3D_UP:
|
||||
m_Canvas->SetView3D(WXK_UP);
|
||||
return;
|
||||
|
||||
case ID_MOVE3D_DOWN:
|
||||
m_Canvas->SetView3D(WXK_DOWN);
|
||||
return;
|
||||
|
||||
case ID_TOOL_SCREENCOPY_TOCLIBBOARD:
|
||||
case ID_MENU_SCREENCOPY_PNG:
|
||||
case ID_MENU_SCREENCOPY_JPEG:
|
||||
m_Canvas->TakeScreenshot(event);
|
||||
break;
|
||||
|
||||
case ID_MENU3D_BGCOLOR_SELECTION:
|
||||
Set3DBgColor();
|
||||
return;
|
||||
|
||||
default:
|
||||
wxMessageBox(
|
||||
wxT("WinEDA3D_DrawFrame::Process_Special_Functions() error: unknown command"));
|
||||
return;
|
||||
}
|
||||
m_Canvas->DisplayStatus();
|
||||
m_Canvas->Refresh(FALSE);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************/
|
||||
void WinEDA3D_DrawFrame::NewDisplay(void)
|
||||
/*****************************************/
|
||||
{
|
||||
m_Canvas->ClearLists();
|
||||
m_Canvas->InitGL();
|
||||
m_Canvas->DisplayStatus();
|
||||
m_Canvas->Refresh(FALSE);
|
||||
}
|
||||
|
||||
|
||||
/******************************************/
|
||||
void WinEDA3D_DrawFrame::Set3DBgColor(void)
|
||||
/******************************************/
|
||||
/* called to set the background color of the 3D scene
|
||||
*/
|
||||
{
|
||||
S3D_Color color;
|
||||
wxColour newcolor, oldcolor;
|
||||
|
||||
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_Blue*255));
|
||||
|
||||
newcolor = wxGetColourFromUser(this, oldcolor);
|
||||
if ( newcolor != oldcolor )
|
||||
{
|
||||
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_Blue = (double) newcolor.Blue() / 255.0;
|
||||
NewDisplay();
|
||||
}
|
||||
}
|
518
3d-viewer/3d_read_mesh.cpp
Normal file
518
3d-viewer/3d_read_mesh.cpp
Normal file
@ -0,0 +1,518 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: 3d_read_mesh.cpp
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "fctsys.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "macros.h"
|
||||
|
||||
|
||||
#include "3d_struct.h"
|
||||
#include "3d_viewer.h"
|
||||
|
||||
|
||||
/***********************************/
|
||||
int Struct3D_Master:: ReadData(void)
|
||||
/************************************/
|
||||
{
|
||||
char line[1024], *text;
|
||||
wxString fullfilename;
|
||||
FILE * file;
|
||||
int LineNum = 0;
|
||||
|
||||
if ( m_Shape3DName.IsEmpty() )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( wxIsAbsolutePath(m_Shape3DName) ) fullfilename.Empty();
|
||||
else fullfilename = g_RealLibDirBuffer + LIB3D_PATH;
|
||||
fullfilename += m_Shape3DName;
|
||||
#if defined (__WINDOWS__)
|
||||
fullfilename.Replace(UNIX_STRING_DIR_SEP,WIN_STRING_DIR_SEP);
|
||||
#else
|
||||
#if defined (__UNIX__)
|
||||
fullfilename.Replace(WIN_STRING_DIR_SEP,UNIX_STRING_DIR_SEP);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
file = wxFopen( fullfilename, wxT("rt") );
|
||||
if ( file == NULL )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
while ( GetLine(file, line, &LineNum, 512) )
|
||||
{
|
||||
text = strtok(line, " \t\n\r");
|
||||
if ( stricmp (text, "DEF" ) == 0 )
|
||||
{
|
||||
while ( GetLine(file, line, &LineNum, 512) )
|
||||
{
|
||||
text = strtok(line, " \t\n\r");
|
||||
if ( text == NULL ) continue;
|
||||
if ( * text == '}' ) break;
|
||||
if ( stricmp (text, "children") == 0 )
|
||||
{
|
||||
ReadChildren(file, &LineNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose (file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************/
|
||||
int Struct3D_Master:: ReadMaterial(FILE * file, int *LineNum)
|
||||
/*********************************************************/
|
||||
/*
|
||||
analyse la description du type:
|
||||
material DEF yellow Material {
|
||||
diffuseColor 1.00000 1.00000 0.00000e+0
|
||||
emissiveColor 0.00000e+0 0.00000e+0 0.00000e+0
|
||||
specularColor 1.00000 1.00000 1.00000
|
||||
ambientIntensity 1.00000
|
||||
transparency 0.00000e+0
|
||||
shininess 1.00000
|
||||
}
|
||||
ou du type:
|
||||
material USE yellow
|
||||
*/
|
||||
{
|
||||
char line[512], * text, * command;
|
||||
wxString mat_name;
|
||||
S3D_Material * material = NULL;
|
||||
|
||||
// Lecture de la commande:
|
||||
command = strtok(NULL, " \t\n\r");
|
||||
text = strtok(NULL, " \t\n\r");
|
||||
mat_name = CONV_FROM_UTF8(text);
|
||||
if ( stricmp(command, "USE") == 0 )
|
||||
{
|
||||
|
||||
for ( material = m_Materials; material != NULL;
|
||||
material = (S3D_Material *) material->Pnext)
|
||||
{
|
||||
if ( material->m_Name == mat_name)
|
||||
{
|
||||
material->SetMaterial();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
printf("ReadMaterial error: material not found\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( stricmp(command, "DEF") == 0 )
|
||||
{
|
||||
material = new S3D_Material(this, mat_name);
|
||||
material->Pnext = m_Materials;
|
||||
m_Materials = material;
|
||||
while ( GetLine(file, line, LineNum, 512) )
|
||||
{
|
||||
text = strtok(line," \t\n\r");
|
||||
if ( text == NULL ) continue;
|
||||
if ( text[0] == '}' )
|
||||
{
|
||||
material->SetMaterial();
|
||||
return 0;
|
||||
}
|
||||
if ( stricmp (text, "diffuseColor") == 0 )
|
||||
{
|
||||
text = strtok(NULL," \t\n\r");
|
||||
material->m_DiffuseColor.x = atof(from_point(text));
|
||||
text = strtok(NULL," \t\n\r");
|
||||
material->m_DiffuseColor.y = atof(from_point(text));
|
||||
text = strtok(NULL," \t\n\r");
|
||||
material->m_DiffuseColor.z = atof(from_point(text));
|
||||
}
|
||||
else if ( stricmp (text, "emissiveColor") == 0 )
|
||||
{
|
||||
text = strtok(NULL," \t\n\r");
|
||||
material->m_EmissiveColor.x = atof(from_point(text));
|
||||
text = strtok(NULL," \t\n\r");
|
||||
material->m_EmissiveColor.y = atof(from_point(text));
|
||||
text = strtok(NULL," \t\n\r");
|
||||
material->m_EmissiveColor.z = atof(from_point(text));
|
||||
}
|
||||
else if ( strnicmp (text, "specularColor", 13 ) == 0 )
|
||||
{
|
||||
text = strtok(NULL," \t\n\r");
|
||||
material->m_SpecularColor.x = atof(from_point(text));
|
||||
text = strtok(NULL," \t\n\r");
|
||||
material->m_SpecularColor.y = atof(from_point(text));
|
||||
text = strtok(NULL," \t\n\r");
|
||||
material->m_SpecularColor.z = atof(from_point(text));
|
||||
}
|
||||
else if ( strnicmp (text, "ambientIntensity", 16 ) == 0 )
|
||||
{
|
||||
text = strtok(NULL," \t\n\r");
|
||||
material->m_AmbientIntensity = atof(from_point(text));
|
||||
}
|
||||
else if ( strnicmp (text, "transparency", 12 ) == 0 )
|
||||
{
|
||||
text = strtok(NULL," \t\n\r");
|
||||
material->m_Transparency = atof(from_point(text));
|
||||
}
|
||||
else if ( strnicmp (text, "shininess", 9 ) == 0 )
|
||||
{
|
||||
text = strtok(NULL," \t\n\r");
|
||||
material->m_Shininess = atof(from_point(text));
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************/
|
||||
int Struct3D_Master::ReadChildren(FILE * file, int *LineNum)
|
||||
/***********************************************************/
|
||||
{
|
||||
char line[1024], *text;
|
||||
|
||||
while ( GetLine(file, line, LineNum, 512) )
|
||||
{
|
||||
text = strtok(line, " \t\n\r");
|
||||
if ( * text == ']' ) return 0;
|
||||
if ( * text == ',' ) continue;
|
||||
|
||||
if ( stricmp (text, "Shape" ) == 0 )
|
||||
{
|
||||
ReadShape(file, LineNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("ReadChildren error line %d <%s> \n", *LineNum, text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/********************************************************/
|
||||
int Struct3D_Master::ReadShape(FILE * file, int *LineNum)
|
||||
/********************************************************/
|
||||
{
|
||||
char line[1024], *text;
|
||||
int err = 1;
|
||||
|
||||
while ( GetLine(file, line, LineNum, 512) )
|
||||
{
|
||||
text = strtok(line, " \t\n\r");
|
||||
if ( * text == '}' )
|
||||
{
|
||||
err = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( stricmp (text, "appearance" ) == 0 )
|
||||
{
|
||||
ReadAppearance(file, LineNum);
|
||||
}
|
||||
else if ( stricmp (text, "geometry" ) == 0 )
|
||||
{
|
||||
ReadGeometry(file, LineNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("ReadShape error line %d <%s> \n", *LineNum, text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
int Struct3D_Master::ReadAppearance(FILE * file, int *LineNum)
|
||||
/*************************************************************/
|
||||
{
|
||||
char line[1024], *text;
|
||||
int err = 1;
|
||||
|
||||
while ( GetLine(file, line, LineNum, 512) )
|
||||
{
|
||||
text = strtok(line, " \t\n\r");
|
||||
if ( * text == '}' )
|
||||
{
|
||||
err = 0; break;
|
||||
}
|
||||
|
||||
if ( stricmp (text, "material" ) == 0 )
|
||||
{
|
||||
ReadMaterial(file, LineNum );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("ReadAppearance error line %d <%s> \n", *LineNum, text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
#define BUFSIZE 2000
|
||||
|
||||
/************************************************************************************/
|
||||
double * ReadCoordsList(FILE * file, char * text_buffer, int * bufsize, int *LineNum)
|
||||
/************************************************************************************/
|
||||
/* Read a coordinate liste like:
|
||||
coord Coordinate { point [
|
||||
-5.24489 6.57640e-3 -9.42129e-2,
|
||||
-5.11821 6.57421e-3 0.542654,
|
||||
-3.45868 0.256565 1.32000 ] }
|
||||
or:
|
||||
normal Normal { vector [
|
||||
0.995171 -6.08102e-6 9.81541e-2,
|
||||
0.923880 -4.09802e-6 0.382683,
|
||||
0.707107 -9.38186e-7 0.707107]
|
||||
}
|
||||
|
||||
Return the coordinate list
|
||||
text_buffer contains the first line of this node :
|
||||
"coord Coordinate { point ["
|
||||
*/
|
||||
{
|
||||
double * data_list = NULL;
|
||||
unsigned int ii = 0, jj = 0, nn = BUFSIZE;
|
||||
char * text;
|
||||
bool HasData = FALSE;
|
||||
bool StartData = FALSE;
|
||||
bool EndData = FALSE;
|
||||
bool EndNode = FALSE;
|
||||
char string_num[512];
|
||||
|
||||
text = text_buffer;
|
||||
while ( !EndNode )
|
||||
{
|
||||
if ( * text == 0 ) // Needs data !
|
||||
{
|
||||
text = text_buffer;
|
||||
GetLine(file, text_buffer, LineNum, 512);
|
||||
}
|
||||
|
||||
while ( !EndNode && *text )
|
||||
{
|
||||
switch ( *text )
|
||||
{
|
||||
case '[':
|
||||
StartData = TRUE;
|
||||
jj = 0; string_num[jj] = 0;
|
||||
data_list = (double *) MyZMalloc(nn * sizeof(double) );
|
||||
break;
|
||||
|
||||
case '}':
|
||||
EndNode = TRUE;
|
||||
break;
|
||||
|
||||
case ']':
|
||||
case '\t':
|
||||
case ' ':
|
||||
case ',':
|
||||
jj = 0;
|
||||
if ( ! StartData || !HasData) break;
|
||||
data_list[ii] = atof(from_point(string_num));
|
||||
string_num[jj] = 0;
|
||||
ii++;
|
||||
if ( ii >= nn )
|
||||
{
|
||||
nn *= 2;
|
||||
data_list = (double *) realloc(data_list, (nn * sizeof(double)) );
|
||||
}
|
||||
HasData = FALSE;
|
||||
if ( *text == ']' )
|
||||
{
|
||||
StartData = FALSE;
|
||||
EndData = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if ( ! StartData ) break;
|
||||
if ( jj >= sizeof(string_num) ) break;
|
||||
string_num[jj] = *text;
|
||||
jj++; string_num[jj] = 0;
|
||||
HasData = TRUE;
|
||||
break;
|
||||
}
|
||||
text++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( data_list )
|
||||
data_list = (double *) realloc(data_list, (ii * sizeof(double)) );
|
||||
if ( bufsize ) *bufsize = ii;
|
||||
return data_list;
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
int Struct3D_Master::ReadGeometry(FILE * file, int *LineNum)
|
||||
/***********************************************************/
|
||||
{
|
||||
char line[1024], buffer[1024], *text;
|
||||
int err = 1;
|
||||
int nn = BUFSIZE;
|
||||
double * points = NULL;
|
||||
int * index = NULL;
|
||||
|
||||
while ( GetLine(file, line, LineNum, 512) )
|
||||
{
|
||||
strcpy(buffer,line);
|
||||
text = strtok(buffer, " \t\n\r");
|
||||
if ( * text == '}' )
|
||||
{
|
||||
err = 0; break;
|
||||
}
|
||||
|
||||
if ( stricmp (text, "normalPerVertex" ) == 0 )
|
||||
{
|
||||
text = strtok(NULL, " ,\t\n\r");
|
||||
if( stricmp (text, "TRUE") == 0 )
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( stricmp (text, "colorPerVertex" ) == 0 )
|
||||
{
|
||||
text = strtok(NULL, " ,\t\n\r");
|
||||
if( stricmp (text, "TRUE") == 0 )
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( stricmp (text, "normal" ) == 0 )
|
||||
{
|
||||
int coord_number;
|
||||
double * buf_points = ReadCoordsList(file, line, &coord_number, LineNum);
|
||||
continue;
|
||||
free(buf_points);
|
||||
continue;
|
||||
}
|
||||
if ( stricmp (text, "normalIndex" ) == 0 )
|
||||
{
|
||||
while ( GetLine(file, line, LineNum, 512) )
|
||||
{
|
||||
text = strtok(line, " ,\t\n\r");
|
||||
while ( text )
|
||||
{
|
||||
if ( *text == ']') break;
|
||||
text = strtok(NULL, " ,\t\n\r");
|
||||
}
|
||||
if ( text && (*text == ']') ) break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( stricmp (text, "color" ) == 0 )
|
||||
{
|
||||
int coord_number;
|
||||
double * buf_points = ReadCoordsList(file, line, &coord_number, LineNum);
|
||||
continue;
|
||||
free(buf_points);
|
||||
continue;
|
||||
}
|
||||
if ( stricmp (text, "colorIndex" ) == 0 )
|
||||
{
|
||||
while ( GetLine(file, line, LineNum, 512) )
|
||||
{
|
||||
text = strtok(line, " ,\t\n\r");
|
||||
while ( text )
|
||||
{
|
||||
if ( *text == ']') break;
|
||||
text = strtok(NULL, " ,\t\n\r");
|
||||
}
|
||||
if ( text && (*text == ']') ) break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( stricmp (text, "coord" ) == 0 )
|
||||
{
|
||||
int coord_number;
|
||||
points = ReadCoordsList(file, line, &coord_number, LineNum);
|
||||
}
|
||||
else if ( stricmp (text, "coordIndex" ) == 0 )
|
||||
{
|
||||
index = (int *) MyMalloc(nn * sizeof(int) );
|
||||
S3D_Vertex * coords =
|
||||
(S3D_Vertex *) MyMalloc(nn * sizeof(S3D_Vertex) );
|
||||
while ( GetLine(file, line, LineNum, 512) )
|
||||
{
|
||||
int coord_count = 0, jj;
|
||||
text = strtok(line, " ,\t\n\r");
|
||||
while ( text )
|
||||
{
|
||||
if ( *text == ']') break;
|
||||
jj = atoi(from_point(text));
|
||||
if ( jj < 0 )
|
||||
{
|
||||
S3D_Vertex * curr_coord = coords;
|
||||
for ( jj = 0; jj < coord_count; jj ++ )
|
||||
{
|
||||
int kk = index[jj] * 3;
|
||||
curr_coord->x = points[kk];
|
||||
curr_coord->y = points[kk+1];
|
||||
curr_coord->z = points[kk+2];
|
||||
curr_coord++;
|
||||
}
|
||||
Set_Object_Coords(coords, coord_count );
|
||||
Set_Object_Data(coords, coord_count );
|
||||
coord_count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
index[coord_count++] = jj;
|
||||
}
|
||||
text = strtok(NULL, " ,\t\n\r");
|
||||
}
|
||||
if ( text && (*text == ']') ) break;
|
||||
}
|
||||
free(index);
|
||||
free(coords);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("ReadGeometry error line %d <%s> \n", *LineNum, text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( points ) free (points);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*********************************************************/
|
||||
int Struct3D_Shape:: ReadData(FILE * file, int *LineNum)
|
||||
/*********************************************************/
|
||||
{
|
||||
char line[512];
|
||||
|
||||
while ( GetLine(file, line, LineNum, 512) )
|
||||
{
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
136
3d-viewer/3d_struct.h
Normal file
136
3d-viewer/3d_struct.h
Normal file
@ -0,0 +1,136 @@
|
||||
/********************************************************/
|
||||
/* 3d_struct.h : definition des structures de donnees */
|
||||
/* pour la representation 3D des modules */
|
||||
/********************************************************/
|
||||
|
||||
#ifndef STRUCT_3D_H
|
||||
#define STRUCT_3D_H
|
||||
|
||||
#include "base_struct.h"
|
||||
|
||||
/* 3D modeler units -> PCB units conversion scale:
|
||||
1 "3D unit modeler" = 1 unit wings3d = 2,54 mm = 0.1 inch */
|
||||
#define UNITS3D_TO_UNITSPCB 1000
|
||||
|
||||
|
||||
class Struct3D_Master;
|
||||
class Struct3D_Shape;
|
||||
|
||||
class S3D_Color /* This is a 3D color (R, G, G) 3 floats range 0 to 1.0*/
|
||||
{
|
||||
public:
|
||||
double m_Red, m_Green, m_Blue;
|
||||
public:
|
||||
S3D_Color(void)
|
||||
{
|
||||
m_Red = m_Green = m_Blue = 0;
|
||||
}
|
||||
};
|
||||
|
||||
class S3D_Vertex /* This is a 3D coordinate (3 float numbers: x,y,z coordinates)*/
|
||||
{
|
||||
public:
|
||||
double x, y, z;
|
||||
public:
|
||||
S3D_Vertex(void);
|
||||
};
|
||||
|
||||
class S3D_Material: public EDA_BaseStruct /* openGL "material" data*/
|
||||
{
|
||||
public:
|
||||
wxString m_Name;
|
||||
S3D_Vertex m_DiffuseColor;
|
||||
S3D_Vertex m_EmissiveColor;
|
||||
S3D_Vertex m_SpecularColor;
|
||||
float m_AmbientIntensity;
|
||||
float m_Transparency;
|
||||
float m_Shininess;
|
||||
|
||||
public:
|
||||
S3D_Material(Struct3D_Master * father, const wxString & name);
|
||||
void SetMaterial(void);
|
||||
};
|
||||
|
||||
/*******************************************/
|
||||
class Struct3D_Master: public EDA_BaseStruct
|
||||
/*******************************************/
|
||||
/* Master structure for a 3D item description */
|
||||
{
|
||||
public:
|
||||
wxString m_Shape3DName; /* 3D shape name in 3D library */
|
||||
S3D_Vertex m_MatScale;
|
||||
S3D_Vertex m_MatRotation;
|
||||
S3D_Vertex m_MatPosition;
|
||||
Struct3D_Shape * m_3D_Drawings;
|
||||
S3D_Material *m_Materials;
|
||||
|
||||
public:
|
||||
|
||||
Struct3D_Master(EDA_BaseStruct * StructFather);
|
||||
~Struct3D_Master(void);
|
||||
|
||||
void Copy(Struct3D_Master * pattern);
|
||||
int ReadData(void);
|
||||
int ReadMaterial(FILE * file, int *LineNum);
|
||||
int ReadChildren(FILE * file, int *LineNum);
|
||||
int ReadShape(FILE * file, int *LineNum);
|
||||
int ReadAppearance(FILE * file, int *LineNum);
|
||||
int ReadGeometry(FILE * file, int *LineNum);
|
||||
void Set_Object_Coords(S3D_Vertex * coord, int nbcoord );
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*********************************************/
|
||||
class Struct3D_Shape: public EDA_BaseStruct
|
||||
/*********************************************/
|
||||
/* decrit une forme complexe 3D */
|
||||
{
|
||||
public:
|
||||
S3D_Vertex * m_3D_Coord;
|
||||
int * m_3D_CoordIndex;
|
||||
int m_3D_Points;
|
||||
|
||||
public:
|
||||
|
||||
Struct3D_Shape(EDA_BaseStruct * StructFather);
|
||||
~Struct3D_Shape(void);
|
||||
|
||||
int ReadData(FILE * file, int *LineNum);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
/* Classe pour afficher et editer un Vertex (triplet de valeurs),*/
|
||||
/* en INCHES ou MM ou sans unites */
|
||||
/*****************************************************************/
|
||||
/* internal_unit is the internal unit number by inch:
|
||||
- 1000 for EESchema
|
||||
- 10000 for PcbNew
|
||||
*/
|
||||
class WinEDA_VertexCtrl
|
||||
{
|
||||
private:
|
||||
int m_Units;
|
||||
int m_Internal_Unit;
|
||||
wxTextCtrl * m_XValueCtrl, * m_YValueCtrl, * m_ZValueCtrl;
|
||||
wxStaticText * m_Text;
|
||||
|
||||
public:
|
||||
// Constructor and destructor
|
||||
WinEDA_VertexCtrl(wxWindow *parent, const wxString & title,
|
||||
wxBoxSizer * BoxSizer,
|
||||
int units, int internal_unit);
|
||||
|
||||
~WinEDA_VertexCtrl(void);
|
||||
|
||||
S3D_Vertex GetValue(void);
|
||||
void SetValue(S3D_Vertex vertex);
|
||||
void Enable(bool enbl);
|
||||
void SetToolTip(const wxString & text);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* STRUCT_3D_H */
|
129
3d-viewer/3d_toolbar.cpp
Normal file
129
3d-viewer/3d_toolbar.cpp
Normal file
@ -0,0 +1,129 @@
|
||||
/*******************************************************************/
|
||||
/* 3d_toolbar.cpp: construction des tool bars de la frame visu 3d */
|
||||
/*******************************************************************/
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "macros.h"
|
||||
|
||||
#include "bitmaps3d.h"
|
||||
#include "bitmaps.h"
|
||||
|
||||
#include "id.h"
|
||||
|
||||
#define BITMAP wxBitmap
|
||||
#include "3d_viewer.h"
|
||||
|
||||
|
||||
/*********************************************/
|
||||
void WinEDA3D_DrawFrame::ReCreateHToolbar(void)
|
||||
/*********************************************/
|
||||
{
|
||||
|
||||
if ( m_HToolBar != NULL )
|
||||
{ // simple mise a jour de la liste des fichiers anciens
|
||||
SetToolbars();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE);
|
||||
SetToolBar(m_HToolBar);
|
||||
|
||||
// Set up toolbar
|
||||
m_HToolBar->AddTool(ID_RELOAD3D_BOARD, wxEmptyString, BITMAP(import3d_xpm),
|
||||
_("Reload board"));
|
||||
#ifdef __WINDOWS__ // do not work properly under linux
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool(ID_TOOL_SCREENCOPY_TOCLIBBOARD, wxEmptyString, BITMAP(copy_button),
|
||||
_("Copy 3D Image to Clipboard"));
|
||||
#endif
|
||||
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool(ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP(zoom_in_xpm),
|
||||
_("zoom + (F1)"));
|
||||
|
||||
m_HToolBar->AddTool(ID_ZOOM_MOINS_BUTT, wxEmptyString, BITMAP(zoom_out_xpm),
|
||||
_("zoom - (F2)"));
|
||||
|
||||
m_HToolBar->AddTool(ID_ZOOM_REDRAW_BUTT, wxEmptyString, BITMAP(repaint_xpm),
|
||||
_("redraw (F3)"));
|
||||
|
||||
m_HToolBar->AddTool(ID_ZOOM_PAGE_BUTT, wxEmptyString, BITMAP(zoom_optimal_xpm),
|
||||
_("auto zoom"));
|
||||
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool(ID_ROTATE3D_X_POS, wxEmptyString, BITMAP(rotate_pos_X_xpm),
|
||||
_("Rotate X ->") );
|
||||
|
||||
m_HToolBar->AddTool(ID_ROTATE3D_X_NEG, wxEmptyString, BITMAP(rotate_neg_X_xpm),
|
||||
_("Rotate X <-") );
|
||||
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool(ID_ROTATE3D_Y_POS, wxEmptyString, BITMAP(rotate_pos_Y_xpm),
|
||||
_("Rotate Y ->") );
|
||||
m_HToolBar->AddTool(ID_ROTATE3D_Y_NEG, wxEmptyString, BITMAP(rotate_neg_Y_xpm),
|
||||
_("Rotate Y <-") );
|
||||
|
||||
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool(ID_ROTATE3D_Z_POS, wxEmptyString, BITMAP(rotate_pos_Z_xpm),
|
||||
_("Rotate Z ->") );
|
||||
|
||||
m_HToolBar->AddTool(ID_ROTATE3D_Z_NEG, wxEmptyString, BITMAP(rotate_neg_Z_xpm),
|
||||
_("Rotate Z <-") );
|
||||
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool(ID_MOVE3D_LEFT, wxEmptyString, BITMAP(left_xpm),
|
||||
_("Move left <-") );
|
||||
|
||||
m_HToolBar->AddTool(ID_MOVE3D_RIGHT, wxEmptyString, BITMAP(right_xpm),
|
||||
_("Move right ->") );
|
||||
|
||||
m_HToolBar->AddTool(ID_MOVE3D_UP, wxEmptyString, BITMAP(up_xpm),
|
||||
_("Move Up ^") );
|
||||
|
||||
m_HToolBar->AddTool(ID_MOVE3D_DOWN, wxEmptyString, BITMAP(down_xpm),
|
||||
_("Move Down") );
|
||||
|
||||
|
||||
m_HToolBar->Realize();
|
||||
|
||||
// SetToolbars();
|
||||
}
|
||||
|
||||
/*********************************************/
|
||||
void WinEDA3D_DrawFrame::ReCreateVToolbar(void)
|
||||
/*********************************************/
|
||||
{
|
||||
}
|
||||
|
||||
/**********************************************/
|
||||
void WinEDA3D_DrawFrame::ReCreateMenuBar(void)
|
||||
/**********************************************/
|
||||
{
|
||||
wxMenuBar *menuBar = new wxMenuBar;
|
||||
|
||||
wxMenu *fileMenu = new wxMenu;
|
||||
menuBar->Append(fileMenu, _("&File") );
|
||||
|
||||
fileMenu->Append(ID_MENU_SCREENCOPY_PNG, _("Create Image (png format)"));
|
||||
fileMenu->Append(ID_MENU_SCREENCOPY_JPEG, _("Create Image (jpeg format)"));
|
||||
fileMenu->AppendSeparator();
|
||||
fileMenu->Append(wxID_EXIT, _("&Exit"));
|
||||
|
||||
wxMenu *referencesMenu = new wxMenu;
|
||||
menuBar->Append(referencesMenu, _("&Preferences") );
|
||||
|
||||
ADD_MENUITEM(referencesMenu, ID_MENU3D_BGCOLOR_SELECTION,
|
||||
_("Choose background color"), palette_xpm)
|
||||
|
||||
|
||||
SetMenuBar(menuBar);
|
||||
}
|
||||
|
||||
/*****************************************/
|
||||
void WinEDA3D_DrawFrame::SetToolbars(void)
|
||||
/*****************************************/
|
||||
{
|
||||
}
|
||||
|
172
3d-viewer/3d_viewer.h
Normal file
172
3d-viewer/3d_viewer.h
Normal file
@ -0,0 +1,172 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: 3d_viewer.h
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#if !wxUSE_GLCANVAS
|
||||
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
|
||||
#endif
|
||||
|
||||
#include "wx/glcanvas.h"
|
||||
|
||||
#ifdef __WXMAC__
|
||||
# ifdef __DARWIN__
|
||||
# include <OpenGL/gl.h>
|
||||
# include <OpenGL/glu.h>
|
||||
# else
|
||||
# include <gl.h>
|
||||
# include <glu.h>
|
||||
# endif
|
||||
#else
|
||||
# include <GL/gl.h>
|
||||
# include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
#ifdef VIEWER_MAIN
|
||||
#define global_3d
|
||||
#else
|
||||
#define global_3d extern
|
||||
#endif
|
||||
|
||||
#include "pcbstruct.h"
|
||||
#include "3d_struct.h"
|
||||
|
||||
#define LIB3D_PATH wxT("packages3d/")
|
||||
|
||||
class Pcb3D_GLCanvas;
|
||||
class WinEDA3D_DrawFrame;
|
||||
class Info_3D_Visu;
|
||||
class S3D_Vertex;
|
||||
class SEGVIA;
|
||||
|
||||
|
||||
#define m_ROTX m_Rot[0]
|
||||
#define m_ROTY m_Rot[1]
|
||||
#define m_ROTZ m_Rot[2]
|
||||
|
||||
/* information needed to display 3D board */
|
||||
class Info_3D_Visu
|
||||
{
|
||||
public:
|
||||
float m_Beginx, m_Beginy; /* position of mouse */
|
||||
float m_Quat[4]; /* orientation of object */
|
||||
float m_Rot[4]; /* man rotation of object */
|
||||
float m_Zoom; /* field of view in degrees */
|
||||
S3D_Color m_BgColor;
|
||||
wxPoint m_BoardPos;
|
||||
wxSize m_BoardSize;
|
||||
int m_Layers;
|
||||
EDA_BoardDesignSettings * m_BoardSettings; // Link to current board design settings
|
||||
float m_Epoxy_Width; /* Epoxy tickness (normalized) */
|
||||
|
||||
float m_BoardScale; /* Normalisation scale for coordinates:
|
||||
when scaled tey are between -1.0 and +1.0 */
|
||||
float m_LayerZcoord[32];
|
||||
public:
|
||||
Info_3D_Visu(void);
|
||||
~Info_3D_Visu(void);
|
||||
};
|
||||
|
||||
|
||||
class Pcb3D_GLCanvas: public wxGLCanvas
|
||||
{
|
||||
public:
|
||||
WinEDA3D_DrawFrame * m_Parent;
|
||||
|
||||
private:
|
||||
bool m_init;
|
||||
GLuint m_gllist;
|
||||
|
||||
public:
|
||||
Pcb3D_GLCanvas(WinEDA3D_DrawFrame *parent, const wxWindowID id = -1,
|
||||
int* gl_attrib = NULL);
|
||||
~Pcb3D_GLCanvas(void);
|
||||
|
||||
void ClearLists(void);
|
||||
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnSize(wxSizeEvent& event);
|
||||
void OnEraseBackground(wxEraseEvent& event);
|
||||
void OnChar(wxKeyEvent& event);
|
||||
void OnMouseEvent(wxMouseEvent& event);
|
||||
void OnRightClick(wxMouseEvent& event);
|
||||
void OnPopUpMenu(wxCommandEvent & event);
|
||||
void TakeScreenshot(wxCommandEvent & event);
|
||||
void SetView3D(int keycode);
|
||||
void DisplayStatus(void);
|
||||
void Redraw(void);
|
||||
GLuint DisplayCubeforTest(void);
|
||||
|
||||
void OnEnterWindow( wxMouseEvent& event );
|
||||
|
||||
void Render( void );
|
||||
GLuint CreateDrawGL_List(void);
|
||||
void InitGL(void);
|
||||
void SetLights(void);
|
||||
void Draw3D_Track(TRACK * track);
|
||||
void Draw3D_Via(SEGVIA * via);
|
||||
void Draw3D_DrawSegment(DRAWSEGMENT * segment);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
class WinEDA3D_DrawFrame: public wxFrame
|
||||
{
|
||||
public:
|
||||
WinEDA_BasePcbFrame * m_Parent;
|
||||
WinEDA_App * m_ParentAppl;
|
||||
Pcb3D_GLCanvas * m_Canvas;
|
||||
wxToolBar * m_HToolBar;
|
||||
wxToolBar * m_VToolBar;
|
||||
int m_InternalUnits;
|
||||
wxPoint m_FramePos;
|
||||
wxSize m_FrameSize;
|
||||
|
||||
private:
|
||||
wxString m_FrameName; // name used for writting and reading setup
|
||||
// It is "Frame3D"
|
||||
|
||||
|
||||
public:
|
||||
WinEDA3D_DrawFrame(WinEDA_BasePcbFrame * parent, WinEDA_App *app_parent,
|
||||
const wxString& title );
|
||||
|
||||
void Exit3DFrame(wxCommandEvent& event);
|
||||
void OnCloseWindow(wxCloseEvent & Event);
|
||||
void ReCreateMenuBar(void);
|
||||
void ReCreateHToolbar(void);
|
||||
void ReCreateVToolbar(void);
|
||||
void SetToolbars(void);
|
||||
void GetSettings(void);
|
||||
void SaveSettings(void);
|
||||
|
||||
void OnLeftClick(wxDC * DC, const wxPoint& MousePos);
|
||||
void OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu);
|
||||
void OnKeyEvent(wxKeyEvent& event);
|
||||
int BestZoom(void); // Retourne le meilleur zoom
|
||||
void RedrawActiveWindow(wxDC * DC, bool EraseBg);
|
||||
void Process_Special_Functions(wxCommandEvent& event);
|
||||
void Process_Zoom(wxCommandEvent& event);
|
||||
|
||||
void NewDisplay(void);
|
||||
void Set3DBgColor(void);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
void SetGLColor(int color);
|
||||
void Set_Object_Data(const S3D_Vertex * coord, int nbcoord );
|
||||
|
||||
global_3d Info_3D_Visu g_Parm_3D_Visu;
|
||||
global_3d double g_Draw3d_dx, g_Draw3d_dy;
|
||||
global_3d double ZBottom, ZTop;
|
||||
global_3d double DataScale3D; // coeff de conversion unites utilsateut -> unites 3D
|
||||
global_3d int gl_attrib[]
|
||||
#ifdef VIEWER_MAIN
|
||||
= { WX_GL_RGBA, WX_GL_MIN_RED, 8, WX_GL_MIN_GREEN, 8,
|
||||
WX_GL_MIN_BLUE, 8, WX_GL_DEPTH_SIZE, 16,
|
||||
WX_GL_DOUBLEBUFFER,
|
||||
GL_NONE }
|
||||
#endif
|
||||
;
|
||||
|
||||
|
15
3d-viewer/bitmaps3d.h
Normal file
15
3d-viewer/bitmaps3d.h
Normal file
@ -0,0 +1,15 @@
|
||||
#include "bitmaps3d/import3d.xpm"
|
||||
|
||||
#include "bitmaps3d/rotate+x.xpm"
|
||||
#include "bitmaps3d/rotate-x.xpm"
|
||||
#include "bitmaps3d/rotate+y.xpm"
|
||||
#include "bitmaps3d/rotate-y.xpm"
|
||||
#include "bitmaps3d/rotate+z.xpm"
|
||||
#include "bitmaps3d/rotate-z.xpm"
|
||||
#include "bitmaps3d/axis3d.xpm"
|
||||
#include "bitmaps3d/axis3d_bottom.xpm"
|
||||
#include "bitmaps3d/axis3d_top.xpm"
|
||||
#include "bitmaps3d/axis3d_left.xpm"
|
||||
#include "bitmaps3d/axis3d_right.xpm"
|
||||
#include "bitmaps3d/axis3d_front.xpm"
|
||||
#include "bitmaps3d/axis3d_back.xpm"
|
27
3d-viewer/bitmaps3d/axis3d.xpm
Normal file
27
3d-viewer/bitmaps3d/axis3d.xpm
Normal file
@ -0,0 +1,27 @@
|
||||
/* XPM bitmap */
|
||||
#ifndef XPM_3D_MAIN
|
||||
extern char * axis3d_xpm[];
|
||||
|
||||
#else
|
||||
char * axis3d_xpm[] = {
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Blue",
|
||||
"x c Red",
|
||||
" . ",
|
||||
" ... ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . . ",
|
||||
" ............",
|
||||
" . . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" .. ",
|
||||
" . ",
|
||||
" "
|
||||
};
|
||||
#endif
|
27
3d-viewer/bitmaps3d/axis3d_back.xpm
Normal file
27
3d-viewer/bitmaps3d/axis3d_back.xpm
Normal file
@ -0,0 +1,27 @@
|
||||
/* XPM bitmap */
|
||||
#ifndef XPM_3D_MAIN
|
||||
extern char * axis3d_back_xpm[];
|
||||
|
||||
#else
|
||||
char * axis3d_back_xpm[] = {
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Blue",
|
||||
"x c Red",
|
||||
" . x ",
|
||||
" ... x ",
|
||||
" . x ",
|
||||
" . xxxxx ",
|
||||
" . xxx ",
|
||||
" . x ",
|
||||
" . . ",
|
||||
" ............",
|
||||
" . . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" .. ",
|
||||
" . ",
|
||||
" "
|
||||
};
|
||||
#endif
|
27
3d-viewer/bitmaps3d/axis3d_bottom.xpm
Normal file
27
3d-viewer/bitmaps3d/axis3d_bottom.xpm
Normal file
@ -0,0 +1,27 @@
|
||||
/* XPM bitmap */
|
||||
#ifndef XPM_3D_MAIN
|
||||
extern char * axis3d_bottom_xpm[];
|
||||
|
||||
#else
|
||||
char * axis3d_bottom_xpm[] = {
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Blue",
|
||||
"x c Red",
|
||||
" . ",
|
||||
" ... ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . . ",
|
||||
" ............",
|
||||
" . . ",
|
||||
" . x ",
|
||||
" . xxx ",
|
||||
" . xxxxx ",
|
||||
" .. x ",
|
||||
" . x ",
|
||||
" x "
|
||||
};
|
||||
#endif
|
27
3d-viewer/bitmaps3d/axis3d_front.xpm
Normal file
27
3d-viewer/bitmaps3d/axis3d_front.xpm
Normal file
@ -0,0 +1,27 @@
|
||||
/* XPM bitmap */
|
||||
#ifndef XPM_3D_MAIN
|
||||
extern char * axis3d_front_xpm[];
|
||||
|
||||
#else
|
||||
char * axis3d_front_xpm[] = {
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Blue",
|
||||
"x c Red",
|
||||
" . ",
|
||||
" ... ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . . ",
|
||||
" ............",
|
||||
" . x . ",
|
||||
" . xxx ",
|
||||
" . xxxxx ",
|
||||
" . x ",
|
||||
" .. x ",
|
||||
" . x ",
|
||||
" "
|
||||
};
|
||||
#endif
|
27
3d-viewer/bitmaps3d/axis3d_left.xpm
Normal file
27
3d-viewer/bitmaps3d/axis3d_left.xpm
Normal file
@ -0,0 +1,27 @@
|
||||
/* XPM bitmap */
|
||||
#ifndef XPM_3D_MAIN
|
||||
extern char * axis3d_left_xpm[];
|
||||
|
||||
#else
|
||||
char * axis3d_left_xpm[] = {
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Blue",
|
||||
"x c Red",
|
||||
" . ",
|
||||
" ... ",
|
||||
" . ",
|
||||
" . ",
|
||||
" x. ",
|
||||
" xx ",
|
||||
"xxxxxx . ",
|
||||
" xx...........",
|
||||
" x . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" .. ",
|
||||
" . ",
|
||||
" "
|
||||
};
|
||||
#endif
|
27
3d-viewer/bitmaps3d/axis3d_right.xpm
Normal file
27
3d-viewer/bitmaps3d/axis3d_right.xpm
Normal file
@ -0,0 +1,27 @@
|
||||
/* XPM bitmap */
|
||||
#ifndef XPM_3D_MAIN
|
||||
extern char * axis3d_right_xpm[];
|
||||
|
||||
#else
|
||||
char * axis3d_right_xpm[] = {
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Blue",
|
||||
"x c Red",
|
||||
" . ",
|
||||
" ... ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . x ",
|
||||
" . xx ",
|
||||
" . xxxxxx",
|
||||
" .......xx...",
|
||||
" . x . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" .. ",
|
||||
" . ",
|
||||
" "
|
||||
};
|
||||
#endif
|
27
3d-viewer/bitmaps3d/axis3d_top.xpm
Normal file
27
3d-viewer/bitmaps3d/axis3d_top.xpm
Normal file
@ -0,0 +1,27 @@
|
||||
/* XPM bitmap */
|
||||
#ifndef XPM_3D_MAIN
|
||||
extern char * axis3d_top_xpm[];
|
||||
|
||||
#else
|
||||
char * axis3d_top_xpm[] = {
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Blue",
|
||||
"x c Red",
|
||||
" . x ",
|
||||
" ... x ",
|
||||
" . x ",
|
||||
" . xxxxx ",
|
||||
" . xxx ",
|
||||
" . x ",
|
||||
" . . ",
|
||||
" ............",
|
||||
" . . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" .. ",
|
||||
" . ",
|
||||
" "
|
||||
};
|
||||
#endif
|
48
3d-viewer/bitmaps3d/import3d.xpm
Normal file
48
3d-viewer/bitmaps3d/import3d.xpm
Normal file
@ -0,0 +1,48 @@
|
||||
/* XPM bitmap */
|
||||
#ifndef XPM_3D_MAIN
|
||||
extern char *import3d_xpm[];
|
||||
|
||||
#else
|
||||
char *import3d_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 3 1",
|
||||
"- c Black",
|
||||
"X c None",
|
||||
"o c Green",
|
||||
|
||||
/* pixels */
|
||||
"XXXXXXXXXXXXXXXX",
|
||||
"----------------",
|
||||
"-oooooooooooooo-",
|
||||
"X-oooooooooooo-X",
|
||||
"X-oooooooooooo-X",
|
||||
"XX-oooooooooo-XX",
|
||||
"XX-oooooooooo-XX",
|
||||
"----oooooooo----",
|
||||
"X-oooooooooooo-X",
|
||||
"XX-oooooooooo-XX",
|
||||
"XXX-oooooooo-XXX",
|
||||
"XXXX-oooooo-XXXX",
|
||||
"XXXXX-oooo-XXXXX",
|
||||
"XXXXXX-oo-XXXXXX",
|
||||
"XXXXXXX--XXXXXXX"
|
||||
|
||||
"XXXXXXXXXXXXXXXX",
|
||||
"XXXXXXXXXXXXXXXX",
|
||||
"XXXXXXXXXXXXXXXX",
|
||||
"XXXXXXXXXXXXXXXX",
|
||||
"XXXXXXXXXXXXXXXX",
|
||||
"XXXXXXXXXXXXXXXX",
|
||||
"XXXXXXXXXXXXXXXX",
|
||||
"XXXXXXXXXXXXXXXX",
|
||||
"XXXXXXXXXXXXXXXX",
|
||||
"XXXXXXXXXXXXXXXX",
|
||||
"XXXXXXXXXXXXXXXX",
|
||||
"XXXXXXXXXXXXXXXX",
|
||||
"XXXXXXXXXXXXXXXX",
|
||||
"XXXXXXXXXXXXXXXX",
|
||||
"XXXXXXXXXXXXXXXX"
|
||||
|
||||
};
|
||||
#endif
|
||||
|
32
3d-viewer/bitmaps3d/rotate+x.xpm
Normal file
32
3d-viewer/bitmaps3d/rotate+x.xpm
Normal file
@ -0,0 +1,32 @@
|
||||
/* XPM */
|
||||
#ifndef XPM_3D_MAIN
|
||||
extern char *rotate_pos_X_xpm[];
|
||||
|
||||
#else
|
||||
char *rotate_pos_X_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 16 15 4 1",
|
||||
/* colors */
|
||||
". c #000080",
|
||||
"# c #c0c0c0",
|
||||
"a c #808080",
|
||||
"o c #008000",
|
||||
/* pixels */
|
||||
"##oo###oo#######",
|
||||
"###oo#oo########",
|
||||
"####ooo#########",
|
||||
"###oo#oo########",
|
||||
"##oo###oo...a###",
|
||||
"##.###...###.a##",
|
||||
"##..#.#######.##",
|
||||
"##...########.##",
|
||||
"##....#######.##",
|
||||
"##.....#####.a##",
|
||||
"###########a.###",
|
||||
"################",
|
||||
"################",
|
||||
"################",
|
||||
"################"
|
||||
};
|
||||
|
||||
#endif
|
32
3d-viewer/bitmaps3d/rotate+y.xpm
Normal file
32
3d-viewer/bitmaps3d/rotate+y.xpm
Normal file
@ -0,0 +1,32 @@
|
||||
/* XPM */
|
||||
#ifndef XPM_3D_MAIN
|
||||
extern char *rotate_pos_Y_xpm[];
|
||||
|
||||
#else
|
||||
char *rotate_pos_Y_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 16 15 4 1",
|
||||
/* colors */
|
||||
". c #000080",
|
||||
"# c #c0c0c0",
|
||||
"a c #808080",
|
||||
"o c #FF0000",
|
||||
/* pixels */
|
||||
"##oo###oo#######",
|
||||
"###oo#oo########",
|
||||
"####ooo#########",
|
||||
"####oo##########",
|
||||
"o##oo...########",
|
||||
"#oo.####..###.##",
|
||||
"##.#######.#..##",
|
||||
"##.########...##",
|
||||
"##.#######....##",
|
||||
"##a.#####.....##",
|
||||
"###.a###########",
|
||||
"################",
|
||||
"################",
|
||||
"################",
|
||||
"################"
|
||||
};
|
||||
#endif
|
||||
|
32
3d-viewer/bitmaps3d/rotate+z.xpm
Normal file
32
3d-viewer/bitmaps3d/rotate+z.xpm
Normal file
@ -0,0 +1,32 @@
|
||||
/* XPM */
|
||||
#ifndef XPM_3D_MAIN
|
||||
extern char *rotate_pos_Z_xpm[];
|
||||
|
||||
#else
|
||||
char *rotate_pos_Z_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 16 15 4 1",
|
||||
/* colors */
|
||||
". c #000080",
|
||||
"# c #c0c0c0",
|
||||
"a c #808080",
|
||||
"o c #008000",
|
||||
/* pixels */
|
||||
"###oooooo#######",
|
||||
"######oo########",
|
||||
"#####oo#########",
|
||||
"####oo##########",
|
||||
"###oooooo...a###",
|
||||
"##.###..####.a##",
|
||||
"##..#.#######.##",
|
||||
"##...########.##",
|
||||
"##....#######.##",
|
||||
"##.....#####.a##",
|
||||
"###########a.###",
|
||||
"################",
|
||||
"################",
|
||||
"################",
|
||||
"################"
|
||||
};
|
||||
|
||||
#endif
|
32
3d-viewer/bitmaps3d/rotate-x.xpm
Normal file
32
3d-viewer/bitmaps3d/rotate-x.xpm
Normal file
@ -0,0 +1,32 @@
|
||||
/* XPM */
|
||||
#ifndef XPM_3D_MAIN
|
||||
extern char *rotate_neg_X_xpm[];
|
||||
|
||||
#else
|
||||
char *rotate_neg_X_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 16 15 4 1",
|
||||
/* colors */
|
||||
". c #000080",
|
||||
"# c #c0c0c0",
|
||||
"a c #808080",
|
||||
"o c #004000",
|
||||
/* pixels */
|
||||
"##oo###oo#######",
|
||||
"###oo#oo########",
|
||||
"####ooo#########",
|
||||
"###oo#oo########",
|
||||
"##oo...oo#######",
|
||||
"##a.####..###.##",
|
||||
"##.#######.#..##",
|
||||
"##.########...##",
|
||||
"##.#######....##",
|
||||
"##a.#####.....##",
|
||||
"###.a###########",
|
||||
"################",
|
||||
"################",
|
||||
"################",
|
||||
"################"
|
||||
};
|
||||
#endif
|
||||
|
32
3d-viewer/bitmaps3d/rotate-y.xpm
Normal file
32
3d-viewer/bitmaps3d/rotate-y.xpm
Normal file
@ -0,0 +1,32 @@
|
||||
/* XPM */
|
||||
#ifndef XPM_3D_MAIN
|
||||
extern char *rotate_neg_Y_xpm[];
|
||||
|
||||
#else
|
||||
char *rotate_neg_Y_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 16 15 4 1",
|
||||
/* colors */
|
||||
". c #000080",
|
||||
"# c #c0c0c0",
|
||||
"a c #808080",
|
||||
"o c #FF0000",
|
||||
/* pixels */
|
||||
"##oo###oo#######",
|
||||
"###oo#oo########",
|
||||
"####ooo#########",
|
||||
"####oo##########",
|
||||
"o##oo###....a###",
|
||||
"#oo###..####.a##",
|
||||
"##..#.#######.##",
|
||||
"##...########.##",
|
||||
"##....#######.##",
|
||||
"##.....#####.a##",
|
||||
"###########a.###",
|
||||
"################",
|
||||
"################",
|
||||
"################",
|
||||
"################"
|
||||
};
|
||||
|
||||
#endif
|
32
3d-viewer/bitmaps3d/rotate-z.xpm
Normal file
32
3d-viewer/bitmaps3d/rotate-z.xpm
Normal file
@ -0,0 +1,32 @@
|
||||
/* XPM */
|
||||
#ifndef XPM_3D_MAIN
|
||||
extern char *rotate_neg_Z_xpm[];
|
||||
|
||||
#else
|
||||
char *rotate_neg_Z_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 16 15 4 1",
|
||||
/* colors */
|
||||
". c #000080",
|
||||
"# c #c0c0c0",
|
||||
"a c #808080",
|
||||
"o c #008000",
|
||||
/* pixels */
|
||||
"###oooooo#######",
|
||||
"######oo########",
|
||||
"#####oo#########",
|
||||
"####oo##########",
|
||||
"###oooooo#######",
|
||||
"##a.####..###.##",
|
||||
"##.#######.#..##",
|
||||
"##.########...##",
|
||||
"##.#######....##",
|
||||
"##a.#####.....##",
|
||||
"###.a###########",
|
||||
"################",
|
||||
"################",
|
||||
"################",
|
||||
"################"
|
||||
};
|
||||
#endif
|
||||
|
28
3d-viewer/bitmaps3d/zoomoins3d.xpm
Normal file
28
3d-viewer/bitmaps3d/zoomoins3d.xpm
Normal file
@ -0,0 +1,28 @@
|
||||
/* XPM bitmap */
|
||||
#ifndef XPMMAIN
|
||||
extern char * zoomoins3d_xpm[];
|
||||
|
||||
#else
|
||||
char * zoomoins3d_xpm[] = {
|
||||
"16 16 3 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c Gray100",
|
||||
" .... ",
|
||||
" ..XXXX.. ",
|
||||
" .XXXXXXXX. ",
|
||||
" .XXXXXXXX. ",
|
||||
".XXXXXXXXXX. ",
|
||||
".XX......XX. ",
|
||||
".XX......XX. ",
|
||||
".XXXXXXXXXX. ",
|
||||
" .XXXXXXXX. ",
|
||||
" .XXXXXXXX. ",
|
||||
" ..XXXX... ",
|
||||
" .... ... ",
|
||||
" ... ",
|
||||
" ... ",
|
||||
" ... ",
|
||||
" .. "
|
||||
};
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user