Loading 3d-viewer/3d_aux.cpp +20 −20 Original line number Diff line number Diff line Loading @@ -26,16 +26,17 @@ void S3D_MASTER::Set_Object_Coords( S3D_Vertex* coord, int nbcoord ) 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) ); 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) ); 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) ); 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; Loading Loading @@ -68,6 +69,7 @@ void Set_Object_Data( const S3D_Vertex* coord, int nbcoord ) 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; Loading Loading @@ -102,7 +104,7 @@ void Set_Object_Data( const S3D_Vertex* coord, int nbcoord ) } GLuint Pcb3D_GLCanvas::DisplayCubeforTest() GLuint EDA_3D_CANVAS::DisplayCubeforTest() { GLuint gllist = glGenLists( 1 ); Loading Loading @@ -151,18 +153,19 @@ Info_3D_Visu::Info_3D_Visu() 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; m_Draw3DAxis = TRUE; m_Draw3DModule = TRUE; m_Draw3DZone = TRUE; m_Draw3DComments = TRUE; m_Draw3DDrawings = TRUE; m_Draw3DEco1 = TRUE; m_Draw3DEco2 = TRUE; m_Draw3DAxis = true; m_Draw3DModule = true; m_Draw3DZone = true; m_Draw3DComments = true; m_Draw3DDrawings = true; m_Draw3DEco1 = true; m_Draw3DEco2 = true; } Loading @@ -187,15 +190,12 @@ WinEDA_VertexCtrl::WinEDA_VertexCtrl( wxWindow* parent, const wxString& title, text = _( "Vertex " ); else text = title; text += ReturnUnitSymbol( units ); msgtitle = new wxStaticText( parent, -1, text, wxDefaultPosition, wxSize( -1, -1 ), 0 ); msgtitle = new wxStaticText( parent, -1, text, wxDefaultPosition, wxSize( -1, -1 ), 0 ); BoxSizer->Add( msgtitle, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM | wxADJUST_MINSIZE ); BoxSizer->Add( msgtitle, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM | wxADJUST_MINSIZE ); wxFlexGridSizer* GridSizer = new wxFlexGridSizer( 3, 2, 0, 0 ); Loading 3d-viewer/3d_canvas.cpp +25 −25 Original line number Diff line number Diff line Loading @@ -50,27 +50,27 @@ void CheckGLError() /* * Pcb3D_GLCanvas implementation * EDA_3D_CANVAS implementation */ BEGIN_EVENT_TABLE( Pcb3D_GLCanvas, wxGLCanvas ) EVT_PAINT( Pcb3D_GLCanvas::OnPaint ) BEGIN_EVENT_TABLE( EDA_3D_CANVAS, wxGLCanvas ) EVT_PAINT( EDA_3D_CANVAS::OnPaint ) // key event: EVT_CHAR( Pcb3D_GLCanvas::OnChar ) EVT_CHAR( EDA_3D_CANVAS::OnChar ) // mouse events EVT_RIGHT_DOWN( Pcb3D_GLCanvas::OnRightClick ) EVT_MOUSEWHEEL( Pcb3D_GLCanvas::OnMouseWheel ) EVT_MOTION( Pcb3D_GLCanvas::OnMouseMove ) EVT_RIGHT_DOWN( EDA_3D_CANVAS::OnRightClick ) EVT_MOUSEWHEEL( EDA_3D_CANVAS::OnMouseWheel ) EVT_MOTION( EDA_3D_CANVAS::OnMouseMove ) // other events EVT_ERASE_BACKGROUND( Pcb3D_GLCanvas::OnEraseBackground ) EVT_MENU_RANGE( ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END, Pcb3D_GLCanvas::OnPopUpMenu ) EVT_ERASE_BACKGROUND( EDA_3D_CANVAS::OnEraseBackground ) EVT_MENU_RANGE( ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END, EDA_3D_CANVAS::OnPopUpMenu ) END_EVENT_TABLE() Pcb3D_GLCanvas::Pcb3D_GLCanvas( EDA_3D_FRAME* parent, int* attribList ) : EDA_3D_CANVAS::EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList ) : #if wxCHECK_VERSION( 2, 7, 0 ) wxGLCanvas( parent, -1, attribList, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE ) Loading @@ -94,7 +94,7 @@ Pcb3D_GLCanvas::Pcb3D_GLCanvas( EDA_3D_FRAME* parent, int* attribList ) : } Pcb3D_GLCanvas::~Pcb3D_GLCanvas() EDA_3D_CANVAS::~EDA_3D_CANVAS() { ClearLists(); m_init = false; Loading @@ -105,7 +105,7 @@ Pcb3D_GLCanvas::~Pcb3D_GLCanvas() } void Pcb3D_GLCanvas::ClearLists() void EDA_3D_CANVAS::ClearLists() { if( m_gllist > 0 ) glDeleteLists( m_gllist, 1 ); Loading @@ -114,14 +114,14 @@ void Pcb3D_GLCanvas::ClearLists() } void Pcb3D_GLCanvas::OnChar( wxKeyEvent& event ) void EDA_3D_CANVAS::OnChar( wxKeyEvent& event ) { SetView3D( event.GetKeyCode() ); event.Skip(); } void Pcb3D_GLCanvas::SetView3D( int keycode ) void EDA_3D_CANVAS::SetView3D( int keycode ) { int ii; double delta_move = 0.7 * g_Parm_3D_Visu.m_Zoom; Loading Loading @@ -237,7 +237,7 @@ void Pcb3D_GLCanvas::SetView3D( int keycode ) } void Pcb3D_GLCanvas::OnMouseWheel( wxMouseEvent& event ) void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent& event ) { wxSize size( GetClientSize() ); Loading Loading @@ -288,7 +288,7 @@ void Pcb3D_GLCanvas::OnMouseWheel( wxMouseEvent& event ) } void Pcb3D_GLCanvas::OnMouseMove( wxMouseEvent& event ) void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event ) { wxSize size( GetClientSize() ); double spin_quat[4]; Loading Loading @@ -331,7 +331,7 @@ void Pcb3D_GLCanvas::OnMouseMove( wxMouseEvent& event ) /* Construct and display a popup menu when the right button is clicked. */ void Pcb3D_GLCanvas::OnRightClick( wxMouseEvent& event ) void EDA_3D_CANVAS::OnRightClick( wxMouseEvent& event ) { wxPoint pos; wxMenu PopUpMenu; Loading Loading @@ -406,7 +406,7 @@ void Pcb3D_GLCanvas::OnRightClick( wxMouseEvent& event ) } void Pcb3D_GLCanvas::OnPopUpMenu( wxCommandEvent& event ) void EDA_3D_CANVAS::OnPopUpMenu( wxCommandEvent& event ) { int key = 0; Loading Loading @@ -468,7 +468,7 @@ void Pcb3D_GLCanvas::OnPopUpMenu( wxCommandEvent& event ) } void Pcb3D_GLCanvas::DisplayStatus() void EDA_3D_CANVAS::DisplayStatus() { wxString msg; Loading @@ -483,7 +483,7 @@ void Pcb3D_GLCanvas::DisplayStatus() } void Pcb3D_GLCanvas::OnPaint( wxPaintEvent& event ) void EDA_3D_CANVAS::OnPaint( wxPaintEvent& event ) { wxPaintDC dc( this ); Loading @@ -492,14 +492,14 @@ void Pcb3D_GLCanvas::OnPaint( wxPaintEvent& event ) } void Pcb3D_GLCanvas::OnEraseBackground( wxEraseEvent& event ) void EDA_3D_CANVAS::OnEraseBackground( wxEraseEvent& event ) { // Do nothing, to avoid flashing. } /* Initialize broad parameters for OpenGL */ void Pcb3D_GLCanvas::InitGL() void EDA_3D_CANVAS::InitGL() { wxSize size = GetClientSize(); Loading Loading @@ -568,7 +568,7 @@ void Pcb3D_GLCanvas::InitGL() g_Parm_3D_Visu.m_BgColor.m_Blue, 1 ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // Setup light souces: // Setup light sources: SetLights(); CheckGLError(); Loading @@ -576,7 +576,7 @@ void Pcb3D_GLCanvas::InitGL() /* Initialize OpenGL light sources. */ void Pcb3D_GLCanvas::SetLights() void EDA_3D_CANVAS::SetLights() { double light; GLfloat light_color[4]; Loading Loading @@ -604,7 +604,7 @@ void Pcb3D_GLCanvas::SetLights() /* Create a Screenshot of the current 3D view. * Output file format is png or jpeg, or image is copied to the clipboard */ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event ) void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event ) { wxFileName fn( m_Parent->m_Parent->GetScreen()->GetFileName() ); wxString FullFileName; Loading 3d-viewer/3d_draw.cpp +28 −23 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ static void CALLBACK tessErrorCB( GLenum errorCode ); static void CALLBACK tessCPolyPt2Vertex( const GLvoid* data ); static void CALLBACK tesswxPoint2Vertex( const GLvoid* data ); void Pcb3D_GLCanvas::Redraw( bool finish ) void EDA_3D_CANVAS::Redraw( bool finish ) { /* SwapBuffer requires the window to be shown before calling */ if( !IsShown() ) Loading Loading @@ -110,7 +110,7 @@ void Pcb3D_GLCanvas::Redraw( bool finish ) /* Create the draw list items */ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() GLuint EDA_3D_CANVAS::CreateDrawGL_List() { PCB_BASE_FRAME* pcbframe = m_Parent->m_Parent; BOARD* pcb = pcbframe->GetBoard(); Loading Loading @@ -219,8 +219,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() glEnd(); #endif /* move the board in order to draw it with its center at 0,0 3D * coordinates */ /* move the board in order to draw it with its center at 0,0 3D coordinates */ 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 ); Loading Loading @@ -248,6 +247,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() for( ii = 0; ii < pcb->GetAreaCount(); ii++ ) { ZONE_CONTAINER* curr_zone = pcb->GetArea( ii ); if( curr_zone->m_FillMode == 0 ) { // solid polygons only are used to fill areas Loading Loading @@ -295,6 +295,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() for( int ic = 1; ic <= imax; ic++ ) { CPolyPt* endcorner = &zone->m_FilledPolysList[ic]; if( begincorner->utility == 0 ) { // Draw only basic outlines, not extra segments Loading @@ -304,6 +305,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() dummysegment.m_End.y = endcorner->y; Draw3D_Track( &dummysegment ); } if( (endcorner->end_contour) || (ic == imax) ) { // the last corner of a filled area is found: draw it Loading Loading @@ -368,7 +370,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() } void Pcb3D_GLCanvas::Draw3D_Track( TRACK* track ) void EDA_3D_CANVAS::Draw3D_Track( TRACK* track ) { double zpos; int layer = track->GetLayer(); Loading Loading @@ -402,7 +404,7 @@ void Pcb3D_GLCanvas::Draw3D_Track( TRACK* track ) * draw all solid polygons used as filles areas in a zone * @param aZone = the zone to draw */ void Pcb3D_GLCanvas::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone ) void EDA_3D_CANVAS::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone ) { double zpos; int layer = aZone->GetLayer(); Loading Loading @@ -435,6 +437,7 @@ void Pcb3D_GLCanvas::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone ) // Draw solid areas contained in this zone int StartContour = 1; for( unsigned ii = 0; ii < aZone->m_FilledPolysList.size(); ii++ ) { if( StartContour == 1 ) Loading @@ -443,6 +446,7 @@ void Pcb3D_GLCanvas::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone ) gluTessBeginContour( tess ); StartContour = 0; } v_data[0] = aZone->m_FilledPolysList[ii].x * g_Parm_3D_Visu.m_BoardScale; v_data[1] = -aZone->m_FilledPolysList[ii].y * g_Parm_3D_Visu.m_BoardScale; gluTessVertex( tess, v_data, &aZone->m_FilledPolysList[ii] ); Loading @@ -461,7 +465,7 @@ void Pcb3D_GLCanvas::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone ) /* 3D drawing for a VIA (cylinder + filled circles) */ void Pcb3D_GLCanvas::Draw3D_Via( SEGVIA* via ) void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via ) { double x, y, r, hole; int layer, top_layer, bottom_layer; Loading @@ -480,6 +484,7 @@ void Pcb3D_GLCanvas::Draw3D_Via( SEGVIA* via ) 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 ) { if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false ) Loading Loading @@ -519,7 +524,7 @@ void Pcb3D_GLCanvas::Draw3D_Via( SEGVIA* via ) } void Pcb3D_GLCanvas::Draw3D_DrawSegment( DRAWSEGMENT* segment ) void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment ) { double x, y, xf, yf; double zpos, w; Loading Loading @@ -608,7 +613,7 @@ static void Draw3dTextSegm( int x0, int y0, int xf, int yf ) } void Pcb3D_GLCanvas::Draw3D_DrawText( TEXTE_PCB* text ) void EDA_3D_CANVAS::Draw3D_DrawText( TEXTE_PCB* text ) { int layer = text->GetLayer(); Loading Loading @@ -661,7 +666,7 @@ void Pcb3D_GLCanvas::Draw3D_DrawText( TEXTE_PCB* text ) } void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) void MODULE::Draw3D( EDA_3D_CANVAS* glcanvas ) { D_PAD* pad = m_Pads; Loading @@ -676,7 +681,7 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) /* Draw module shape: 3D shape if exists (or module outlines if not exists) */ S3D_MASTER* Struct3D = m_3D_Drawings; bool As3dShape = FALSE; bool As3dShape = false; if( g_Parm_3D_Visu.m_Draw3DModule ) { Loading @@ -703,7 +708,7 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) { if( !Struct3D->m_Shape3DName.IsEmpty() ) { As3dShape = TRUE; As3dShape = true; Struct3D->ReadData(); } } Loading Loading @@ -739,7 +744,7 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) } void EDGE_MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas ) { wxString s; int dx, dy; Loading Loading @@ -862,7 +867,7 @@ void EDGE_MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) /* Draw 3D pads. */ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) { int ii, ll, layer, nlmax; int ux0, uy0, Loading Loading @@ -907,8 +912,8 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis nlmax = g_Parm_3D_Visu.m_Layers - 1; Oncu = (m_layerMask & LAYER_BACK) ? TRUE : FALSE; Oncmp = (m_layerMask & LAYER_FRONT) ? TRUE : FALSE; Oncu = (m_layerMask & LAYER_BACK) ? true : false; Oncmp = (m_layerMask & LAYER_FRONT) ? true : false; Both = Oncu && Oncmp; switch( m_PadShape & 0x7F ) Loading Loading @@ -1364,10 +1369,10 @@ static void Draw3D_CircleSegment( double startx, double starty, double endx, /** * Function Draw3D_Polygon * draw one solid polygon * @param aCornersList = a std::vector<wxPoint> liste of corners, in physical coordinates * @param aCornersList = a std::vector<wxPoint> list of corners, in physical coordinates * @param aZpos = the z position in 3D units */ void Pcb3D_GLCanvas::Draw3D_Polygon( std::vector<wxPoint>& aCornersList, double aZpos ) void EDA_3D_CANVAS::Draw3D_Polygon( std::vector<wxPoint>& aCornersList, double aZpos ) { g_Parm_3D_Visu.m_ActZpos = aZpos; Loading Loading @@ -1407,19 +1412,19 @@ static int Get3DLayerEnable( int act_layer ) { bool enablelayer; enablelayer = TRUE; enablelayer = true; if( act_layer == DRAW_N && !g_Parm_3D_Visu.m_Draw3DDrawings ) enablelayer = FALSE; enablelayer = false; if( act_layer == COMMENT_N && !g_Parm_3D_Visu.m_Draw3DComments ) enablelayer = FALSE; enablelayer = false; if( act_layer == ECO1_N && !g_Parm_3D_Visu.m_Draw3DEco1 ) enablelayer = FALSE; enablelayer = false; if( act_layer == ECO2_N && !g_Parm_3D_Visu.m_Draw3DEco2 ) enablelayer = FALSE; enablelayer = false; return enablelayer; } Loading 3d-viewer/3d_frame.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -66,9 +66,9 @@ EDA_3D_FRAME::EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title, long // ReCreateAuxiliaryToolbar(); ReCreateVToolbar(); // Make a Pcb3D_GLCanvas // Make a EDA_3D_CANVAS int attrs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0 }; m_Canvas = new Pcb3D_GLCanvas( this, attrs ); m_Canvas = new EDA_3D_CANVAS( this, attrs ); m_auimgr.SetManagedWindow( this ); Loading 3d-viewer/3d_read_mesh.cpp +58 −22 Original line number Diff line number Diff line Loading @@ -24,9 +24,10 @@ int S3D_MASTER::ReadData() return 1; } if( wxFileName::FileExists( m_Shape3DName ) ) { FullFilename = m_Shape3DName; } else { fn = m_Shape3DName; Loading @@ -50,18 +51,23 @@ int S3D_MASTER::ReadData() // Switch the locale to standard C (needed to print floating point // numbers like 1.3) SetLocaleTo_C_standard(); 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 ); Loading Loading @@ -98,6 +104,7 @@ int S3D_MASTER:: ReadMaterial( FILE* file, int* LineNum ) command = strtok( NULL, " \t\n\r" ); text = strtok( NULL, " \t\n\r" ); mat_name = FROM_UTF8( text ); if( stricmp( command, "USE" ) == 0 ) { for( material = m_Materials; material; material = material->Next() ) Loading @@ -122,13 +129,16 @@ int S3D_MASTER:: ReadMaterial( FILE* file, int* LineNum ) 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" ); Loading Loading @@ -173,6 +183,7 @@ int S3D_MASTER:: ReadMaterial( FILE* file, int* LineNum ) } } } return -1; } Loading @@ -184,8 +195,10 @@ int S3D_MASTER::ReadChildren( FILE* file, int* LineNum ) while( GetLine( file, line, LineNum, 512 ) ) { text = strtok( line, " \t\n\r" ); if( *text == ']' ) return 0; if( *text == ',' ) continue; Loading @@ -212,6 +225,7 @@ int S3D_MASTER::ReadShape( FILE* file, int* LineNum ) while( GetLine( file, line, LineNum, 512 ) ) { text = strtok( line, " \t\n\r" ); if( *text == '}' ) { err = 0; Loading Loading @@ -245,6 +259,7 @@ int S3D_MASTER::ReadAppearance( FILE* file, int* LineNum ) while( GetLine( file, line, LineNum, 512 ) ) { text = strtok( line, " \t\n\r" ); if( *text == '}' ) { err = 0; break; Loading Loading @@ -283,18 +298,18 @@ int S3D_MASTER::ReadAppearance( FILE* file, int* LineNum ) * text_buffer contains the first line of this node : * "coord Coordinate { point [" */ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, int* LineNum ) double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, int* LineNum ) { double* data_list = NULL; unsigned int ii = 0, jj = 0, nn = BUFSIZE; char* text; bool HasData = FALSE; bool StartData = FALSE; bool EndNode = FALSE; bool HasData = false; bool StartData = false; bool EndNode = false; char string_num[512]; text = text_buffer; while( !EndNode ) { if( *text == 0 ) // Needs data ! Loading @@ -308,13 +323,13 @@ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, switch( *text ) { case '[': StartData = TRUE; StartData = true; jj = 0; string_num[jj] = 0; data_list = (double*) MyZMalloc( nn * sizeof(double) ); break; case '}': EndNode = TRUE; EndNode = true; break; case ']': Loading @@ -322,32 +337,38 @@ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, case ' ': case ',': jj = 0; if( !StartData || !HasData ) break; data_list[ii] = atof( string_num ); string_num[jj] = 0; ii++; if( ii >= nn ) { nn *= 2; data_list = (double*) realloc( data_list, ( nn * sizeof(double) ) ); data_list = (double*) realloc( data_list, ( nn * sizeof(double) ) ); } HasData = FALSE; HasData = false; if( *text == ']' ) { StartData = FALSE; StartData = false; } break; default: if( !StartData ) break; if( jj >= sizeof(string_num) ) break; string_num[jj] = *text; jj++; string_num[jj] = 0; HasData = TRUE; HasData = true; break; } Loading @@ -357,8 +378,10 @@ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, if( data_list ) data_list = (double*) realloc( data_list, ( ii * sizeof(double) ) ); if( bufsize ) *bufsize = ii; return data_list; } Loading @@ -375,6 +398,7 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) { strcpy( buffer, line ); text = strtok( buffer, " \t\n\r" ); if( *text == '}' ) { err = 0; break; Loading @@ -383,7 +407,8 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) if( stricmp( text, "normalPerVertex" ) == 0 ) { text = strtok( NULL, " ,\t\n\r" ); if( stricmp( text, "TRUE" ) == 0 ) if( stricmp( text, "true" ) == 0 ) { } else Loading @@ -395,7 +420,8 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) if( stricmp( text, "colorPerVertex" ) == 0 ) { text = strtok( NULL, " ,\t\n\r" ); if( stricmp( text, "TRUE" ) == 0 ) if( stricmp( text, "true" ) == 0 ) { } else Loading @@ -407,8 +433,8 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) if( stricmp( text, "normal" ) == 0 ) { int coord_number; double* buf_points = ReadCoordsList( file, line, &coord_number, LineNum ); double* buf_points = ReadCoordsList( file, line, &coord_number, LineNum ); // Do something if needed free( buf_points ); continue; Loading @@ -418,10 +444,12 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) while( GetLine( file, line, LineNum, 512 ) ) { text = strtok( line, " ,\t\n\r" ); while( text ) { if( *text == ']' ) break; text = strtok( NULL, " ,\t\n\r" ); } Loading @@ -435,21 +463,24 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) if( stricmp( text, "color" ) == 0 ) { int coord_number; double* buf_points = ReadCoordsList( file, line, &coord_number, LineNum ); double* buf_points = ReadCoordsList( file, line, &coord_number, LineNum ); // Do something if needed 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" ); } Loading @@ -468,20 +499,24 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) else if( stricmp( text, "coordIndex" ) == 0 ) { index = (int*) MyMalloc( nn * sizeof(int) ); S3D_Vertex* coords = (S3D_Vertex*) MyMalloc( nn * sizeof(S3D_Vertex) ); 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( text ); if( jj < 0 ) { S3D_Vertex* curr_coord = coords; for( jj = 0; jj < coord_count; jj++ ) { int kk = index[jj] * 3; Loading @@ -499,6 +534,7 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) { index[coord_count++] = jj; } text = strtok( NULL, " ,\t\n\r" ); } Loading Loading
3d-viewer/3d_aux.cpp +20 −20 Original line number Diff line number Diff line Loading @@ -26,16 +26,17 @@ void S3D_MASTER::Set_Object_Coords( S3D_Vertex* coord, int nbcoord ) 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) ); 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) ); 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) ); 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; Loading Loading @@ -68,6 +69,7 @@ void Set_Object_Data( const S3D_Vertex* coord, int nbcoord ) 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; Loading Loading @@ -102,7 +104,7 @@ void Set_Object_Data( const S3D_Vertex* coord, int nbcoord ) } GLuint Pcb3D_GLCanvas::DisplayCubeforTest() GLuint EDA_3D_CANVAS::DisplayCubeforTest() { GLuint gllist = glGenLists( 1 ); Loading Loading @@ -151,18 +153,19 @@ Info_3D_Visu::Info_3D_Visu() 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; m_Draw3DAxis = TRUE; m_Draw3DModule = TRUE; m_Draw3DZone = TRUE; m_Draw3DComments = TRUE; m_Draw3DDrawings = TRUE; m_Draw3DEco1 = TRUE; m_Draw3DEco2 = TRUE; m_Draw3DAxis = true; m_Draw3DModule = true; m_Draw3DZone = true; m_Draw3DComments = true; m_Draw3DDrawings = true; m_Draw3DEco1 = true; m_Draw3DEco2 = true; } Loading @@ -187,15 +190,12 @@ WinEDA_VertexCtrl::WinEDA_VertexCtrl( wxWindow* parent, const wxString& title, text = _( "Vertex " ); else text = title; text += ReturnUnitSymbol( units ); msgtitle = new wxStaticText( parent, -1, text, wxDefaultPosition, wxSize( -1, -1 ), 0 ); msgtitle = new wxStaticText( parent, -1, text, wxDefaultPosition, wxSize( -1, -1 ), 0 ); BoxSizer->Add( msgtitle, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM | wxADJUST_MINSIZE ); BoxSizer->Add( msgtitle, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM | wxADJUST_MINSIZE ); wxFlexGridSizer* GridSizer = new wxFlexGridSizer( 3, 2, 0, 0 ); Loading
3d-viewer/3d_canvas.cpp +25 −25 Original line number Diff line number Diff line Loading @@ -50,27 +50,27 @@ void CheckGLError() /* * Pcb3D_GLCanvas implementation * EDA_3D_CANVAS implementation */ BEGIN_EVENT_TABLE( Pcb3D_GLCanvas, wxGLCanvas ) EVT_PAINT( Pcb3D_GLCanvas::OnPaint ) BEGIN_EVENT_TABLE( EDA_3D_CANVAS, wxGLCanvas ) EVT_PAINT( EDA_3D_CANVAS::OnPaint ) // key event: EVT_CHAR( Pcb3D_GLCanvas::OnChar ) EVT_CHAR( EDA_3D_CANVAS::OnChar ) // mouse events EVT_RIGHT_DOWN( Pcb3D_GLCanvas::OnRightClick ) EVT_MOUSEWHEEL( Pcb3D_GLCanvas::OnMouseWheel ) EVT_MOTION( Pcb3D_GLCanvas::OnMouseMove ) EVT_RIGHT_DOWN( EDA_3D_CANVAS::OnRightClick ) EVT_MOUSEWHEEL( EDA_3D_CANVAS::OnMouseWheel ) EVT_MOTION( EDA_3D_CANVAS::OnMouseMove ) // other events EVT_ERASE_BACKGROUND( Pcb3D_GLCanvas::OnEraseBackground ) EVT_MENU_RANGE( ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END, Pcb3D_GLCanvas::OnPopUpMenu ) EVT_ERASE_BACKGROUND( EDA_3D_CANVAS::OnEraseBackground ) EVT_MENU_RANGE( ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END, EDA_3D_CANVAS::OnPopUpMenu ) END_EVENT_TABLE() Pcb3D_GLCanvas::Pcb3D_GLCanvas( EDA_3D_FRAME* parent, int* attribList ) : EDA_3D_CANVAS::EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList ) : #if wxCHECK_VERSION( 2, 7, 0 ) wxGLCanvas( parent, -1, attribList, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE ) Loading @@ -94,7 +94,7 @@ Pcb3D_GLCanvas::Pcb3D_GLCanvas( EDA_3D_FRAME* parent, int* attribList ) : } Pcb3D_GLCanvas::~Pcb3D_GLCanvas() EDA_3D_CANVAS::~EDA_3D_CANVAS() { ClearLists(); m_init = false; Loading @@ -105,7 +105,7 @@ Pcb3D_GLCanvas::~Pcb3D_GLCanvas() } void Pcb3D_GLCanvas::ClearLists() void EDA_3D_CANVAS::ClearLists() { if( m_gllist > 0 ) glDeleteLists( m_gllist, 1 ); Loading @@ -114,14 +114,14 @@ void Pcb3D_GLCanvas::ClearLists() } void Pcb3D_GLCanvas::OnChar( wxKeyEvent& event ) void EDA_3D_CANVAS::OnChar( wxKeyEvent& event ) { SetView3D( event.GetKeyCode() ); event.Skip(); } void Pcb3D_GLCanvas::SetView3D( int keycode ) void EDA_3D_CANVAS::SetView3D( int keycode ) { int ii; double delta_move = 0.7 * g_Parm_3D_Visu.m_Zoom; Loading Loading @@ -237,7 +237,7 @@ void Pcb3D_GLCanvas::SetView3D( int keycode ) } void Pcb3D_GLCanvas::OnMouseWheel( wxMouseEvent& event ) void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent& event ) { wxSize size( GetClientSize() ); Loading Loading @@ -288,7 +288,7 @@ void Pcb3D_GLCanvas::OnMouseWheel( wxMouseEvent& event ) } void Pcb3D_GLCanvas::OnMouseMove( wxMouseEvent& event ) void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event ) { wxSize size( GetClientSize() ); double spin_quat[4]; Loading Loading @@ -331,7 +331,7 @@ void Pcb3D_GLCanvas::OnMouseMove( wxMouseEvent& event ) /* Construct and display a popup menu when the right button is clicked. */ void Pcb3D_GLCanvas::OnRightClick( wxMouseEvent& event ) void EDA_3D_CANVAS::OnRightClick( wxMouseEvent& event ) { wxPoint pos; wxMenu PopUpMenu; Loading Loading @@ -406,7 +406,7 @@ void Pcb3D_GLCanvas::OnRightClick( wxMouseEvent& event ) } void Pcb3D_GLCanvas::OnPopUpMenu( wxCommandEvent& event ) void EDA_3D_CANVAS::OnPopUpMenu( wxCommandEvent& event ) { int key = 0; Loading Loading @@ -468,7 +468,7 @@ void Pcb3D_GLCanvas::OnPopUpMenu( wxCommandEvent& event ) } void Pcb3D_GLCanvas::DisplayStatus() void EDA_3D_CANVAS::DisplayStatus() { wxString msg; Loading @@ -483,7 +483,7 @@ void Pcb3D_GLCanvas::DisplayStatus() } void Pcb3D_GLCanvas::OnPaint( wxPaintEvent& event ) void EDA_3D_CANVAS::OnPaint( wxPaintEvent& event ) { wxPaintDC dc( this ); Loading @@ -492,14 +492,14 @@ void Pcb3D_GLCanvas::OnPaint( wxPaintEvent& event ) } void Pcb3D_GLCanvas::OnEraseBackground( wxEraseEvent& event ) void EDA_3D_CANVAS::OnEraseBackground( wxEraseEvent& event ) { // Do nothing, to avoid flashing. } /* Initialize broad parameters for OpenGL */ void Pcb3D_GLCanvas::InitGL() void EDA_3D_CANVAS::InitGL() { wxSize size = GetClientSize(); Loading Loading @@ -568,7 +568,7 @@ void Pcb3D_GLCanvas::InitGL() g_Parm_3D_Visu.m_BgColor.m_Blue, 1 ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // Setup light souces: // Setup light sources: SetLights(); CheckGLError(); Loading @@ -576,7 +576,7 @@ void Pcb3D_GLCanvas::InitGL() /* Initialize OpenGL light sources. */ void Pcb3D_GLCanvas::SetLights() void EDA_3D_CANVAS::SetLights() { double light; GLfloat light_color[4]; Loading Loading @@ -604,7 +604,7 @@ void Pcb3D_GLCanvas::SetLights() /* Create a Screenshot of the current 3D view. * Output file format is png or jpeg, or image is copied to the clipboard */ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event ) void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event ) { wxFileName fn( m_Parent->m_Parent->GetScreen()->GetFileName() ); wxString FullFileName; Loading
3d-viewer/3d_draw.cpp +28 −23 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ static void CALLBACK tessErrorCB( GLenum errorCode ); static void CALLBACK tessCPolyPt2Vertex( const GLvoid* data ); static void CALLBACK tesswxPoint2Vertex( const GLvoid* data ); void Pcb3D_GLCanvas::Redraw( bool finish ) void EDA_3D_CANVAS::Redraw( bool finish ) { /* SwapBuffer requires the window to be shown before calling */ if( !IsShown() ) Loading Loading @@ -110,7 +110,7 @@ void Pcb3D_GLCanvas::Redraw( bool finish ) /* Create the draw list items */ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() GLuint EDA_3D_CANVAS::CreateDrawGL_List() { PCB_BASE_FRAME* pcbframe = m_Parent->m_Parent; BOARD* pcb = pcbframe->GetBoard(); Loading Loading @@ -219,8 +219,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() glEnd(); #endif /* move the board in order to draw it with its center at 0,0 3D * coordinates */ /* move the board in order to draw it with its center at 0,0 3D coordinates */ 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 ); Loading Loading @@ -248,6 +247,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() for( ii = 0; ii < pcb->GetAreaCount(); ii++ ) { ZONE_CONTAINER* curr_zone = pcb->GetArea( ii ); if( curr_zone->m_FillMode == 0 ) { // solid polygons only are used to fill areas Loading Loading @@ -295,6 +295,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() for( int ic = 1; ic <= imax; ic++ ) { CPolyPt* endcorner = &zone->m_FilledPolysList[ic]; if( begincorner->utility == 0 ) { // Draw only basic outlines, not extra segments Loading @@ -304,6 +305,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() dummysegment.m_End.y = endcorner->y; Draw3D_Track( &dummysegment ); } if( (endcorner->end_contour) || (ic == imax) ) { // the last corner of a filled area is found: draw it Loading Loading @@ -368,7 +370,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() } void Pcb3D_GLCanvas::Draw3D_Track( TRACK* track ) void EDA_3D_CANVAS::Draw3D_Track( TRACK* track ) { double zpos; int layer = track->GetLayer(); Loading Loading @@ -402,7 +404,7 @@ void Pcb3D_GLCanvas::Draw3D_Track( TRACK* track ) * draw all solid polygons used as filles areas in a zone * @param aZone = the zone to draw */ void Pcb3D_GLCanvas::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone ) void EDA_3D_CANVAS::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone ) { double zpos; int layer = aZone->GetLayer(); Loading Loading @@ -435,6 +437,7 @@ void Pcb3D_GLCanvas::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone ) // Draw solid areas contained in this zone int StartContour = 1; for( unsigned ii = 0; ii < aZone->m_FilledPolysList.size(); ii++ ) { if( StartContour == 1 ) Loading @@ -443,6 +446,7 @@ void Pcb3D_GLCanvas::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone ) gluTessBeginContour( tess ); StartContour = 0; } v_data[0] = aZone->m_FilledPolysList[ii].x * g_Parm_3D_Visu.m_BoardScale; v_data[1] = -aZone->m_FilledPolysList[ii].y * g_Parm_3D_Visu.m_BoardScale; gluTessVertex( tess, v_data, &aZone->m_FilledPolysList[ii] ); Loading @@ -461,7 +465,7 @@ void Pcb3D_GLCanvas::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone ) /* 3D drawing for a VIA (cylinder + filled circles) */ void Pcb3D_GLCanvas::Draw3D_Via( SEGVIA* via ) void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via ) { double x, y, r, hole; int layer, top_layer, bottom_layer; Loading @@ -480,6 +484,7 @@ void Pcb3D_GLCanvas::Draw3D_Via( SEGVIA* via ) 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 ) { if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false ) Loading Loading @@ -519,7 +524,7 @@ void Pcb3D_GLCanvas::Draw3D_Via( SEGVIA* via ) } void Pcb3D_GLCanvas::Draw3D_DrawSegment( DRAWSEGMENT* segment ) void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment ) { double x, y, xf, yf; double zpos, w; Loading Loading @@ -608,7 +613,7 @@ static void Draw3dTextSegm( int x0, int y0, int xf, int yf ) } void Pcb3D_GLCanvas::Draw3D_DrawText( TEXTE_PCB* text ) void EDA_3D_CANVAS::Draw3D_DrawText( TEXTE_PCB* text ) { int layer = text->GetLayer(); Loading Loading @@ -661,7 +666,7 @@ void Pcb3D_GLCanvas::Draw3D_DrawText( TEXTE_PCB* text ) } void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) void MODULE::Draw3D( EDA_3D_CANVAS* glcanvas ) { D_PAD* pad = m_Pads; Loading @@ -676,7 +681,7 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) /* Draw module shape: 3D shape if exists (or module outlines if not exists) */ S3D_MASTER* Struct3D = m_3D_Drawings; bool As3dShape = FALSE; bool As3dShape = false; if( g_Parm_3D_Visu.m_Draw3DModule ) { Loading @@ -703,7 +708,7 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) { if( !Struct3D->m_Shape3DName.IsEmpty() ) { As3dShape = TRUE; As3dShape = true; Struct3D->ReadData(); } } Loading Loading @@ -739,7 +744,7 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) } void EDGE_MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas ) { wxString s; int dx, dy; Loading Loading @@ -862,7 +867,7 @@ void EDGE_MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) /* Draw 3D pads. */ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) { int ii, ll, layer, nlmax; int ux0, uy0, Loading Loading @@ -907,8 +912,8 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis nlmax = g_Parm_3D_Visu.m_Layers - 1; Oncu = (m_layerMask & LAYER_BACK) ? TRUE : FALSE; Oncmp = (m_layerMask & LAYER_FRONT) ? TRUE : FALSE; Oncu = (m_layerMask & LAYER_BACK) ? true : false; Oncmp = (m_layerMask & LAYER_FRONT) ? true : false; Both = Oncu && Oncmp; switch( m_PadShape & 0x7F ) Loading Loading @@ -1364,10 +1369,10 @@ static void Draw3D_CircleSegment( double startx, double starty, double endx, /** * Function Draw3D_Polygon * draw one solid polygon * @param aCornersList = a std::vector<wxPoint> liste of corners, in physical coordinates * @param aCornersList = a std::vector<wxPoint> list of corners, in physical coordinates * @param aZpos = the z position in 3D units */ void Pcb3D_GLCanvas::Draw3D_Polygon( std::vector<wxPoint>& aCornersList, double aZpos ) void EDA_3D_CANVAS::Draw3D_Polygon( std::vector<wxPoint>& aCornersList, double aZpos ) { g_Parm_3D_Visu.m_ActZpos = aZpos; Loading Loading @@ -1407,19 +1412,19 @@ static int Get3DLayerEnable( int act_layer ) { bool enablelayer; enablelayer = TRUE; enablelayer = true; if( act_layer == DRAW_N && !g_Parm_3D_Visu.m_Draw3DDrawings ) enablelayer = FALSE; enablelayer = false; if( act_layer == COMMENT_N && !g_Parm_3D_Visu.m_Draw3DComments ) enablelayer = FALSE; enablelayer = false; if( act_layer == ECO1_N && !g_Parm_3D_Visu.m_Draw3DEco1 ) enablelayer = FALSE; enablelayer = false; if( act_layer == ECO2_N && !g_Parm_3D_Visu.m_Draw3DEco2 ) enablelayer = FALSE; enablelayer = false; return enablelayer; } Loading
3d-viewer/3d_frame.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -66,9 +66,9 @@ EDA_3D_FRAME::EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title, long // ReCreateAuxiliaryToolbar(); ReCreateVToolbar(); // Make a Pcb3D_GLCanvas // Make a EDA_3D_CANVAS int attrs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0 }; m_Canvas = new Pcb3D_GLCanvas( this, attrs ); m_Canvas = new EDA_3D_CANVAS( this, attrs ); m_auimgr.SetManagedWindow( this ); Loading
3d-viewer/3d_read_mesh.cpp +58 −22 Original line number Diff line number Diff line Loading @@ -24,9 +24,10 @@ int S3D_MASTER::ReadData() return 1; } if( wxFileName::FileExists( m_Shape3DName ) ) { FullFilename = m_Shape3DName; } else { fn = m_Shape3DName; Loading @@ -50,18 +51,23 @@ int S3D_MASTER::ReadData() // Switch the locale to standard C (needed to print floating point // numbers like 1.3) SetLocaleTo_C_standard(); 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 ); Loading Loading @@ -98,6 +104,7 @@ int S3D_MASTER:: ReadMaterial( FILE* file, int* LineNum ) command = strtok( NULL, " \t\n\r" ); text = strtok( NULL, " \t\n\r" ); mat_name = FROM_UTF8( text ); if( stricmp( command, "USE" ) == 0 ) { for( material = m_Materials; material; material = material->Next() ) Loading @@ -122,13 +129,16 @@ int S3D_MASTER:: ReadMaterial( FILE* file, int* LineNum ) 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" ); Loading Loading @@ -173,6 +183,7 @@ int S3D_MASTER:: ReadMaterial( FILE* file, int* LineNum ) } } } return -1; } Loading @@ -184,8 +195,10 @@ int S3D_MASTER::ReadChildren( FILE* file, int* LineNum ) while( GetLine( file, line, LineNum, 512 ) ) { text = strtok( line, " \t\n\r" ); if( *text == ']' ) return 0; if( *text == ',' ) continue; Loading @@ -212,6 +225,7 @@ int S3D_MASTER::ReadShape( FILE* file, int* LineNum ) while( GetLine( file, line, LineNum, 512 ) ) { text = strtok( line, " \t\n\r" ); if( *text == '}' ) { err = 0; Loading Loading @@ -245,6 +259,7 @@ int S3D_MASTER::ReadAppearance( FILE* file, int* LineNum ) while( GetLine( file, line, LineNum, 512 ) ) { text = strtok( line, " \t\n\r" ); if( *text == '}' ) { err = 0; break; Loading Loading @@ -283,18 +298,18 @@ int S3D_MASTER::ReadAppearance( FILE* file, int* LineNum ) * text_buffer contains the first line of this node : * "coord Coordinate { point [" */ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, int* LineNum ) double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, int* LineNum ) { double* data_list = NULL; unsigned int ii = 0, jj = 0, nn = BUFSIZE; char* text; bool HasData = FALSE; bool StartData = FALSE; bool EndNode = FALSE; bool HasData = false; bool StartData = false; bool EndNode = false; char string_num[512]; text = text_buffer; while( !EndNode ) { if( *text == 0 ) // Needs data ! Loading @@ -308,13 +323,13 @@ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, switch( *text ) { case '[': StartData = TRUE; StartData = true; jj = 0; string_num[jj] = 0; data_list = (double*) MyZMalloc( nn * sizeof(double) ); break; case '}': EndNode = TRUE; EndNode = true; break; case ']': Loading @@ -322,32 +337,38 @@ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, case ' ': case ',': jj = 0; if( !StartData || !HasData ) break; data_list[ii] = atof( string_num ); string_num[jj] = 0; ii++; if( ii >= nn ) { nn *= 2; data_list = (double*) realloc( data_list, ( nn * sizeof(double) ) ); data_list = (double*) realloc( data_list, ( nn * sizeof(double) ) ); } HasData = FALSE; HasData = false; if( *text == ']' ) { StartData = FALSE; StartData = false; } break; default: if( !StartData ) break; if( jj >= sizeof(string_num) ) break; string_num[jj] = *text; jj++; string_num[jj] = 0; HasData = TRUE; HasData = true; break; } Loading @@ -357,8 +378,10 @@ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, if( data_list ) data_list = (double*) realloc( data_list, ( ii * sizeof(double) ) ); if( bufsize ) *bufsize = ii; return data_list; } Loading @@ -375,6 +398,7 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) { strcpy( buffer, line ); text = strtok( buffer, " \t\n\r" ); if( *text == '}' ) { err = 0; break; Loading @@ -383,7 +407,8 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) if( stricmp( text, "normalPerVertex" ) == 0 ) { text = strtok( NULL, " ,\t\n\r" ); if( stricmp( text, "TRUE" ) == 0 ) if( stricmp( text, "true" ) == 0 ) { } else Loading @@ -395,7 +420,8 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) if( stricmp( text, "colorPerVertex" ) == 0 ) { text = strtok( NULL, " ,\t\n\r" ); if( stricmp( text, "TRUE" ) == 0 ) if( stricmp( text, "true" ) == 0 ) { } else Loading @@ -407,8 +433,8 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) if( stricmp( text, "normal" ) == 0 ) { int coord_number; double* buf_points = ReadCoordsList( file, line, &coord_number, LineNum ); double* buf_points = ReadCoordsList( file, line, &coord_number, LineNum ); // Do something if needed free( buf_points ); continue; Loading @@ -418,10 +444,12 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) while( GetLine( file, line, LineNum, 512 ) ) { text = strtok( line, " ,\t\n\r" ); while( text ) { if( *text == ']' ) break; text = strtok( NULL, " ,\t\n\r" ); } Loading @@ -435,21 +463,24 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) if( stricmp( text, "color" ) == 0 ) { int coord_number; double* buf_points = ReadCoordsList( file, line, &coord_number, LineNum ); double* buf_points = ReadCoordsList( file, line, &coord_number, LineNum ); // Do something if needed 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" ); } Loading @@ -468,20 +499,24 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) else if( stricmp( text, "coordIndex" ) == 0 ) { index = (int*) MyMalloc( nn * sizeof(int) ); S3D_Vertex* coords = (S3D_Vertex*) MyMalloc( nn * sizeof(S3D_Vertex) ); 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( text ); if( jj < 0 ) { S3D_Vertex* curr_coord = coords; for( jj = 0; jj < coord_count; jj++ ) { int kk = index[jj] * 3; Loading @@ -499,6 +534,7 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) { index[coord_count++] = jj; } text = strtok( NULL, " ,\t\n\r" ); } Loading