diff --git a/3d-viewer/3d_canvas.cpp b/3d-viewer/3d_canvas.cpp index 8a16b0c439..05d056b081 100644 --- a/3d-viewer/3d_canvas.cpp +++ b/3d-viewer/3d_canvas.cpp @@ -1,4 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// + // Name: 3d_canvas.cpp ///////////////////////////////////////////////////////////////////////////// @@ -32,22 +33,21 @@ #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 +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 }; @@ -55,381 +55,412 @@ enum onrclick_id * 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) +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) +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(); + m_init = FALSE; + m_gllist = 0; + m_Parent = parent; + DisplayStatus(); } /*************************************/ -Pcb3D_GLCanvas::~Pcb3D_GLCanvas(void) +Pcb3D_GLCanvas::~Pcb3D_GLCanvas( void ) /*************************************/ { - ClearLists(); + ClearLists(); } + /*************************************/ -void Pcb3D_GLCanvas::ClearLists(void) +void Pcb3D_GLCanvas::ClearLists( void ) /*************************************/ { - if( m_gllist > 0 ) - glDeleteLists(m_gllist, 1); - m_init = FALSE; - m_gllist = 0; + if( m_gllist > 0 ) + glDeleteLists( m_gllist, 1 ); + m_init = FALSE; + m_gllist = 0; } + /*********************************************/ -void Pcb3D_GLCanvas::OnChar(wxKeyEvent& event) +void Pcb3D_GLCanvas::OnChar( wxKeyEvent& event ) /*********************************************/ { - SetView3D(event.GetKeyCode()); - event.Skip(); + SetView3D( event.GetKeyCode() ); + event.Skip(); } + /*********************************************/ -void Pcb3D_GLCanvas::SetView3D(int keycode) +void Pcb3D_GLCanvas::SetView3D( int keycode ) /*********************************************/ { -int ii; -double delta_move = 0.7 * g_Parm_3D_Visu.m_Zoom; + 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; + switch( keycode ) + { + case WXK_LEFT: + g_Draw3d_dx -= 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_RIGHT: + g_Draw3d_dx += delta_move; + break; - case WXK_END: - break; + case WXK_UP: + g_Draw3d_dy += delta_move; + 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_DOWN: + g_Draw3d_dy -= delta_move; + break; - case WXK_F2: - g_Parm_3D_Visu.m_Zoom *= 1.4; - 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 '+': - break; + case WXK_END: + break; - case '-': - 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 '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 WXK_F2: + g_Parm_3D_Visu.m_Zoom *= 1.4; + 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 '+': + 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 '-': + 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 '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; - 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; + 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 ); - break; + case 'x': + for( ii = 0; ii < 4; ii++ ) + g_Parm_3D_Visu.m_Rot[ii] = 0.0; - 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; + 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; - default: - return; - } + case 'X': + for( ii = 0; ii < 4; ii++ ) + g_Parm_3D_Visu.m_Rot[ii] = 0.0; - DisplayStatus(); - Refresh(FALSE); + 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) +void Pcb3D_GLCanvas::OnMouseEvent( wxMouseEvent& event ) /********************************************************/ { -wxSize size(GetClientSize()); -float spin_quat[4]; + wxSize size( GetClientSize() ); + float spin_quat[4]; - if( event.RightDown() ) - { - OnRightClick(event); return; - } + if( event.RightDown() ) + { + OnRightClick( event ); return; + } - if ( event.m_wheelRotation ) - { - if( event.ShiftDown() ) { - if ( event.GetWheelRotation() < 0 ) { - /* up */ - SetView3D(WXK_UP); - } else { - /* down */ - SetView3D(WXK_DOWN); - } - } else if( event.ControlDown() ) { - if ( event.GetWheelRotation() > 0 ) { - /* right */ - SetView3D(WXK_RIGHT); - } else { - /* left */ - SetView3D(WXK_LEFT); + if( event.m_wheelRotation ) + { + if( event.ShiftDown() ) + { + if( event.GetWheelRotation() < 0 ) + { + /* up */ + SetView3D( WXK_UP ); + } + else + { + /* down */ + SetView3D( WXK_DOWN ); } } - else { - if ( event.GetWheelRotation() > 0 ) + else if( event.ControlDown() ) + { + if( event.GetWheelRotation() > 0 ) + { + /* right */ + SetView3D( WXK_RIGHT ); + } + else + { + /* left */ + SetView3D( WXK_LEFT ); + } + } + else + { + if( event.GetWheelRotation() > 0 ) { g_Parm_3D_Visu.m_Zoom /= 1.4; - if ( g_Parm_3D_Visu.m_Zoom <= 0.01) + if( g_Parm_3D_Visu.m_Zoom <= 0.01 ) g_Parm_3D_Visu.m_Zoom = 0.01; } - else g_Parm_3D_Visu.m_Zoom *= 1.4; + else + g_Parm_3D_Visu.m_Zoom *= 1.4; DisplayStatus(); - Refresh(FALSE); + Refresh( FALSE ); } - } + } - if (event.Dragging()) + 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); + 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); + 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) +void Pcb3D_GLCanvas::OnRightClick( wxMouseEvent& event ) /*******************************************************/ + /* Construit et affiche un menu Popup lorsque on actionne le bouton droit - de la souris -*/ + * de la souris + */ { -wxPoint pos; -wxMenu PopUpMenu; + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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_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_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); + item = new wxMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_DOWN, + _( "Move Down" ) ); + item->SetBitmap( down_xpm ); + PopUpMenu.Append( item ); - PopupMenu( &PopUpMenu, pos); + PopupMenu( &PopUpMenu, pos ); } + /*******************************************************/ -void Pcb3D_GLCanvas::OnPopUpMenu(wxCommandEvent & event) +void Pcb3D_GLCanvas::OnPopUpMenu( wxCommandEvent& event ) /*******************************************************/ { -int key = 0; + int key = 0; - switch( event.GetId() ) - { - case ID_POPUP_ZOOMIN: - key = WXK_F1; - break; + switch( event.GetId() ) + { + case ID_POPUP_ZOOMIN: + key = WXK_F1; + break; - case ID_POPUP_ZOOMOUT: - key = WXK_F2; - break; + case ID_POPUP_ZOOMOUT: + key = WXK_F2; + break; - case ID_POPUP_VIEW_XPOS: - key = 'x'; - break; + case ID_POPUP_VIEW_XPOS: + key = 'x'; + break; - case ID_POPUP_VIEW_XNEG: - key = 'X'; - break; + case ID_POPUP_VIEW_XNEG: + key = 'X'; + break; - case ID_POPUP_VIEW_YPOS: - key = 'y'; - break; + case ID_POPUP_VIEW_YPOS: + key = 'y'; + break; - case ID_POPUP_VIEW_YNEG: - key = 'Y'; - break; + case ID_POPUP_VIEW_YNEG: + key = 'Y'; + break; - case ID_POPUP_VIEW_ZPOS: - key = 'z'; - break; + case ID_POPUP_VIEW_ZPOS: + key = 'z'; + break; - case ID_POPUP_VIEW_ZNEG: - 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; + case ID_POPUP_MOVE3D_LEFT: + key = WXK_LEFT; + break; - default: - return; - } - SetView3D(key); + 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) +void Pcb3D_GLCanvas::DisplayStatus( void ) /***************************************/ { -wxString msg; - msg.Printf(wxT("dx %3.2f"), g_Draw3d_dx); - m_Parent->SetStatusText(msg,1); + wxString msg; - msg.Printf(wxT("dy %3.2f"), g_Draw3d_dy); - m_Parent->SetStatusText(msg,2); + msg.Printf( wxT( "dx %3.2f" ), g_Draw3d_dx ); + m_Parent->SetStatusText( msg, 1 ); - msg.Printf(wxT("View: %3.1f"), 45 * g_Parm_3D_Visu.m_Zoom); - m_Parent->SetStatusText(msg,3); + 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 ); } @@ -437,203 +468,207 @@ wxString msg; void Pcb3D_GLCanvas::OnPaint( wxPaintEvent& event ) /*************************************************/ { - wxPaintDC dc(this); + wxPaintDC dc( this ); #ifndef __WXMOTIF__ - if (!GetContext()) return; + if( !GetContext() ) + return; #endif - Redraw(); - event.Skip(); + Redraw(); + event.Skip(); } /**********************************************/ -void Pcb3D_GLCanvas::OnSize(wxSizeEvent& event) +void Pcb3D_GLCanvas::OnSize( wxSizeEvent& event ) /**********************************************/ { // this is also necessary to update the context on some platforms - wxGLCanvas::OnSize(event); + wxGLCanvas::OnSize( event ); // set GL viewport (not called by wxGLCanvas::OnSize on all platforms...) int w, h; - GetClientSize(&w, &h); + GetClientSize( &w, &h ); #ifndef __WXMOTIF__ - if (GetContext()) + if( GetContext() ) #endif { SetCurrent(); - glViewport(0, 0, (GLint) w, (GLint) h); + glViewport( 0, 0, (GLint) w, (GLint) h ); } } + /***********************************************************/ -void Pcb3D_GLCanvas::OnEraseBackground(wxEraseEvent& event) +void Pcb3D_GLCanvas::OnEraseBackground( wxEraseEvent& event ) /***********************************************************/ { - // Do nothing, to avoid flashing. + // 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; - } +/* 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); + 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 ); +#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); + 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 ); + 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(); + /* Setup light souces: */ + SetLights(); - glDisable(GL_CULL_FACE); // show back faces + glDisable( GL_CULL_FACE ); // show back faces - glEnable(GL_DEPTH_TEST); // Enable z-buferring + glEnable( GL_DEPTH_TEST ); // Enable z-buferring - glEnable(GL_LINE_SMOOTH); - glEnable(GL_COLOR_MATERIAL); - glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); + 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); + /* 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) +void Pcb3D_GLCanvas::SetLights( void ) /***********************************/ -/* Init sources lumineuses pour OPENGL -*/ -{ -double light; -GLfloat light_color[4]; - SetCurrent(); +/* 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 }; + 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); + 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) +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 -*/ + * Output file format is png or jpeg, or image is copied on clipboard + */ { -wxString FullFileName; -wxString file_ext, mask; -bool fmt_is_jpeg = FALSE; + 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); + 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; - } - - Redraw(true); - wxSize image_size = GetClientSize(); - wxClientDC dc(this); - wxBitmap bitmap(image_size.x, image_size.y ); - wxMemoryDC memdc; + 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; + } + + Redraw( true ); + 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.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(); - } - } + 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(); - else - { - wxImage image = bitmap.ConvertToImage(); + if( !image.SaveFile( FullFileName, + fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) ) + wxLogError( wxT( "Can't save file" ) ); - if ( !image.SaveFile( FullFileName, - fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG)) - wxLogError(wxT("Can't save file")); - - image.Destroy(); - } + image.Destroy(); + } } - - diff --git a/change_log.txt b/change_log.txt index 5076b652e8..8d2c91c4e9 100644 --- a/change_log.txt +++ b/change_log.txt @@ -5,6 +5,22 @@ Please add newer entries at the top, list the date and your name with email address. +2007-Aug-19 UPDATE Dick Hollenbeck <dick@softplc.com> +================================================================================ ++ all + * Made BASE_SCREEN::m_CurrentItem private so we can force usage of the new + SetCurItem() function, and use it to put a breakpoint on the only place + that m_CurrentItem is changed, namely in the new SetCurItem() function. + ( Added new function GetCurItem() as well to class BASE_SCREEN in + drawpanel_wxstruct.h.) Using a stack trace at the breakpoint we can tell + who called it. There were in excess of 450 edits to get this done so I + had to commit it asap so other folks could get on with edits without a + merge conflict. + * Started work on the COLLECTOR class which will assist in giving a choice + in PCBNEW when there is more than one click candidate at the same mouse + or cursor coordinates. COLLECTOR not committed yet. + * More beautification. + 2007-Aug-14 UPDATE Dick Hollenbeck <dick@softplc.com> ================================================================================ diff --git a/common/base_screen.cpp b/common/base_screen.cpp index d18432e0f2..7d320c9fec 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -1,6 +1,6 @@ - /******************************************************************/ - /* drawpanel.cpp - fonctions des classes du type WinEDA_DrawPanel */ - /******************************************************************/ +/******************************************************************/ +/* drawpanel.cpp - fonctions des classes du type WinEDA_DrawPanel */ +/******************************************************************/ #ifdef __GNUG__ #pragma implementation @@ -11,487 +11,557 @@ /* defines locaux */ -#define CURSOR_SIZE 12 /* taille de la croix du curseur PCB */ +#define CURSOR_SIZE 12 /* taille de la croix du curseur PCB */ - /*******************************************************/ - /* Class BASE_SCREEN: classe de gestion d'un affichage */ - /*******************************************************/ -BASE_SCREEN::BASE_SCREEN(int idscreen): EDA_BaseStruct(SCREEN_STRUCT_TYPE) +/*******************************************************/ +/* Class BASE_SCREEN: classe de gestion d'un affichage */ +/*******************************************************/ +BASE_SCREEN::BASE_SCREEN( int idscreen ) : EDA_BaseStruct( SCREEN_STRUCT_TYPE ) { - EEDrawList = NULL; /* Schematic items list */ - m_Type = idscreen; - m_ZoomList = NULL; - m_GridList = NULL; - m_UndoList = NULL; - m_RedoList = NULL; - m_UndoRedoCountMax = 1; - m_FirstRedraw = TRUE; - InitDatas(); + EEDrawList = NULL; /* Schematic items list */ + m_Type = idscreen; + m_ZoomList = NULL; + m_GridList = NULL; + m_UndoList = NULL; + m_RedoList = NULL; + m_UndoRedoCountMax = 1; + m_FirstRedraw = TRUE; + InitDatas(); } /******************************/ -BASE_SCREEN::~BASE_SCREEN(void) +BASE_SCREEN::~BASE_SCREEN( void ) /******************************/ { - if ( m_ZoomList ) free(m_ZoomList); - if ( m_GridList ) free(m_GridList); - ClearUndoRedoList(); + if( m_ZoomList ) + free( m_ZoomList ); + if( m_GridList ) + free( m_GridList ); + ClearUndoRedoList(); } + /*******************************/ -void BASE_SCREEN::InitDatas(void) +void BASE_SCREEN::InitDatas( void ) /*******************************/ { - m_SheetNumber = m_NumberOfSheet = 1; /* gestion hierarchie: Root: SheetNumber = 1 */ - m_Zoom = 32; - m_Grid = wxSize(50,50); /* pas de la grille */ - m_UserGrid = g_UserGrid; /* pas de la grille "utilisateur" */ - m_UserGridIsON = FALSE; - m_UserGridUnit = g_UserGrid_Unit; - m_Diviseur_Grille = 1; - m_Center = TRUE; + m_SheetNumber = m_NumberOfSheet = 1; /* gestion hierarchie: Root: SheetNumber = 1 */ + m_Zoom = 32; + m_Grid = wxSize( 50, 50 ); /* pas de la grille */ + m_UserGrid = g_UserGrid; /* pas de la grille "utilisateur" */ + m_UserGridIsON = FALSE; + m_UserGridUnit = g_UserGrid_Unit; + m_Diviseur_Grille = 1; + m_Center = TRUE; - /* offsets pour tracer le circuit sur l'ecran */ - switch (m_Type ) // Init taille sheet par defaut - { - case SCHEMATIC_FRAME : - m_Center = FALSE; - m_CurrentSheet = &g_Sheet_A4; - break; + /* offsets pour tracer le circuit sur l'ecran */ + switch( m_Type ) // Init taille sheet par defaut + { + case SCHEMATIC_FRAME: + m_Center = FALSE; + m_CurrentSheet = &g_Sheet_A4; + break; - default: - case CVPCB_DISPLAY_FRAME: - case MODULE_EDITOR_FRAME: - case PCB_FRAME: - m_CurrentSheet = &g_Sheet_A4; - break; + default: + case CVPCB_DISPLAY_FRAME: + case MODULE_EDITOR_FRAME: + case PCB_FRAME: + m_CurrentSheet = &g_Sheet_A4; + break; - case GERBER_FRAME: - m_CurrentSheet = &g_Sheet_GERBER; - break; - } + case GERBER_FRAME: + m_CurrentSheet = &g_Sheet_GERBER; + break; + } - if ( m_Center ) - { - m_Curseur.x = m_Curseur.y = 0; - m_DrawOrg.x = - ReturnPageSize().x/2; - m_DrawOrg.y = - ReturnPageSize().y/2; - } - else - { - m_DrawOrg.x = m_DrawOrg.y = 0; - m_Curseur.x = ReturnPageSize().x/2; - m_Curseur.y = ReturnPageSize().y/2; - } + if( m_Center ) + { + m_Curseur.x = m_Curseur.y = 0; + m_DrawOrg.x = -ReturnPageSize().x / 2; + m_DrawOrg.y = -ReturnPageSize().y / 2; + } + else + { + m_DrawOrg.x = m_DrawOrg.y = 0; + m_Curseur.x = ReturnPageSize().x / 2; + m_Curseur.y = ReturnPageSize().y / 2; + } - // DrawOrg est rendu multiple du zoom min : - m_DrawOrg.x -= m_DrawOrg.x % 256; m_DrawOrg.y -= m_DrawOrg.y % 256; + // DrawOrg est rendu multiple du zoom min : + m_DrawOrg.x -= m_DrawOrg.x % 256; + m_DrawOrg.y -= m_DrawOrg.y % 256; - m_O_Curseur = m_Curseur; + m_O_Curseur = m_Curseur; - m_CurrentItem = NULL; + SetCurItem( NULL ); - /* indicateurs divers */ - m_FlagRefreshReq = 0; /* indique que l'ecran doit redessine */ - m_FlagModified = 0; // indique modif du PCB,utilise pour eviter une sortie sans sauvegarde - m_FlagSave = 1; // indique sauvegarde auto faite + /* indicateurs divers */ + m_FlagRefreshReq = 0; /* indique que l'ecran doit redessine */ + m_FlagModified = 0; // indique modif du PCB,utilise pour eviter une sortie sans sauvegarde + m_FlagSave = 1; // indique sauvegarde auto faite } /******************************************************************/ -wxPoint BASE_SCREEN::CursorRealPosition(const wxPoint & ScreenPos) +wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos ) /******************************************************************/ { -wxPoint curpos; + wxPoint curpos; - curpos.x = ScreenPos.x * GetZoom(); - curpos.y = ScreenPos.y * GetZoom(); + curpos.x = ScreenPos.x* GetZoom(); - curpos.x += m_DrawOrg.x; - curpos.y += m_DrawOrg.y; + curpos.y = ScreenPos.y* GetZoom(); - return curpos; + curpos.x += m_DrawOrg.x; + curpos.y += m_DrawOrg.y; + + return curpos; } + /***************************************/ -int BASE_SCREEN::GetInternalUnits(void) +int BASE_SCREEN::GetInternalUnits( void ) /***************************************/ { - switch (m_Type ) - { - default: - case SCHEMATIC_FRAME : - return EESCHEMA_INTERNAL_UNIT; - break; + switch( m_Type ) + { + default: + case SCHEMATIC_FRAME: + return EESCHEMA_INTERNAL_UNIT; + break; - case GERBER_FRAME: - case CVPCB_DISPLAY_FRAME: - case MODULE_EDITOR_FRAME: - case PCB_FRAME: - return PCB_INTERNAL_UNIT; - } + case GERBER_FRAME: + case CVPCB_DISPLAY_FRAME: + case MODULE_EDITOR_FRAME: + case PCB_FRAME: + return PCB_INTERNAL_UNIT; + } } + /*****************************************/ -wxSize BASE_SCREEN::ReturnPageSize(void) +wxSize BASE_SCREEN::ReturnPageSize( void ) /*****************************************/ + /* Retourne en unites internes la taille de la feuille de dessin - (la taille de la feuille est connue en 1/1000 ") -*/ + * (la taille de la feuille est connue en 1/1000 ") + */ { -wxSize PageSize; - - switch (m_Type ) - { - default: - case SCHEMATIC_FRAME : - PageSize = m_CurrentSheet->m_Size; - break; + wxSize PageSize; - case GERBER_FRAME: - case CVPCB_DISPLAY_FRAME: - case MODULE_EDITOR_FRAME: - case PCB_FRAME: - PageSize.x = m_CurrentSheet->m_Size.x * (PCB_INTERNAL_UNIT/1000); - PageSize.y = m_CurrentSheet->m_Size.y * (PCB_INTERNAL_UNIT/1000); - break; - } - - return PageSize; + switch( m_Type ) + { + default: + case SCHEMATIC_FRAME: + PageSize = m_CurrentSheet->m_Size; + break; + + case GERBER_FRAME: + case CVPCB_DISPLAY_FRAME: + case MODULE_EDITOR_FRAME: + case PCB_FRAME: + PageSize.x = m_CurrentSheet->m_Size.x * (PCB_INTERNAL_UNIT / 1000); + PageSize.y = m_CurrentSheet->m_Size.y * (PCB_INTERNAL_UNIT / 1000); + break; + } + + return PageSize; } /********************************************/ -void BASE_SCREEN::SetZoomList(int * zoomlist) +void BASE_SCREEN::SetZoomList( int* zoomlist ) /********************************************/ + /* init liste des zoom (NULL terminated) -*/ + */ { -int ii, nbitems, * zoom; - // Decompte des items - for ( nbitems = 1, zoom = zoomlist; ; zoom ++, nbitems++ ) - { - if ( *zoom == 0 ) break; - } - - // Init liste - if ( m_ZoomList ) free(m_ZoomList); - m_ZoomList = (int*) MyZMalloc( nbitems * sizeof ( int) ); - - for ( ii = 0, zoom = zoomlist; ii < nbitems; zoom ++, ii++ ) - { - m_ZoomList[ii] = *zoom; - } + int ii, nbitems, * zoom; + + // Decompte des items + for( nbitems = 1, zoom = zoomlist; ; zoom++, nbitems++ ) + { + if( *zoom == 0 ) + break; + } + + // Init liste + if( m_ZoomList ) + free( m_ZoomList ); + m_ZoomList = (int*) MyZMalloc( nbitems * sizeof( int) ); + + for( ii = 0, zoom = zoomlist; ii < nbitems; zoom++, ii++ ) + { + m_ZoomList[ii] = *zoom; + } } + /***********************************/ -void BASE_SCREEN::SetFirstZoom(void) +void BASE_SCREEN::SetFirstZoom( void ) /***********************************/ /* ajuste le coeff de zoom a 1*/ { - m_Zoom = 1; + m_Zoom = 1; } /****************************/ -int BASE_SCREEN::GetZoom(void) +int BASE_SCREEN::GetZoom( void ) /****************************/ /* retourne le coeff de zoom */ { - return m_Zoom; + return m_Zoom; } + /***********************************/ -void BASE_SCREEN::SetZoom(int coeff) +void BASE_SCREEN::SetZoom( int coeff ) /***********************************/ /* ajuste le coeff de zoom a coeff */ { - m_Zoom = coeff; - if ( m_Zoom < 1 ) m_Zoom = 1; + m_Zoom = coeff; + if( m_Zoom < 1 ) + m_Zoom = 1; } /********************************/ -void BASE_SCREEN::SetNextZoom(void) +void BASE_SCREEN::SetNextZoom( void ) /********************************/ + /* Selectionne le prochain coeff de zoom -*/ + */ { - m_Zoom *= 2; + m_Zoom *= 2; - if ( m_ZoomList == NULL ) return; + if( m_ZoomList == NULL ) + return; -int ii, zoom_max = 512; - for ( ii = 0; m_ZoomList[ii] != 0; ii ++ ) zoom_max = m_ZoomList[ii]; - if ( m_Zoom > zoom_max ) m_Zoom = zoom_max; + int ii, zoom_max = 512; + for( ii = 0; m_ZoomList[ii] != 0; ii++ ) + zoom_max = m_ZoomList[ii]; + + if( m_Zoom > zoom_max ) + m_Zoom = zoom_max; } /*************************************/ -void BASE_SCREEN::SetPreviousZoom(void) +void BASE_SCREEN::SetPreviousZoom( void ) /*************************************/ + /* Selectionne le precedent coeff de zoom -*/ + */ { - m_Zoom /= 2; - if ( m_Zoom < 1 ) m_Zoom = 1; + m_Zoom /= 2; + if( m_Zoom < 1 ) + m_Zoom = 1; } /**********************************/ -void BASE_SCREEN::SetLastZoom(void) +void BASE_SCREEN::SetLastZoom( void ) /**********************************/ + /* ajuste le coeff de zoom au max -*/ + */ { - if ( m_ZoomList == NULL ) return; -int ii; - for ( ii = 0; m_ZoomList[ii] != 0; ii ++ ) m_Zoom = m_ZoomList[ii]; + if( m_ZoomList == NULL ) + return; + int ii; + for( ii = 0; m_ZoomList[ii] != 0; ii++ ) + m_Zoom = m_ZoomList[ii]; } /********************************************/ -void BASE_SCREEN::SetGridList(wxSize * gridlist) +void BASE_SCREEN::SetGridList( wxSize* gridlist ) /********************************************/ + /* init liste des zoom (NULL terminated) -*/ + */ { -int ii, nbitems; -wxSize * grid; - // Decompte des items - for ( nbitems = 0, grid = gridlist; ; grid ++, nbitems++ ) - { - if ( (grid->x <= 0) || (grid->y <= 0) ) break; - } - - // Init liste - if ( m_GridList ) free(m_GridList); - m_GridList = (wxSize*) MyZMalloc( nbitems * sizeof (wxSize) ); - - for ( ii = 0, grid = gridlist; ii < nbitems; grid ++, ii++ ) - { - m_GridList[ii] = *grid; - } + int ii, nbitems; + wxSize* grid; + + // Decompte des items + for( nbitems = 0, grid = gridlist; ; grid++, nbitems++ ) + { + if( (grid->x <= 0) || (grid->y <= 0) ) + break; + } + + // Init liste + if( m_GridList ) + free( m_GridList ); + m_GridList = (wxSize*) MyZMalloc( nbitems * sizeof(wxSize) ); + + for( ii = 0, grid = gridlist; ii < nbitems; grid++, ii++ ) + { + m_GridList[ii] = *grid; + } } + /**********************************************/ -void BASE_SCREEN::SetGrid( const wxSize & size ) +void BASE_SCREEN::SetGrid( const wxSize& size ) /**********************************************/ { - if ( m_GridList == NULL ) return; - - if ( (size.x <= 0) || (size.y <= 0) ) - { - m_UserGrid = g_UserGrid; - m_UserGridIsON = TRUE; - } - else - { - m_Grid = size; - m_UserGridIsON = FALSE; - } + if( m_GridList == NULL ) + return; + + if( (size.x <= 0) || (size.y <= 0) ) + { + m_UserGrid = g_UserGrid; + m_UserGridIsON = TRUE; + } + else + { + m_Grid = size; + m_UserGridIsON = FALSE; + } } + /*********************************/ -wxSize BASE_SCREEN::GetGrid(void) +wxSize BASE_SCREEN::GetGrid( void ) /*********************************/ { -wxSize grid = m_Grid; -double xx, scale; - - if ( m_GridList == NULL ) return wxSize(1,1); + wxSize grid = m_Grid; + double xx, scale; - if ( m_UserGridIsON || m_Grid.x < 0 || m_Grid.y < 0 ) - { - if ( m_UserGridUnit == INCHES ) scale = 10000; - else scale = 10000/25.4; - xx = m_UserGrid.x * scale; - grid.x = (int)(xx + 0.5); - xx = m_UserGrid.y * scale; - grid.y = (int)(xx + 0.5); - } - return grid; + if( m_GridList == NULL ) + return wxSize( 1, 1 ); + + if( m_UserGridIsON || m_Grid.x < 0 || m_Grid.y < 0 ) + { + if( m_UserGridUnit == INCHES ) + scale = 10000; + else + scale = 10000 / 25.4; + xx = m_UserGrid.x * scale; + grid.x = (int) (xx + 0.5); + xx = m_UserGrid.y * scale; + grid.y = (int) (xx + 0.5); + } + return grid; } /*********************************/ -void BASE_SCREEN::SetNextGrid(void) +void BASE_SCREEN::SetNextGrid( void ) /*********************************/ + /* Selectionne la prochaine grille -*/ + */ { -int ii; + int ii; - if ( m_GridList == NULL ) return; + if( m_GridList == NULL ) + return; - for ( ii = 0; ; ii++ ) - { - if ( m_GridList[ii].x <= 0 ) break; - if ( (m_Grid.x == m_GridList[ii].x) && (m_Grid.y == m_GridList[ii].y) ) - break; - } - if ( (m_GridList[ii].x > 0) && (ii > 0) ) - m_Grid = m_GridList[ii - 1]; + for( ii = 0; ; ii++ ) + { + if( m_GridList[ii].x <= 0 ) + break; + if( (m_Grid.x == m_GridList[ii].x) && (m_Grid.y == m_GridList[ii].y) ) + break; + } + + if( (m_GridList[ii].x > 0) && (ii > 0) ) + m_Grid = m_GridList[ii - 1]; } /*************************************/ -void BASE_SCREEN::SetPreviousGrid(void) +void BASE_SCREEN::SetPreviousGrid( void ) /*************************************/ + /* Selectionne le precedent coeff de grille -*/ + */ { -int ii; + int ii; - if ( m_GridList == NULL ) return; + if( m_GridList == NULL ) + return; - for ( ii = 0; ; ii++ ) - { - if ( m_GridList[ii].x <= 0 ) break; - if ( (m_Grid.x == m_GridList[ii].x) && (m_Grid.y == m_GridList[ii].y) ) - break; - } - if ( (m_GridList[ii].x > 0) && (m_GridList[ii+1].x > 0) ) - m_Grid = m_GridList[ii + 1]; + for( ii = 0; ; ii++ ) + { + if( m_GridList[ii].x <= 0 ) + break; + if( (m_Grid.x == m_GridList[ii].x) && (m_Grid.y == m_GridList[ii].y) ) + break; + } + + if( (m_GridList[ii].x > 0) && (m_GridList[ii + 1].x > 0) ) + m_Grid = m_GridList[ii + 1]; } /**********************************/ -void BASE_SCREEN::SetFirstGrid(void) +void BASE_SCREEN::SetFirstGrid( void ) /**********************************/ + /* ajuste le coeff de grille a 1 -*/ + */ { - if ( m_GridList == NULL ) return; + if( m_GridList == NULL ) + return; -int ii = 0; - while ( m_GridList[ii].x > 0 ) ii ++; - m_Grid = m_GridList[ii-1]; + int ii = 0; + while( m_GridList[ii].x > 0 ) + ii++; + + m_Grid = m_GridList[ii - 1]; } +/**********************************/ +void BASE_SCREEN::SetLastGrid( void ) +/**********************************/ -/**********************************/ -void BASE_SCREEN::SetLastGrid(void) -/**********************************/ /* ajuste le coeff de grille au max -*/ + */ { - if ( m_GridList == NULL ) return; - m_Grid = m_GridList[0]; + if( m_GridList == NULL ) + return; + m_Grid = m_GridList[0]; } /*****************************************/ -void BASE_SCREEN::ClearUndoRedoList(void) +void BASE_SCREEN::ClearUndoRedoList( void ) /*****************************************/ + /* free the undo and the redo lists -*/ + */ { -EDA_BaseStruct *nextitem; - - while ( m_UndoList ) - { - nextitem = m_UndoList->Pnext; - delete m_UndoList; - m_UndoList = nextitem; - } - - while ( m_RedoList ) - { - nextitem = m_RedoList->Pnext; - delete m_RedoList; - m_RedoList = nextitem; - } - + EDA_BaseStruct* nextitem; + + while( m_UndoList ) + { + nextitem = m_UndoList->Pnext; + delete m_UndoList; + m_UndoList = nextitem; + } + + while( m_RedoList ) + { + nextitem = m_RedoList->Pnext; + delete m_RedoList; + m_RedoList = nextitem; + } } + /***********************************************************/ -void BASE_SCREEN::AddItemToUndoList(EDA_BaseStruct * newitem) +void BASE_SCREEN::AddItemToUndoList( EDA_BaseStruct* newitem ) /************************************************************/ + /* Put newitem in head of undo list - Deletes olds items if > count max. -*/ + * Deletes olds items if > count max. + */ { -int ii; -EDA_BaseStruct * item, *nextitem; - - if ( newitem == NULL ) return; - - newitem->Pnext = m_UndoList; - m_UndoList = newitem; + int ii; + EDA_BaseStruct* item, * nextitem; - /* Free first items, if count max reached */ - for ( ii = 0, item = m_UndoList; ii < m_UndoRedoCountMax; ii++ ) - { - if ( item->Pnext == NULL ) return; - item = item->Pnext; - } - - if ( item == NULL ) return; - - nextitem = item->Pnext; - item->Pnext = NULL; // Set end of chain - - // Delete the extra items - for(item = nextitem ; item != NULL; item = nextitem ) - { - nextitem = item->Pnext; - delete item; - } - + if( newitem == NULL ) + return; + + newitem->Pnext = m_UndoList; + m_UndoList = newitem; + + /* Free first items, if count max reached */ + for( ii = 0, item = m_UndoList; ii < m_UndoRedoCountMax; ii++ ) + { + if( item->Pnext == NULL ) + return; + item = item->Pnext; + } + + if( item == NULL ) + return; + + nextitem = item->Pnext; + item->Pnext = NULL; // Set end of chain + + // Delete the extra items + for( item = nextitem; item != NULL; item = nextitem ) + { + nextitem = item->Pnext; + delete item; + } } + /***********************************************************/ -void BASE_SCREEN::AddItemToRedoList(EDA_BaseStruct * newitem) +void BASE_SCREEN::AddItemToRedoList( EDA_BaseStruct* newitem ) /***********************************************************/ { -int ii; -EDA_BaseStruct * item, *nextitem; - - if ( newitem == NULL ) return; - - newitem->Pnext = m_RedoList; - m_RedoList = newitem; - /* Free first items, if count max reached */ - for ( ii = 0, item = m_RedoList; ii < m_UndoRedoCountMax; ii++ ) - { - if ( item->Pnext == NULL ) break; - item = item->Pnext; - } - - if ( item == NULL ) return; - - nextitem = item->Pnext; - item->Pnext = NULL; // Set end of chain - - // Delete the extra items - for(item = nextitem ; item != NULL; item = nextitem ) - { - nextitem = item->Pnext; - delete item; - } - + int ii; + EDA_BaseStruct* item, * nextitem; + + if( newitem == NULL ) + return; + + newitem->Pnext = m_RedoList; + m_RedoList = newitem; + /* Free first items, if count max reached */ + for( ii = 0, item = m_RedoList; ii < m_UndoRedoCountMax; ii++ ) + { + if( item->Pnext == NULL ) + break; + item = item->Pnext; + } + + if( item == NULL ) + return; + + nextitem = item->Pnext; + item->Pnext = NULL; // Set end of chain + + // Delete the extra items + for( item = nextitem; item != NULL; item = nextitem ) + { + nextitem = item->Pnext; + delete item; + } } + /*****************************************************/ -EDA_BaseStruct * BASE_SCREEN::GetItemFromUndoList(void) +EDA_BaseStruct* BASE_SCREEN::GetItemFromUndoList( void ) /*****************************************************/ { -EDA_BaseStruct * item = m_UndoList; + EDA_BaseStruct* item = m_UndoList; - if ( item ) m_UndoList = item->Pnext; - return item; + if( item ) + m_UndoList = item->Pnext; + return item; } + /******************************************************/ -EDA_BaseStruct * BASE_SCREEN::GetItemFromRedoList(void) +EDA_BaseStruct* BASE_SCREEN::GetItemFromRedoList( void ) /******************************************************/ { -EDA_BaseStruct * item = m_RedoList; - - if ( item ) m_RedoList = item->Pnext; - return item; + EDA_BaseStruct* item = m_RedoList; + + if( item ) + m_RedoList = item->Pnext; + return item; } + + +EDA_BaseStruct* BASE_SCREEN::GetCurItem() +{ + return m_CurrentItem; +} + +void BASE_SCREEN::SetCurItem( EDA_BaseStruct* aCurItem ) +{ + m_CurrentItem = aCurItem; +} diff --git a/common/block_commande.cpp b/common/block_commande.cpp index e7ccc5e7ea..363de56ae2 100644 --- a/common/block_commande.cpp +++ b/common/block_commande.cpp @@ -1,9 +1,9 @@ - /****************************************************/ - /* Routines de gestion des commandes sur blocks */ - /* (section commune eeschema/pcbnew... */ - /****************************************************/ +/****************************************************/ +/* Routines de gestion des commandes sur blocks */ +/* (section commune eeschema/pcbnew... */ +/****************************************************/ - /* Fichier common.cpp */ +/* Fichier common.cpp */ #include "fctsys.h" #include "gr_basic.h" @@ -12,274 +12,285 @@ #include "macros.h" - /*******************/ - /* DrawBlockStruct */ - /*******************/ +/*******************/ +/* DrawBlockStruct */ +/*******************/ /****************************************************************************/ -DrawBlockStruct::DrawBlockStruct(void): - EDA_BaseStruct(BLOCK_LOCATE_STRUCT_TYPE), EDA_Rect() +DrawBlockStruct::DrawBlockStruct( void ) : + EDA_BaseStruct( BLOCK_LOCATE_STRUCT_TYPE ) + , EDA_Rect() /****************************************************************************/ { - m_State = STATE_NO_BLOCK; /* Etat (enum BlockState) du block */ - m_Command = BLOCK_IDLE; /* Type (enum CmdBlockType) d'operation */ - m_BlockDrawStruct = NULL; /* pointeur sur la structure */ - m_Color = BROWN; + m_State = STATE_NO_BLOCK; /* Etat (enum BlockState) du block */ + m_Command = BLOCK_IDLE; /* Type (enum CmdBlockType) d'operation */ + m_BlockDrawStruct = NULL; /* pointeur sur la structure */ + m_Color = BROWN; } /****************************************/ -DrawBlockStruct::~DrawBlockStruct(void) +DrawBlockStruct::~DrawBlockStruct( void ) /****************************************/ { } - /***************************************************************/ -void DrawBlockStruct::SetMessageBlock(WinEDA_DrawFrame * frame) +void DrawBlockStruct::SetMessageBlock( WinEDA_DrawFrame* frame ) /***************************************************************/ + /* - Print block command message (Block move, Block copy ...) in status bar -*/ -{ -wxString msg; - - switch(m_Command) - { - case BLOCK_IDLE: - break; - - case BLOCK_MOVE: /* Move */ - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ - msg = _("Block Move"); - break; - - case BLOCK_DRAG: /* Drag */ - msg = _("Block Drag"); - break; - - case BLOCK_COPY: /* Copy */ - msg = _("Block Copy"); - break; - - case BLOCK_DELETE: /* Delete */ - msg = _("Block Delete"); - break; - - case BLOCK_SAVE: /* Save */ - msg = _("Block Save"); - break; - - case BLOCK_PASTE: - msg = _("Block Paste"); - break; - - case BLOCK_ZOOM: /* Window Zoom */ - msg = _("Win Zoom"); - break; - - case BLOCK_ROTATE: /* Rotate 90 deg */ - msg = _("Block Rotate"); - break; - - case BLOCK_INVERT: /* Flip */ - msg = _("Block Invert"); - break; - - case BLOCK_MIRROR_X: - case BLOCK_MIRROR_Y: /* mirror */ - msg = _("Block Mirror"); - break; - - case BLOCK_ABORT: - break; - - default: - msg = wxT("????"); - break; - } - - frame->DisplayToolMsg(msg); -} - - -/**************************************************************/ -void DrawBlockStruct::Draw(WinEDA_DrawPanel * panel, wxDC * DC) -/**************************************************************/ -{ - int w = GetWidth()/panel->GetZoom(); - int h = GetHeight()/panel->GetZoom(); - if ( w == 0 || h == 0 ) - GRLine(&panel->m_ClipBox, DC, GetX(), GetY(), - GetRight(), GetBottom(), 0, m_Color); - else - GRRect(&panel->m_ClipBox, DC, GetX(), GetY(), - GetRight(), GetBottom(), 0, m_Color); -} - -/*************************************************************************/ -bool WinEDA_DrawFrame::HandleBlockBegin(wxDC * DC, int key, - const wxPoint & startpos) -/*************************************************************************/ -/* First command block function: - Init the Block infos: command type, initial position, and other variables.. -*/ -{ -DrawBlockStruct * Block = & GetScreen()->BlockLocate; - - if ( (Block->m_Command != BLOCK_IDLE) || - ( Block->m_State != STATE_NO_BLOCK) ) - return FALSE; - - Block->m_Flags = 0; - Block->m_Command = (CmdBlockType) ReturnBlockCommand(key); - if ( Block->m_Command == 0 ) - return FALSE; - - switch(Block->m_Command) - { - case BLOCK_IDLE: break; - - case BLOCK_MOVE: /* Move */ - case BLOCK_DRAG: /* Drag */ - case BLOCK_COPY: /* Copy */ - case BLOCK_DELETE: /* Delete */ - case BLOCK_SAVE: /* Save */ - case BLOCK_ROTATE: /* Rotate 90 deg */ - case BLOCK_INVERT: /* Flip */ - case BLOCK_ZOOM: /* Window Zoom */ - case BLOCK_MIRROR_X: - case BLOCK_MIRROR_Y: /* mirror */ - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ - InitBlockLocateDatas(DrawPanel,startpos); - break; - - case BLOCK_PASTE: - InitBlockLocateDatas(DrawPanel,startpos); - Block->m_BlockLastCursorPosition.x = 0; - Block->m_BlockLastCursorPosition.y = 0; - InitBlockPasteInfos(); - if( Block->m_BlockDrawStruct == NULL ) /* No data to paste */ - { - DisplayError(this, wxT("No Block to paste"), 20); - GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; - DrawPanel->ManageCurseur = NULL; - return TRUE; - } - if ( DrawPanel->ManageCurseur == NULL ) - { - Block->m_BlockDrawStruct = NULL; - DisplayError(this, - wxT("WinEDA_DrawFrame::HandleBlockBegin() Err: ManageCurseur NULL")); - return TRUE; - } - Block->m_State = STATE_BLOCK_MOVE; - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - break; - - default: - { - wxString msg; - msg << wxT("WinEDA_DrawFrame::HandleBlockBegin() error: Unknown command ") << Block->m_Command; - DisplayError( this, msg ); - } - break; - } - - Block->SetMessageBlock(this); - return TRUE; -} - - -/******************************************************************/ -void AbortBlockCurrentCommand(WinEDA_DrawPanel * Panel, wxDC * DC) -/******************************************************************/ -/* - Cancel Current block operation. -*/ -{ -BASE_SCREEN * screen = Panel->GetScreen(); - - if( Panel->ManageCurseur) /* Erase current drawing on screen */ - { - Panel->ManageCurseur(Panel,DC, FALSE); /* Efface dessin fantome */ - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; - screen->m_CurrentItem = NULL; - - /* Delete the picked wrapper if this is a picked list. */ - if( (screen->BlockLocate.m_Command != BLOCK_PASTE) && - screen->BlockLocate.m_BlockDrawStruct ) - { - if(screen->BlockLocate.m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) - { - DrawPickedStruct * PickedList; - PickedList = (DrawPickedStruct*)screen->BlockLocate.m_BlockDrawStruct; - PickedList->DeleteWrapperList(); - } - screen->BlockLocate.m_BlockDrawStruct = NULL; - } - } - - screen->BlockLocate.m_Flags = 0; - screen->BlockLocate.m_State = STATE_NO_BLOCK; - - screen->BlockLocate.m_Command = BLOCK_ABORT; - Panel->m_Parent->HandleBlockEnd(DC); - - screen->BlockLocate.m_Command = BLOCK_IDLE; - Panel->m_Parent->DisplayToolMsg(wxEmptyString); -} - -/*************************************************************************/ -void InitBlockLocateDatas( WinEDA_DrawPanel * Panel,const wxPoint & startpos ) -/*************************************************************************/ -/* - Init the initial values of a BlockLocate, before starting a block command -*/ -{ -BASE_SCREEN * screen = Panel->GetScreen(); - screen->BlockLocate.m_State = STATE_BLOCK_INIT; - screen->BlockLocate.SetOrigin(startpos); - screen->BlockLocate.SetSize(wxSize(0,0)); - screen->BlockLocate.Pnext = NULL; - screen->BlockLocate.m_BlockDrawStruct = NULL; - Panel->ManageCurseur = DrawAndSizingBlockOutlines; - Panel->ForceCloseManageCurseur = AbortBlockCurrentCommand; -} - -/********************************************************************************/ -void DrawAndSizingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase ) -/********************************************************************************/ -/* Redraw the outlines of the block which shows the search area for block commands - The first point of the rectangle showing the area is initialised - by InitBlockLocateDatas(). - The other point of the rectangle is the mouse cursor + * Print block command message (Block move, Block copy ...) in status bar */ { -DrawBlockStruct * PtBlock; + wxString msg; - PtBlock = &panel->GetScreen()->BlockLocate; + switch( m_Command ) + { + case BLOCK_IDLE: + break; - PtBlock->m_MoveVector = wxPoint(0,0); + case BLOCK_MOVE: /* Move */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + msg = _( "Block Move" ); + break; - GRSetDrawMode(DC, g_XorMode); + case BLOCK_DRAG: /* Drag */ + msg = _( "Block Drag" ); + break; - /* Effacement ancien cadre */ - if( erase ) PtBlock->Draw(panel, DC); + case BLOCK_COPY: /* Copy */ + msg = _( "Block Copy" ); + break; - PtBlock->m_BlockLastCursorPosition = panel->GetScreen()->m_Curseur; - PtBlock->SetEnd(panel->GetScreen()->m_Curseur); + case BLOCK_DELETE: /* Delete */ + msg = _( "Block Delete" ); + break; - PtBlock->Draw(panel, DC); + case BLOCK_SAVE: /* Save */ + msg = _( "Block Save" ); + break; - if ( PtBlock->m_State == STATE_BLOCK_INIT ) - { - if ( PtBlock->GetWidth() || PtBlock->GetHeight() ) - /* 2ieme point existant: le rectangle n'est pas de surface nulle */ - PtBlock->m_State = STATE_BLOCK_END; - } + case BLOCK_PASTE: + msg = _( "Block Paste" ); + break; + + case BLOCK_ZOOM: /* Window Zoom */ + msg = _( "Win Zoom" ); + break; + + case BLOCK_ROTATE: /* Rotate 90 deg */ + msg = _( "Block Rotate" ); + break; + + case BLOCK_INVERT: /* Flip */ + msg = _( "Block Invert" ); + break; + + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: /* mirror */ + msg = _( "Block Mirror" ); + break; + + case BLOCK_ABORT: + break; + + default: + msg = wxT( "????" ); + break; + } + + frame->DisplayToolMsg( msg ); } +/**************************************************************/ +void DrawBlockStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC ) +/**************************************************************/ +{ + int w = GetWidth() / panel->GetZoom(); + int h = GetHeight() / panel->GetZoom(); + + if( w == 0 || h == 0 ) + GRLine( &panel->m_ClipBox, DC, GetX(), GetY(), + GetRight(), GetBottom(), 0, m_Color ); + else + GRRect( &panel->m_ClipBox, DC, GetX(), GetY(), + GetRight(), GetBottom(), 0, m_Color ); +} + + +/*************************************************************************/ +bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key, + const wxPoint& startpos ) +/*************************************************************************/ + +/* First command block function: + * Init the Block infos: command type, initial position, and other variables.. + */ +{ + DrawBlockStruct* Block = & GetScreen()->BlockLocate; + + if( (Block->m_Command != BLOCK_IDLE) + || ( Block->m_State != STATE_NO_BLOCK) ) + return FALSE; + + Block->m_Flags = 0; + Block->m_Command = (CmdBlockType) ReturnBlockCommand( key ); + if( Block->m_Command == 0 ) + return FALSE; + + switch( Block->m_Command ) + { + case BLOCK_IDLE: + break; + + case BLOCK_MOVE: /* Move */ + case BLOCK_DRAG: /* Drag */ + case BLOCK_COPY: /* Copy */ + case BLOCK_DELETE: /* Delete */ + case BLOCK_SAVE: /* Save */ + case BLOCK_ROTATE: /* Rotate 90 deg */ + case BLOCK_INVERT: /* Flip */ + case BLOCK_ZOOM: /* Window Zoom */ + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: /* mirror */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + InitBlockLocateDatas( DrawPanel, startpos ); + break; + + case BLOCK_PASTE: + InitBlockLocateDatas( DrawPanel, startpos ); + Block->m_BlockLastCursorPosition.x = 0; + Block->m_BlockLastCursorPosition.y = 0; + InitBlockPasteInfos(); + if( Block->m_BlockDrawStruct == NULL ) /* No data to paste */ + { + DisplayError( this, wxT( "No Block to paste" ), 20 ); + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + DrawPanel->ManageCurseur = NULL; + return TRUE; + } + if( DrawPanel->ManageCurseur == NULL ) + { + Block->m_BlockDrawStruct = NULL; + DisplayError( this, + wxT( "WinEDA_DrawFrame::HandleBlockBegin() Err: ManageCurseur NULL" ) ); + return TRUE; + } + Block->m_State = STATE_BLOCK_MOVE; + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + break; + + default: + { + wxString msg; + msg << wxT( "WinEDA_DrawFrame::HandleBlockBegin() error: Unknown command " ) << + Block->m_Command; + DisplayError( this, msg ); + } + break; + } + + Block->SetMessageBlock( this ); + return TRUE; +} + + +/******************************************************************/ +void AbortBlockCurrentCommand( WinEDA_DrawPanel* Panel, wxDC* DC ) +/******************************************************************/ + +/* + * Cancel Current block operation. + */ +{ + BASE_SCREEN* screen = Panel->GetScreen(); + + if( Panel->ManageCurseur ) /* Erase current drawing on screen */ + { + Panel->ManageCurseur( Panel, DC, FALSE ); /* Efface dessin fantome */ + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + screen->SetCurItem( NULL ); + + /* Delete the picked wrapper if this is a picked list. */ + if( (screen->BlockLocate.m_Command != BLOCK_PASTE) + && screen->BlockLocate.m_BlockDrawStruct ) + { + if( screen->BlockLocate.m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE ) + { + DrawPickedStruct* PickedList; + PickedList = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + PickedList->DeleteWrapperList(); + } + screen->BlockLocate.m_BlockDrawStruct = NULL; + } + } + + screen->BlockLocate.m_Flags = 0; + screen->BlockLocate.m_State = STATE_NO_BLOCK; + + screen->BlockLocate.m_Command = BLOCK_ABORT; + Panel->m_Parent->HandleBlockEnd( DC ); + + screen->BlockLocate.m_Command = BLOCK_IDLE; + Panel->m_Parent->DisplayToolMsg( wxEmptyString ); +} + + +/*************************************************************************/ +void InitBlockLocateDatas( WinEDA_DrawPanel* Panel, const wxPoint& startpos ) +/*************************************************************************/ + +/* + * Init the initial values of a BlockLocate, before starting a block command + */ +{ + BASE_SCREEN* screen = Panel->GetScreen(); + + screen->BlockLocate.m_State = STATE_BLOCK_INIT; + screen->BlockLocate.SetOrigin( startpos ); + screen->BlockLocate.SetSize( wxSize( 0, 0 ) ); + screen->BlockLocate.Pnext = NULL; + screen->BlockLocate.m_BlockDrawStruct = NULL; + Panel->ManageCurseur = DrawAndSizingBlockOutlines; + Panel->ForceCloseManageCurseur = AbortBlockCurrentCommand; +} + + +/********************************************************************************/ +void DrawAndSizingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) +/********************************************************************************/ + +/* Redraw the outlines of the block which shows the search area for block commands + * The first point of the rectangle showing the area is initialised + * by InitBlockLocateDatas(). + * The other point of the rectangle is the mouse cursor + */ +{ + DrawBlockStruct* PtBlock; + + PtBlock = &panel->GetScreen()->BlockLocate; + + PtBlock->m_MoveVector = wxPoint( 0, 0 ); + + GRSetDrawMode( DC, g_XorMode ); + + /* Effacement ancien cadre */ + if( erase ) + PtBlock->Draw( panel, DC ); + + PtBlock->m_BlockLastCursorPosition = panel->GetScreen()->m_Curseur; + PtBlock->SetEnd( panel->GetScreen()->m_Curseur ); + + PtBlock->Draw( panel, DC ); + + if( PtBlock->m_State == STATE_BLOCK_INIT ) + { + if( PtBlock->GetWidth() || PtBlock->GetHeight() ) + /* 2ieme point existant: le rectangle n'est pas de surface nulle */ + PtBlock->m_State = STATE_BLOCK_END; + } +} diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 50b2df4f20..5c3ff75905 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -18,498 +18,531 @@ /* Fonctions exportees */ /* Fonctions Locales */ -static EDA_BaseStruct * CopyStruct(WinEDA_DrawPanel * panel, wxDC * DC, BASE_SCREEN * screen, - EDA_BaseStruct *DrawStruct); -static void CollectStructsToDrag(SCH_SCREEN * screen); -static void AddPickedItem(SCH_SCREEN * screen, int px, int py ); -static LibEDA_BaseStruct * GetNextPinPosition( EDA_SchComponentStruct * DrawLibItem, - int * px, int * py ); -static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); -static EDA_BaseStruct * SaveStructListForPaste(EDA_BaseStruct *DrawStruct); -static bool MirrorStruct(WinEDA_DrawPanel * panel, wxDC * DC, EDA_BaseStruct *DrawStruct, wxPoint & Center); -static void MirrorOneStruct(EDA_BaseStruct *DrawStruct, wxPoint & Center); +static EDA_BaseStruct* CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* screen, + EDA_BaseStruct* DrawStruct ); +static void CollectStructsToDrag( SCH_SCREEN* screen ); +static void AddPickedItem( SCH_SCREEN* screen, int px, int py ); +static LibEDA_BaseStruct* GetNextPinPosition( EDA_SchComponentStruct* DrawLibItem, + int* px, int* py ); +static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); +static EDA_BaseStruct* SaveStructListForPaste( EDA_BaseStruct* DrawStruct ); +static bool MirrorStruct( WinEDA_DrawPanel* panel, wxDC* DC, + EDA_BaseStruct* DrawStruct, wxPoint& Center ); +static void MirrorOneStruct( EDA_BaseStruct* DrawStruct, wxPoint& Center ); /*************************************************************************/ -int WinEDA_SchematicFrame::ReturnBlockCommand(int key) +int WinEDA_SchematicFrame::ReturnBlockCommand( int key ) /*************************************************************************/ + /* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to - the key (ALT, SHIFT ALT ..) -*/ + * the key (ALT, SHIFT ALT ..) + */ { -int cmd; + int cmd; - switch ( key ) - { - default: - cmd = key & 0xFF; - break; + switch( key ) + { + default: + cmd = key & 0xFF; + break; - case 0: - cmd = BLOCK_MOVE; - break; + case 0: + cmd = BLOCK_MOVE; + break; - case GR_KB_ALT: - case GR_KB_SHIFT: - cmd = BLOCK_COPY; - break; + case GR_KB_ALT: + case GR_KB_SHIFT: + cmd = BLOCK_COPY; + break; - case GR_KB_CTRL: - cmd = BLOCK_DRAG; - break; + case GR_KB_CTRL: + cmd = BLOCK_DRAG; + break; - case GR_KB_SHIFTCTRL: - cmd = BLOCK_DELETE; - break; + case GR_KB_SHIFTCTRL: + cmd = BLOCK_DELETE; + break; - case MOUSE_MIDDLE: - cmd = BLOCK_ZOOM; - break; - } - return cmd; + case MOUSE_MIDDLE: + cmd = BLOCK_ZOOM; + break; + } + + return cmd; } + /*************************************************/ void WinEDA_SchematicFrame::InitBlockPasteInfos() /*************************************************/ + /* Init the parameters used by the block paste command -*/ + */ { -DrawBlockStruct * block = & GetScreen()->BlockLocate; + DrawBlockStruct* block = & GetScreen()->BlockLocate; - block->m_BlockDrawStruct = g_BlockSaveDataList; - DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + block->m_BlockDrawStruct = g_BlockSaveDataList; + DrawPanel->ManageCurseur = DrawMovingBlockOutlines; } +/******************************************************/ +void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) +/******************************************************/ -/******************************************************/ -void WinEDA_SchematicFrame::HandleBlockPlace(wxDC * DC) -/******************************************************/ /* Routine to handle the BLOCK PLACE commande - Last routine for block operation for: - - block move & drag - - block copie & paste -*/ + * Last routine for block operation for: + * - block move & drag + * - block copie & paste + */ { -bool err = FALSE; -DrawBlockStruct * block = & GetScreen()->BlockLocate; -EDA_BaseStruct * NewStruct = NULL; + bool err = FALSE; + DrawBlockStruct* block = & GetScreen()->BlockLocate; - if(DrawPanel->ManageCurseur == NULL) - { - err = TRUE; - DisplayError(this, wxT("HandleBlockPLace() : ManageCurseur = NULL") ); - } + EDA_BaseStruct* NewStruct = NULL; - if(block->m_BlockDrawStruct == NULL) - { - wxString msg; - err = TRUE; - msg.Printf( wxT("HandleBlockPLace() : m_BlockDrawStruct = NULL (cmd %d, state %d)"), - block->m_Command, block->m_State); - DisplayError(this, msg ); - } + if( DrawPanel->ManageCurseur == NULL ) + { + err = TRUE; + DisplayError( this, wxT( "HandleBlockPLace() : ManageCurseur = NULL" ) ); + } - block->m_State = STATE_BLOCK_STOP; + if( block->m_BlockDrawStruct == NULL ) + { + wxString msg; + err = TRUE; + msg.Printf( wxT( "HandleBlockPLace() : m_BlockDrawStruct = NULL (cmd %d, state %d)" ), + block->m_Command, block->m_State ); + DisplayError( this, msg ); + } - switch(block->m_Command ) - { - case BLOCK_IDLE: - err = TRUE; - break; - case BLOCK_DRAG: /* Drag */ - case BLOCK_MOVE: /* Move */ - if ( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + block->m_State = STATE_BLOCK_STOP; - SaveCopyInUndoList(block->m_BlockDrawStruct, IS_CHANGED); + switch( block->m_Command ) + { + case BLOCK_IDLE: + err = TRUE; + break; - MoveStruct(DrawPanel, DC, block->m_BlockDrawStruct); - block->m_BlockDrawStruct = NULL; - break; + case BLOCK_DRAG: /* Drag */ + case BLOCK_MOVE: /* Move */ + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); - case BLOCK_COPY: /* Copy */ - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ - if ( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + SaveCopyInUndoList( block->m_BlockDrawStruct, IS_CHANGED ); - NewStruct = CopyStruct(DrawPanel, DC, GetScreen(), block->m_BlockDrawStruct); + MoveStruct( DrawPanel, DC, block->m_BlockDrawStruct ); + block->m_BlockDrawStruct = NULL; + break; - SaveCopyInUndoList(NewStruct, - (block->m_Command == BLOCK_PRESELECT_MOVE) ? IS_CHANGED : IS_NEW); + case BLOCK_COPY: /* Copy */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); - block->m_BlockDrawStruct = NULL; - break; + NewStruct = CopyStruct( DrawPanel, DC, GetScreen(), block->m_BlockDrawStruct ); - case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */ - if ( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - PasteStruct(DC); - block->m_BlockDrawStruct = NULL; - break; + SaveCopyInUndoList( NewStruct, + (block->m_Command == BLOCK_PRESELECT_MOVE) ? IS_CHANGED : IS_NEW ); - case BLOCK_ZOOM: // Handled by HandleBlockEnd() - case BLOCK_DELETE: - case BLOCK_SAVE: - case BLOCK_ROTATE: - case BLOCK_MIRROR_X: - case BLOCK_MIRROR_Y: - case BLOCK_INVERT: - case BLOCK_ABORT: - case BLOCK_SELECT_ITEMS_ONLY: - break; - } + block->m_BlockDrawStruct = NULL; + break; - GetScreen()->SetModify(); + case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */ + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + PasteStruct( DC ); + block->m_BlockDrawStruct = NULL; + break; - /* clear struct.m_Flags */ - EDA_BaseStruct * Struct; - for(Struct = GetScreen()->EEDrawList; Struct != NULL; Struct=Struct->Pnext) - Struct->m_Flags = 0; + case BLOCK_ZOOM: // Handled by HandleBlockEnd() + case BLOCK_DELETE: + case BLOCK_SAVE: + case BLOCK_ROTATE: + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: + case BLOCK_INVERT: + case BLOCK_ABORT: + case BLOCK_SELECT_ITEMS_ONLY: + break; + } - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - block->m_Flags = 0; - block->m_State = STATE_NO_BLOCK; - block->m_Command = BLOCK_IDLE; - GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetModify(); - TestDanglingEnds(GetScreen()->EEDrawList, DC); + /* clear struct.m_Flags */ + EDA_BaseStruct* Struct; + for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Pnext ) + Struct->m_Flags = 0; - if ( block->m_BlockDrawStruct ) - { - DisplayError(this, wxT("HandleBlockPLace() error: DrawStruct != Null") ); - block->m_BlockDrawStruct = NULL; - } + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + block->m_Flags = 0; + block->m_State = STATE_NO_BLOCK; + block->m_Command = BLOCK_IDLE; + GetScreen()->SetCurItem( NULL ); - SetToolID(m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); + TestDanglingEnds( GetScreen()->EEDrawList, DC ); + + if( block->m_BlockDrawStruct ) + { + DisplayError( this, wxT( "HandleBlockPLace() error: DrawStruct != Null" ) ); + block->m_BlockDrawStruct = NULL; + } + + SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); } + /****************************************************/ -int WinEDA_SchematicFrame::HandleBlockEnd(wxDC * DC) +int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) /****************************************************/ + /* Routine de gestion de la commande BLOCK END - retourne : - 0 si aucun composant selectionne - 1 sinon - -1 si commande termin�e et composants trouv�s (block delete, block save) -*/ + * retourne : + * 0 si aucun composant selectionne + * 1 sinon + * -1 si commande termin�e et composants trouv�s (block delete, block save) + */ { -int ii = 0; -bool zoom_command = FALSE; -DrawBlockStruct * block = & GetScreen()->BlockLocate; + int ii = 0; + bool zoom_command = FALSE; + DrawBlockStruct* block = & GetScreen()->BlockLocate; - if ( block->m_BlockDrawStruct ) - { - BlockState state = block->m_State; - CmdBlockType command = block->m_Command; - if ( DrawPanel->ForceCloseManageCurseur ) - DrawPanel->ForceCloseManageCurseur(DrawPanel, DC); - block->m_State = state; - block->m_Command = command; - DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines; - DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand; - GetScreen()->m_Curseur.x = block->GetRight(); - GetScreen()->m_Curseur.y = block->GetBottom(); - if ( block->m_Command != BLOCK_ABORT ) - DrawPanel->MouseToCursorSchema(); - } + if( block->m_BlockDrawStruct ) + { + BlockState state = block->m_State; + CmdBlockType command = block->m_Command; + if( DrawPanel->ForceCloseManageCurseur ) + DrawPanel->ForceCloseManageCurseur( DrawPanel, DC ); + block->m_State = state; + block->m_Command = command; + DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines; + DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand; + GetScreen()->m_Curseur.x = block->GetRight(); + GetScreen()->m_Curseur.y = block->GetBottom(); + if( block->m_Command != BLOCK_ABORT ) + DrawPanel->MouseToCursorSchema(); + } - if(DrawPanel->ManageCurseur != NULL) - switch( block->m_Command ) - { - case BLOCK_IDLE: - DisplayError(this, wxT("Error in HandleBlockPLace()") ); - break; + if( DrawPanel->ManageCurseur != NULL ) + switch( block->m_Command ) + { + case BLOCK_IDLE: + DisplayError( this, wxT( "Error in HandleBlockPLace()" ) ); + break; - case BLOCK_DRAG: /* Drag */ - BreakSegmentOnJunction(GetScreen() ); - case BLOCK_MOVE: /* Move */ - case BLOCK_COPY: /* Copy */ - block->m_BlockDrawStruct = - PickStruct(GetScreen()->BlockLocate, GetScreen()->EEDrawList, SEARCHALL); - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ - if( block->m_BlockDrawStruct != NULL) - { - ii = 1; - CollectStructsToDrag(GetScreen()); - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - DrawPanel->ManageCurseur = DrawMovingBlockOutlines; - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - block->m_State = STATE_BLOCK_MOVE; - } - else - { - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - } - break; + case BLOCK_DRAG: /* Drag */ + BreakSegmentOnJunction( GetScreen() ); - case BLOCK_DELETE: /* Delete */ - block->m_BlockDrawStruct = - PickStruct(GetScreen()->BlockLocate, - GetScreen()->EEDrawList, SEARCHALL); - DrawAndSizingBlockOutlines(DrawPanel, DC, FALSE); - if( block->m_BlockDrawStruct != NULL) - { - ii = -1; - DeleteStruct(DrawPanel, DC, block->m_BlockDrawStruct); - GetScreen()->SetModify(); - } - block->m_BlockDrawStruct = NULL; - TestDanglingEnds(GetScreen()->EEDrawList, DC); - break; + case BLOCK_MOVE: /* Move */ + case BLOCK_COPY: /* Copy */ + block->m_BlockDrawStruct = + PickStruct( GetScreen()->BlockLocate, GetScreen()->EEDrawList, SEARCHALL ); - case BLOCK_SAVE: /* Save */ - block->m_BlockDrawStruct = - PickStruct(GetScreen()->BlockLocate, - GetScreen()->EEDrawList, SEARCHALL); - DrawAndSizingBlockOutlines(DrawPanel, DC, FALSE); - if( block->m_BlockDrawStruct != NULL) - { - wxPoint oldpos = GetScreen()->m_Curseur; - GetScreen()->m_Curseur = wxPoint(0,0); - EDA_BaseStruct *DrawStructCopy = - SaveStructListForPaste(block->m_BlockDrawStruct); - PlaceStruct( GetScreen(), DrawStructCopy); - GetScreen()->m_Curseur = oldpos; - ii = -1; - } - block->m_BlockDrawStruct = NULL; - break; + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + if( block->m_BlockDrawStruct != NULL ) + { + ii = 1; + CollectStructsToDrag( GetScreen() ); + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + block->m_State = STATE_BLOCK_MOVE; + } + else + { + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + } + break; - case BLOCK_PASTE: - block->m_State = STATE_BLOCK_MOVE; - break; + case BLOCK_DELETE: /* Delete */ + block->m_BlockDrawStruct = + PickStruct( GetScreen()->BlockLocate, + GetScreen()->EEDrawList, SEARCHALL ); + DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); + if( block->m_BlockDrawStruct != NULL ) + { + ii = -1; + DeleteStruct( DrawPanel, DC, block->m_BlockDrawStruct ); + GetScreen()->SetModify(); + } + block->m_BlockDrawStruct = NULL; + TestDanglingEnds( GetScreen()->EEDrawList, DC ); + break; - case BLOCK_INVERT: /* pcbnew only! */ - break; + case BLOCK_SAVE: /* Save */ + block->m_BlockDrawStruct = + PickStruct( GetScreen()->BlockLocate, + GetScreen()->EEDrawList, SEARCHALL ); + DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); + if( block->m_BlockDrawStruct != NULL ) + { + wxPoint oldpos = GetScreen()->m_Curseur; + GetScreen()->m_Curseur = wxPoint( 0, 0 ); + EDA_BaseStruct* DrawStructCopy = + SaveStructListForPaste( block->m_BlockDrawStruct ); + PlaceStruct( GetScreen(), DrawStructCopy ); + GetScreen()->m_Curseur = oldpos; + ii = -1; + } + block->m_BlockDrawStruct = NULL; + break; - case BLOCK_ROTATE: - case BLOCK_MIRROR_X: - case BLOCK_MIRROR_Y: - break; + case BLOCK_PASTE: + block->m_State = STATE_BLOCK_MOVE; + break; - case BLOCK_ZOOM: /* Window Zoom */ - zoom_command = TRUE; - break; + case BLOCK_INVERT: /* pcbnew only! */ + break; - case BLOCK_SELECT_ITEMS_ONLY: /* Not used */ - case BLOCK_ABORT: /* not executed here */ - break; - } + case BLOCK_ROTATE: + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: + break; - if ( block->m_Command == BLOCK_ABORT ) - { /* clear struct.m_Flags */ - EDA_BaseStruct * Struct; - for(Struct = GetScreen()->EEDrawList; Struct != NULL; Struct=Struct->Pnext) - Struct->m_Flags = 0; - } + case BLOCK_ZOOM: /* Window Zoom */ + zoom_command = TRUE; + break; - if ( ii <= 0 ) - { - block->m_Flags = 0; - block->m_State = STATE_NO_BLOCK; - block->m_Command = BLOCK_IDLE; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->m_CurrentItem = NULL; - SetToolID(m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); - } + case BLOCK_SELECT_ITEMS_ONLY: /* Not used */ + case BLOCK_ABORT: /* not executed here */ + break; + } - if ( zoom_command) - Window_Zoom( GetScreen()->BlockLocate); + if( block->m_Command == BLOCK_ABORT ) + { /* clear struct.m_Flags */ + EDA_BaseStruct* Struct; + for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Pnext ) + Struct->m_Flags = 0; + } - return(ii); + if( ii <= 0 ) + { + block->m_Flags = 0; + block->m_State = STATE_NO_BLOCK; + block->m_Command = BLOCK_IDLE; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->SetCurItem( NULL ); + SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); + } + + if( zoom_command ) + Window_Zoom( GetScreen()->BlockLocate ); + + return ii; } /***********************************************************************/ -void WinEDA_SchematicFrame::HandleBlockEndByPopUp(int Command, wxDC * DC) +void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) /***********************************************************************/ + /* Routine de gestion de la commande BLOCK END by PopUp - Appelee apres HandleBlockEnd. - A partir de la commande bloc move, peut executer une commande autre que bloc move. -*/ + * Appelee apres HandleBlockEnd. + * A partir de la commande bloc move, peut executer une commande autre que bloc move. + */ { -int ii = 0; -DrawBlockStruct * block = & GetScreen()->BlockLocate; + int ii = 0; + DrawBlockStruct* block = & GetScreen()->BlockLocate; - if( block->m_Command != BLOCK_MOVE ) return; - if( Command == BLOCK_MOVE ) return; + if( block->m_Command != BLOCK_MOVE ) + return; + if( Command == BLOCK_MOVE ) + return; - block->m_Command = (CmdBlockType) Command; - block->SetMessageBlock(this); + block->m_Command = (CmdBlockType) Command; + block->SetMessageBlock( this ); - switch( block->m_Command ) - { - case BLOCK_COPY: /* move to copy */ - block->m_State = STATE_BLOCK_MOVE; - ii = 1; - break; + switch( block->m_Command ) + { + case BLOCK_COPY: /* move to copy */ + block->m_State = STATE_BLOCK_MOVE; + ii = 1; + break; - case BLOCK_DRAG: /* move to Drag */ - /* Effacement de la liste des structures de pointage, - qui est devenue erronnee */ - if(DrawPanel->ManageCurseur) - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - if( block->m_BlockDrawStruct ) - { - if(block->m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) - { /* Delete the picked wrapper if this is a picked list. */ - DrawPickedStruct * PickedList; - PickedList = (DrawPickedStruct*)block->m_BlockDrawStruct; - PickedList->DeleteWrapperList(); - } - block->m_BlockDrawStruct = NULL; - } - BreakSegmentOnJunction(GetScreen() ); - block->m_BlockDrawStruct = - PickStruct(GetScreen()->BlockLocate, - GetScreen()->EEDrawList, SEARCHALL); - if( block->m_BlockDrawStruct != NULL) - { - ii = 1; - CollectStructsToDrag(GetScreen()); - if(DrawPanel->ManageCurseur) - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - block->m_State = STATE_BLOCK_MOVE; - } - break; + case BLOCK_DRAG: /* move to Drag */ - case BLOCK_DELETE: /* move to Delete */ - if(DrawPanel->ManageCurseur) - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - if( block->m_BlockDrawStruct != NULL) - { - ii = -1; - DeleteStruct(DrawPanel, DC, block->m_BlockDrawStruct); - GetScreen()->SetModify(); - } - TestDanglingEnds(GetScreen()->EEDrawList, DC); - break; + /* Effacement de la liste des structures de pointage, + * qui est devenue erronnee */ + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + if( block->m_BlockDrawStruct ) + { + if( block->m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE ) + { /* Delete the picked wrapper if this is a picked list. */ + DrawPickedStruct* PickedList; + PickedList = (DrawPickedStruct*) block->m_BlockDrawStruct; + PickedList->DeleteWrapperList(); + } + block->m_BlockDrawStruct = NULL; + } + BreakSegmentOnJunction( GetScreen() ); + block->m_BlockDrawStruct = + PickStruct( GetScreen()->BlockLocate, + GetScreen()->EEDrawList, SEARCHALL ); + if( block->m_BlockDrawStruct != NULL ) + { + ii = 1; + CollectStructsToDrag( GetScreen() ); + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + block->m_State = STATE_BLOCK_MOVE; + } + break; - case BLOCK_SAVE: /* Save */ - if(DrawPanel->ManageCurseur) - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - if( block->m_BlockDrawStruct != NULL) - { - wxPoint oldpos = GetScreen()->m_Curseur; - GetScreen()->m_Curseur = wxPoint(0,0); - EDA_BaseStruct *DrawStructCopy = - SaveStructListForPaste(block->m_BlockDrawStruct); - PlaceStruct( GetScreen(), DrawStructCopy); - GetScreen()->m_Curseur = oldpos; - ii = -1; - } - break; + case BLOCK_DELETE: /* move to Delete */ + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + if( block->m_BlockDrawStruct != NULL ) + { + ii = -1; + DeleteStruct( DrawPanel, DC, block->m_BlockDrawStruct ); + GetScreen()->SetModify(); + } + TestDanglingEnds( GetScreen()->EEDrawList, DC ); + break; - case BLOCK_ZOOM: /* Window Zoom */ - DrawPanel->ForceCloseManageCurseur(DrawPanel, DC); - DrawPanel->SetCursor(DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor); - Window_Zoom( GetScreen()->BlockLocate); - break; + case BLOCK_SAVE: /* Save */ + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + if( block->m_BlockDrawStruct != NULL ) + { + wxPoint oldpos = GetScreen()->m_Curseur; + GetScreen()->m_Curseur = wxPoint( 0, 0 ); + EDA_BaseStruct* DrawStructCopy = + SaveStructListForPaste( block->m_BlockDrawStruct ); + PlaceStruct( GetScreen(), DrawStructCopy ); + GetScreen()->m_Curseur = oldpos; + ii = -1; + } + break; + + case BLOCK_ZOOM: /* Window Zoom */ + DrawPanel->ForceCloseManageCurseur( DrawPanel, DC ); + DrawPanel->SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor ); + Window_Zoom( GetScreen()->BlockLocate ); + break; - case BLOCK_ROTATE: - break; + case BLOCK_ROTATE: + break; - case BLOCK_MIRROR_X: - case BLOCK_MIRROR_Y: - if(DrawPanel->ManageCurseur) - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - if( block->m_BlockDrawStruct != NULL) - { - SaveCopyInUndoList(block->m_BlockDrawStruct, IS_CHANGED); + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + if( block->m_BlockDrawStruct != NULL ) + { + SaveCopyInUndoList( block->m_BlockDrawStruct, IS_CHANGED ); - ii = -1; - /* Compute the mirror centre and put it on grid */ - wxPoint Center = block->Centre(); - PutOnGrid(&Center); - MirrorStruct(DrawPanel, DC, block->m_BlockDrawStruct, Center); - GetScreen()->SetModify(); - } - TestDanglingEnds(GetScreen()->EEDrawList, DC); - break; + ii = -1; + /* Compute the mirror centre and put it on grid */ + wxPoint Center = block->Centre(); + PutOnGrid( &Center ); + MirrorStruct( DrawPanel, DC, block->m_BlockDrawStruct, Center ); + GetScreen()->SetModify(); + } + TestDanglingEnds( GetScreen()->EEDrawList, DC ); + break; - default: - break; - } - - if ( ii <= 0 ) - { - block->m_BlockDrawStruct = NULL; - block->m_Flags = 0; - block->m_State = STATE_NO_BLOCK; - block->m_Command = BLOCK_IDLE; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->m_CurrentItem = NULL; - SetToolID(m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); - } + default: + break; + } + if( ii <= 0 ) + { + block->m_BlockDrawStruct = NULL; + block->m_Flags = 0; + block->m_State = STATE_NO_BLOCK; + block->m_Command = BLOCK_IDLE; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->SetCurItem( NULL ); + SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); + } } /************************************************************************/ -static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, - bool erase ) +static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, + bool erase ) /************************************************************************/ + /* Retrace le contour du block de recherche de structures - L'ensemble du block suit le curseur -*/ + * L'ensemble du block suit le curseur + */ { -DrawBlockStruct * PtBlock; -DrawPickedStruct *PickedList; -BASE_SCREEN * screen = panel->m_Parent->GetScreen(); + DrawBlockStruct* PtBlock; + DrawPickedStruct* PickedList; + BASE_SCREEN* screen = panel->m_Parent->GetScreen(); - PtBlock = &panel->GetScreen()->BlockLocate; - GRSetDrawMode(DC, g_XorMode); + PtBlock = &panel->GetScreen()->BlockLocate; + GRSetDrawMode( DC, g_XorMode ); - /* Effacement ancien cadre */ - if( erase && PtBlock->m_BlockDrawStruct) - { - PtBlock->Offset(PtBlock->m_MoveVector); - PtBlock->Draw(panel, DC); - PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y); + /* Effacement ancien cadre */ + if( erase && PtBlock->m_BlockDrawStruct ) + { + PtBlock->Offset( PtBlock->m_MoveVector ); + PtBlock->Draw( panel, DC ); + PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y ); - /* Effacement ancien affichage */ - if(PtBlock->m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) - { - PickedList = (DrawPickedStruct *) PtBlock->m_BlockDrawStruct; - while (PickedList) - { - DrawStructsInGhost(panel, DC, PickedList->m_PickedStruct, PtBlock->m_MoveVector.x, PtBlock->m_MoveVector.y); - PickedList = (DrawPickedStruct *)PickedList->Pnext; - } - } - else DrawStructsInGhost(panel, DC, PtBlock->m_BlockDrawStruct, PtBlock->m_MoveVector.x, PtBlock->m_MoveVector.y); - } + /* Effacement ancien affichage */ + if( PtBlock->m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE ) + { + PickedList = (DrawPickedStruct*) PtBlock->m_BlockDrawStruct; + while( PickedList ) + { + DrawStructsInGhost( panel, + DC, + PickedList->m_PickedStruct, + PtBlock->m_MoveVector.x, + PtBlock->m_MoveVector.y ); + PickedList = (DrawPickedStruct*) PickedList->Pnext; + } + } + else + DrawStructsInGhost( panel, + DC, + PtBlock->m_BlockDrawStruct, + PtBlock->m_MoveVector.x, + PtBlock->m_MoveVector.y ); + } - /* Redessin nouvel affichage */ + /* Redessin nouvel affichage */ - PtBlock->m_MoveVector.x = screen->m_Curseur.x - PtBlock->m_BlockLastCursorPosition.x; - PtBlock->m_MoveVector.y = screen->m_Curseur.y - PtBlock->m_BlockLastCursorPosition.y; + PtBlock->m_MoveVector.x = screen->m_Curseur.x - PtBlock->m_BlockLastCursorPosition.x; + PtBlock->m_MoveVector.y = screen->m_Curseur.y - PtBlock->m_BlockLastCursorPosition.y; - GRSetDrawMode(DC, g_XorMode); - PtBlock->Offset(PtBlock->m_MoveVector); - PtBlock->Draw(panel, DC); - PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y); + GRSetDrawMode( DC, g_XorMode ); + PtBlock->Offset( PtBlock->m_MoveVector ); + PtBlock->Draw( panel, DC ); + PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y ); - if(PtBlock->m_BlockDrawStruct ) - { - if(PtBlock->m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) - { - PickedList = (DrawPickedStruct *) PtBlock->m_BlockDrawStruct; - while (PickedList) - { - DrawStructsInGhost(panel, DC, PickedList->m_PickedStruct, PtBlock->m_MoveVector.x, PtBlock->m_MoveVector.y); - PickedList = (DrawPickedStruct *)PickedList->Pnext; - } - } - else DrawStructsInGhost(panel, DC, PtBlock->m_BlockDrawStruct, PtBlock->m_MoveVector.x, PtBlock->m_MoveVector.y); - } + if( PtBlock->m_BlockDrawStruct ) + { + if( PtBlock->m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE ) + { + PickedList = (DrawPickedStruct*) PtBlock->m_BlockDrawStruct; + while( PickedList ) + { + DrawStructsInGhost( panel, + DC, + PickedList->m_PickedStruct, + PtBlock->m_MoveVector.x, + PtBlock->m_MoveVector.y ); + PickedList = (DrawPickedStruct*) PickedList->Pnext; + } + } + else + DrawStructsInGhost( panel, + DC, + PtBlock->m_BlockDrawStruct, + PtBlock->m_MoveVector.x, + PtBlock->m_MoveVector.y ); + } } @@ -518,441 +551,463 @@ BASE_SCREEN * screen = panel->m_Parent->GetScreen(); * If DrawStruct is of type DrawPickedStruct, a list of objects picked is * * assumed, otherwise exactly one structure is assumed been picked. * *****************************************************************************/ -bool MoveStruct(WinEDA_DrawPanel * panel, wxDC * DC, EDA_BaseStruct *DrawStruct) +bool MoveStruct( WinEDA_DrawPanel* panel, wxDC* DC, EDA_BaseStruct* DrawStruct ) { -DrawPickedStruct *PickedList = NULL; + DrawPickedStruct* PickedList = NULL; - if ( !DrawStruct ) return FALSE; + if( !DrawStruct ) + return FALSE; - if(DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) - { - if ( DC ) - RedrawStructList(panel, DC, DrawStruct, g_XorMode); - PlaceStruct(panel->GetScreen(), DrawStruct); /* Place it in its new position. */ - if ( DC ) - RedrawStructList(panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE); + if( DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE ) + { + if( DC ) + RedrawStructList( panel, DC, DrawStruct, g_XorMode ); + PlaceStruct( panel->GetScreen(), DrawStruct ); /* Place it in its new position. */ + if( DC ) + RedrawStructList( panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE ); - /* Free the wrapper DrawPickedStruct chain: */ - PickedList = (DrawPickedStruct *) DrawStruct; - PickedList->DeleteWrapperList(); - } - - else - { - if ( DC ) - RedrawOneStruct(panel, DC, DrawStruct, g_XorMode); - PlaceStruct(panel->GetScreen(), DrawStruct); /* Place it in its new position. */ - if ( DC ) - RedrawOneStruct(panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE); - } - return TRUE; + /* Free the wrapper DrawPickedStruct chain: */ + PickedList = (DrawPickedStruct*) DrawStruct; + PickedList->DeleteWrapperList(); + } + else + { + if( DC ) + RedrawOneStruct( panel, DC, DrawStruct, g_XorMode ); + PlaceStruct( panel->GetScreen(), DrawStruct ); /* Place it in its new position. */ + if( DC ) + RedrawOneStruct( panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE ); + } + return TRUE; } -static void MirrorYPoint(wxPoint & point, wxPoint & Center) +static void MirrorYPoint( wxPoint& point, wxPoint& Center ) { - point.x -= Center.x; - point.x = - point.x; - point.x += Center.x; + point.x -= Center.x; + point.x = -point.x; + point.x += Center.x; } + /**************************************************************/ -void MirrorOneStruct(EDA_BaseStruct *DrawStruct, wxPoint & Center) +void MirrorOneStruct( EDA_BaseStruct* DrawStruct, wxPoint& Center ) /**************************************************************/ + /* Given a structure rotate it to 90 degrees refer to the Center point. -*/ + */ { -int dx, ii, *Points; -DrawPolylineStruct *DrawPoly; -DrawJunctionStruct *DrawConnect; -EDA_DrawLineStruct *DrawSegment; -DrawBusEntryStruct *DrawRaccord; -EDA_SchComponentStruct *DrawLibItem; -DrawSheetStruct *DrawSheet; -DrawSheetLabelStruct *DrawSheetLabel; -DrawMarkerStruct * DrawMarker; -DrawNoConnectStruct * DrawNoConnect; -DrawTextStruct * DrawText; -wxPoint px; + int dx, ii, * Points; + DrawPolylineStruct* DrawPoly; + DrawJunctionStruct* DrawConnect; + EDA_DrawLineStruct* DrawSegment; + DrawBusEntryStruct* DrawRaccord; + EDA_SchComponentStruct* DrawLibItem; + DrawSheetStruct* DrawSheet; + DrawSheetLabelStruct* DrawSheetLabel; + DrawMarkerStruct* DrawMarker; + DrawNoConnectStruct* DrawNoConnect; + DrawTextStruct* DrawText; + wxPoint px; - if ( !DrawStruct ) return; + if( !DrawStruct ) + return; - switch (DrawStruct->m_StructType) - { - case TYPE_NOT_INIT: - break; + switch( DrawStruct->m_StructType ) + { + case TYPE_NOT_INIT: + break; - case DRAW_POLYLINE_STRUCT_TYPE: - DrawPoly = (DrawPolylineStruct *) DrawStruct; - Points = DrawPoly->m_Points; - for (ii = 0; ii < DrawPoly->m_NumOfPoints; ii++) - { - wxPoint point; - point.x = Points[ii * 2]; point.y = Points[ii * 2 + 1]; - MirrorYPoint(point, Center); - Points[ii * 2] = point.x; Points[ii * 2 + 1] = point.y; - } - break; + case DRAW_POLYLINE_STRUCT_TYPE: + DrawPoly = (DrawPolylineStruct*) DrawStruct; + Points = DrawPoly->m_Points; + for( ii = 0; ii < DrawPoly->m_NumOfPoints; ii++ ) + { + wxPoint point; + point.x = Points[ii * 2]; point.y = Points[ii * 2 + 1]; + MirrorYPoint( point, Center ); + Points[ii * 2] = point.x; Points[ii * 2 + 1] = point.y; + } - case DRAW_SEGMENT_STRUCT_TYPE: - DrawSegment = (EDA_DrawLineStruct *) DrawStruct; - if( (DrawSegment->m_Flags & STARTPOINT) == 0 ) - { - MirrorYPoint(DrawSegment->m_Start, Center); - } - if( (DrawSegment->m_Flags & ENDPOINT) == 0 ) - { - MirrorYPoint(DrawSegment->m_End, Center); - } - break; + break; - case DRAW_BUSENTRY_STRUCT_TYPE: - DrawRaccord = (DrawBusEntryStruct *) DrawStruct; - MirrorYPoint(DrawRaccord->m_Pos, Center); - break; + case DRAW_SEGMENT_STRUCT_TYPE: + DrawSegment = (EDA_DrawLineStruct*) DrawStruct; + if( (DrawSegment->m_Flags & STARTPOINT) == 0 ) + { + MirrorYPoint( DrawSegment->m_Start, Center ); + } + if( (DrawSegment->m_Flags & ENDPOINT) == 0 ) + { + MirrorYPoint( DrawSegment->m_End, Center ); + } + break; - case DRAW_JUNCTION_STRUCT_TYPE: - DrawConnect = (DrawJunctionStruct *) DrawStruct; - MirrorYPoint(DrawConnect->m_Pos, Center); - break; + case DRAW_BUSENTRY_STRUCT_TYPE: + DrawRaccord = (DrawBusEntryStruct*) DrawStruct; + MirrorYPoint( DrawRaccord->m_Pos, Center ); + break; - case DRAW_MARKER_STRUCT_TYPE: - DrawMarker = (DrawMarkerStruct *) DrawStruct; - MirrorYPoint(DrawMarker->m_Pos, Center); - break; + case DRAW_JUNCTION_STRUCT_TYPE: + DrawConnect = (DrawJunctionStruct*) DrawStruct; + MirrorYPoint( DrawConnect->m_Pos, Center ); + break; - case DRAW_NOCONNECT_STRUCT_TYPE: - DrawNoConnect = (DrawNoConnectStruct *) DrawStruct; - MirrorYPoint(DrawNoConnect->m_Pos, Center); - break; + case DRAW_MARKER_STRUCT_TYPE: + DrawMarker = (DrawMarkerStruct*) DrawStruct; + MirrorYPoint( DrawMarker->m_Pos, Center ); + break; - case DRAW_TEXT_STRUCT_TYPE: - case DRAW_LABEL_STRUCT_TYPE: - // Text is not really mirrored; it is moved to a suitable position - // which is the closest position for a true mirrored text - // The center position is mirrored and the text is moved for half horizontal len - DrawText = (DrawTextStruct *) DrawStruct; - px = DrawText->m_Pos; - if( DrawText->m_Orient == 0 ) /* horizontal text */ - dx = DrawText->Len_Size() / 2; - else if( DrawText->m_Orient == 2 ) /* invert horizontal text*/ - dx = - DrawText->Len_Size() / 2; - else dx = 0; - px.x += dx; - MirrorYPoint(px, Center); - px.x -= dx; + case DRAW_NOCONNECT_STRUCT_TYPE: + DrawNoConnect = (DrawNoConnectStruct*) DrawStruct; + MirrorYPoint( DrawNoConnect->m_Pos, Center ); + break; - EDA_Appl->SchematicFrame->PutOnGrid(&px); - DrawText->m_Pos.x = px.x; - break; + case DRAW_TEXT_STRUCT_TYPE: + case DRAW_LABEL_STRUCT_TYPE: - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - // Text is not really mirrored: Orientation is changed - DrawText = (DrawGlobalLabelStruct *) DrawStruct; - if( DrawText->m_Orient == 0 ) /* horizontal text */ - DrawText->m_Orient = 2; - else if( DrawText->m_Orient == 2 ) /* invert horizontal text*/ - DrawText->m_Orient = 0; + // Text is not really mirrored; it is moved to a suitable position + // which is the closest position for a true mirrored text + // The center position is mirrored and the text is moved for half horizontal len + DrawText = (DrawTextStruct*) DrawStruct; + px = DrawText->m_Pos; + if( DrawText->m_Orient == 0 ) /* horizontal text */ + dx = DrawText->Len_Size() / 2; + else if( DrawText->m_Orient == 2 ) /* invert horizontal text*/ + dx = -DrawText->Len_Size() / 2; + else + dx = 0; + px.x += dx; + MirrorYPoint( px, Center ); + px.x -= dx; - px = DrawText->m_Pos; - MirrorYPoint(px, Center); - EDA_Appl->SchematicFrame->PutOnGrid(&px); - DrawText->m_Pos.x = px.x; - break; + EDA_Appl->SchematicFrame->PutOnGrid( &px ); + DrawText->m_Pos.x = px.x; + break; - case DRAW_LIB_ITEM_STRUCT_TYPE: - DrawLibItem = (EDA_SchComponentStruct *) DrawStruct; - dx = DrawLibItem->m_Pos.x; - EDA_Appl->SchematicFrame->CmpRotationMiroir( DrawLibItem, - NULL, CMP_MIROIR_Y ); - MirrorYPoint(DrawLibItem->m_Pos, Center); - dx -= DrawLibItem->m_Pos.x; - for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) - { /* move the fields to the new position because the component itself has moved */ - DrawLibItem->m_Field[ii].m_Pos.x -= dx; - } - break; + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - case DRAW_SHEET_STRUCT_TYPE: - DrawSheet = (DrawSheetStruct *) DrawStruct; - MirrorYPoint(DrawSheet->m_Pos, Center); - DrawSheet->m_Pos.x -= DrawSheet->m_Size.x; + // Text is not really mirrored: Orientation is changed + DrawText = (DrawGlobalLabelStruct*) DrawStruct; + if( DrawText->m_Orient == 0 ) /* horizontal text */ + DrawText->m_Orient = 2; + else if( DrawText->m_Orient == 2 ) /* invert horizontal text*/ + DrawText->m_Orient = 0; - DrawSheetLabel = DrawSheet->m_Label; - while( DrawSheetLabel != NULL ) - { - MirrorYPoint(DrawSheetLabel->m_Pos, Center); - DrawSheetLabel->m_Edge = DrawSheetLabel->m_Edge ? 0 : 1; - DrawSheetLabel = (DrawSheetLabelStruct*)DrawSheetLabel->Pnext; - } - break; + px = DrawText->m_Pos; + MirrorYPoint( px, Center ); + EDA_Appl->SchematicFrame->PutOnGrid( &px ); + DrawText->m_Pos.x = px.x; + break; - case DRAW_SHEETLABEL_STRUCT_TYPE: - DrawSheetLabel = (DrawSheetLabelStruct *) DrawStruct; - MirrorYPoint(DrawSheetLabel->m_Pos, Center); - break; + case DRAW_LIB_ITEM_STRUCT_TYPE: + DrawLibItem = (EDA_SchComponentStruct*) DrawStruct; + dx = DrawLibItem->m_Pos.x; + EDA_Appl->SchematicFrame->CmpRotationMiroir( DrawLibItem, + NULL, CMP_MIROIR_Y ); + MirrorYPoint( DrawLibItem->m_Pos, Center ); + dx -= DrawLibItem->m_Pos.x; + for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) + { /* move the fields to the new position because the component itself has moved */ + DrawLibItem->m_Field[ii].m_Pos.x -= dx; + } - case DRAW_PICK_ITEM_STRUCT_TYPE : break; + break; - default: break; - } + case DRAW_SHEET_STRUCT_TYPE: + DrawSheet = (DrawSheetStruct*) DrawStruct; + MirrorYPoint( DrawSheet->m_Pos, Center ); + DrawSheet->m_Pos.x -= DrawSheet->m_Size.x; + + DrawSheetLabel = DrawSheet->m_Label; + while( DrawSheetLabel != NULL ) + { + MirrorYPoint( DrawSheetLabel->m_Pos, Center ); + DrawSheetLabel->m_Edge = DrawSheetLabel->m_Edge ? 0 : 1; + DrawSheetLabel = (DrawSheetLabelStruct*) DrawSheetLabel->Pnext; + } + + break; + + case DRAW_SHEETLABEL_STRUCT_TYPE: + DrawSheetLabel = (DrawSheetLabelStruct*) DrawStruct; + MirrorYPoint( DrawSheetLabel->m_Pos, Center ); + break; + + case DRAW_PICK_ITEM_STRUCT_TYPE: + break; + + default: + break; + } } - /***************************************************************************** * Routine to Mirror an object(s). * * If DrawStruct is of type DrawPickedStruct, a list of objects picked is * * assumed, otherwise exactly one structure is assumed been picked. * *****************************************************************************/ -bool MirrorStruct(WinEDA_DrawPanel * panel, wxDC * DC, EDA_BaseStruct *DrawStruct, wxPoint & Center) +bool MirrorStruct( WinEDA_DrawPanel* panel, wxDC* DC, EDA_BaseStruct* DrawStruct, wxPoint& Center ) { -DrawPickedStruct *PickedList = NULL; -DrawPickedStruct *DrawStructs; - if ( !DrawStruct ) return FALSE; + DrawPickedStruct* PickedList = NULL; + DrawPickedStruct* DrawStructs; - if(DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) - { - if ( DC ) - RedrawStructList(panel, DC, DrawStruct, g_XorMode); - DrawStructs = (DrawPickedStruct *) DrawStruct; - while (DrawStructs) - { - MirrorOneStruct(DrawStructs->m_PickedStruct, Center); - DrawStructs->m_PickedStruct->m_Flags = 0; - DrawStructs = (DrawPickedStruct *)DrawStructs->Pnext; - } - if ( DC ) - RedrawStructList(panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE); + if( !DrawStruct ) + return FALSE; - /* Free the wrapper DrawPickedStruct chain: */ - PickedList = (DrawPickedStruct *) DrawStruct; - PickedList->DeleteWrapperList(); - } + if( DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE ) + { + if( DC ) + RedrawStructList( panel, DC, DrawStruct, g_XorMode ); + DrawStructs = (DrawPickedStruct*) DrawStruct; + while( DrawStructs ) + { + MirrorOneStruct( DrawStructs->m_PickedStruct, Center ); + DrawStructs->m_PickedStruct->m_Flags = 0; + DrawStructs = (DrawPickedStruct*) DrawStructs->Pnext; + } - else - { - if ( DC ) - RedrawOneStruct(panel, DC, DrawStruct, g_XorMode); - MirrorOneStruct(DrawStruct, Center); /* Place it in its new position. */ - if ( DC ) - RedrawOneStruct(panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE); - DrawStruct->m_Flags = 0; - } + if( DC ) + RedrawStructList( panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE ); + + /* Free the wrapper DrawPickedStruct chain: */ + PickedList = (DrawPickedStruct*) DrawStruct; + PickedList->DeleteWrapperList(); + } + else + { + if( DC ) + RedrawOneStruct( panel, DC, DrawStruct, g_XorMode ); + MirrorOneStruct( DrawStruct, Center ); /* Place it in its new position. */ + if( DC ) + RedrawOneStruct( panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE ); + DrawStruct->m_Flags = 0; + } - return TRUE; + return TRUE; } /*****************************************************************************/ -static EDA_BaseStruct * CopyStruct(WinEDA_DrawPanel * panel, wxDC * DC, BASE_SCREEN * screen, - EDA_BaseStruct *DrawStruct) +static EDA_BaseStruct* CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* screen, + EDA_BaseStruct* DrawStruct ) /*****************************************************************************/ + /* Routine to copy a new entity of an object and reposition it. -If DrawStruct is of type DrawPickedStruct, a list of objects picked is -assumed, otherwise exactly one structure is assumed been picked. -Return the new created struct -*/ + * If DrawStruct is of type DrawPickedStruct, a list of objects picked is + * assumed, otherwise exactly one structure is assumed been picked. + * Return the new created struct + */ { -EDA_BaseStruct *NewDrawStruct; -DrawPickedStruct *PickedList = NULL; + EDA_BaseStruct* NewDrawStruct; + DrawPickedStruct* PickedList = NULL; - if ( !DrawStruct ) return FALSE; + if( !DrawStruct ) + return FALSE; - NewDrawStruct = DuplicateStruct(DrawStruct); - if ( NewDrawStruct == NULL ) return NULL; + NewDrawStruct = DuplicateStruct( DrawStruct ); + if( NewDrawStruct == NULL ) + return NULL; - PlaceStruct( screen, NewDrawStruct); - /* Draw the new structure and chain it in: */ - if (NewDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) - { - PickedList = (DrawPickedStruct *) NewDrawStruct; - while (PickedList) // Clear annotation for new components - { - EDA_BaseStruct * Struct = PickedList->m_PickedStruct; - switch ( Struct->m_StructType ) - { - case DRAW_LIB_ITEM_STRUCT_TYPE: - { - ((EDA_SchComponentStruct*)Struct)->m_TimeStamp = GetTimeStamp(); - ((EDA_SchComponentStruct*)Struct)->ClearAnnotation(); - } - break; - case DRAW_SHEET_STRUCT_TYPE: - { - DrawSheetStruct * sheet = (DrawSheetStruct*)Struct; - sheet->m_TimeStamp = GetTimeStamp(); - sheet->m_UndoList = NULL; - sheet->m_RedoList = NULL; - sheet->EEDrawList = NULL; - sheet->m_Son = NULL; - sheet->m_SheetName.Printf(wxT("%8.8lX"), sheet->m_TimeStamp); - sheet->m_FileName = sheet->m_SheetName + wxT(".sch"); - break; - } - } - SetStructFather(Struct, screen); - PickedList = (DrawPickedStruct *)PickedList->Pnext; - } - RedrawStructList(panel, DC, NewDrawStruct, GR_DEFAULT_DRAWMODE); - /* Chain the new items */ - PickedList = (DrawPickedStruct *) NewDrawStruct; - while (PickedList) - { - PickedList->m_PickedStruct->Pnext = screen->EEDrawList; - screen->EEDrawList = PickedList->m_PickedStruct; - PickedList = PickedList->Next(); - } - } + PlaceStruct( screen, NewDrawStruct ); + /* Draw the new structure and chain it in: */ + if( NewDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE ) + { + PickedList = (DrawPickedStruct*) NewDrawStruct; + while( PickedList ) // Clear annotation for new components + { + EDA_BaseStruct* Struct = PickedList->m_PickedStruct; - else - { - switch(NewDrawStruct->m_StructType) - { - case DRAW_POLYLINE_STRUCT_TYPE: - case DRAW_JUNCTION_STRUCT_TYPE: - case DRAW_SEGMENT_STRUCT_TYPE: - case DRAW_BUSENTRY_STRUCT_TYPE: - case DRAW_TEXT_STRUCT_TYPE: - case DRAW_LABEL_STRUCT_TYPE: - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - case DRAW_SHEETLABEL_STRUCT_TYPE: - case DRAW_PICK_ITEM_STRUCT_TYPE: - case DRAW_MARKER_STRUCT_TYPE: - case DRAW_NOCONNECT_STRUCT_TYPE: - default: - break; + switch( Struct->m_StructType ) + { + case DRAW_LIB_ITEM_STRUCT_TYPE: + { + ( (EDA_SchComponentStruct*) Struct )->m_TimeStamp = GetTimeStamp(); + ( (EDA_SchComponentStruct*) Struct )->ClearAnnotation(); + } + break; - case DRAW_SHEET_STRUCT_TYPE: - { - DrawSheetStruct * sheet = (DrawSheetStruct*)NewDrawStruct; - sheet->m_TimeStamp = GetTimeStamp(); - sheet->m_UndoList = NULL; - sheet->m_RedoList = NULL; - sheet->EEDrawList = NULL; - sheet->m_Son = NULL; - sheet->m_SheetName.Printf(wxT("%8.8lX"), sheet->m_TimeStamp); - sheet->m_FileName = sheet->m_SheetName + wxT(".sch"); - break; - } + case DRAW_SHEET_STRUCT_TYPE: + { + DrawSheetStruct* sheet = (DrawSheetStruct*) Struct; + sheet->m_TimeStamp = GetTimeStamp(); + sheet->m_UndoList = NULL; + sheet->m_RedoList = NULL; + sheet->EEDrawList = NULL; + sheet->m_Son = NULL; + sheet->m_SheetName.Printf( wxT( "%8.8lX" ), sheet->m_TimeStamp ); + sheet->m_FileName = sheet->m_SheetName + wxT( ".sch" ); + break; + } + } - case DRAW_LIB_ITEM_STRUCT_TYPE: - ((EDA_SchComponentStruct*)NewDrawStruct)->m_TimeStamp = GetTimeStamp(); - ((EDA_SchComponentStruct*)NewDrawStruct)->ClearAnnotation(); - break; + SetStructFather( Struct, screen ); + PickedList = (DrawPickedStruct*) PickedList->Pnext; + } - } + RedrawStructList( panel, DC, NewDrawStruct, GR_DEFAULT_DRAWMODE ); + /* Chain the new items */ + PickedList = (DrawPickedStruct*) NewDrawStruct; + while( PickedList ) + { + PickedList->m_PickedStruct->Pnext = screen->EEDrawList; + screen->EEDrawList = PickedList->m_PickedStruct; + PickedList = PickedList->Next(); + } + } + else + { + switch( NewDrawStruct->m_StructType ) + { + case DRAW_POLYLINE_STRUCT_TYPE: + case DRAW_JUNCTION_STRUCT_TYPE: + case DRAW_SEGMENT_STRUCT_TYPE: + case DRAW_BUSENTRY_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_SHEETLABEL_STRUCT_TYPE: + case DRAW_PICK_ITEM_STRUCT_TYPE: + case DRAW_MARKER_STRUCT_TYPE: + case DRAW_NOCONNECT_STRUCT_TYPE: + default: + break; - RedrawOneStruct(panel, DC, NewDrawStruct, GR_DEFAULT_DRAWMODE); + case DRAW_SHEET_STRUCT_TYPE: + { + DrawSheetStruct* sheet = (DrawSheetStruct*) NewDrawStruct; + sheet->m_TimeStamp = GetTimeStamp(); + sheet->m_UndoList = NULL; + sheet->m_RedoList = NULL; + sheet->EEDrawList = NULL; + sheet->m_Son = NULL; + sheet->m_SheetName.Printf( wxT( "%8.8lX" ), sheet->m_TimeStamp ); + sheet->m_FileName = sheet->m_SheetName + wxT( ".sch" ); + break; + } - SetStructFather(NewDrawStruct, screen); - NewDrawStruct->Pnext = screen->EEDrawList; - screen->EEDrawList = NewDrawStruct; - } + case DRAW_LIB_ITEM_STRUCT_TYPE: + ( (EDA_SchComponentStruct*) NewDrawStruct )->m_TimeStamp = GetTimeStamp(); + ( (EDA_SchComponentStruct*) NewDrawStruct )->ClearAnnotation(); + break; + } - /* Free the original DrawPickedStruct chain: */ - if (DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) - { - PickedList = (DrawPickedStruct *) DrawStruct; - PickedList->DeleteWrapperList(); - } + RedrawOneStruct( panel, DC, NewDrawStruct, GR_DEFAULT_DRAWMODE ); - return NewDrawStruct; + SetStructFather( NewDrawStruct, screen ); + NewDrawStruct->Pnext = screen->EEDrawList; + screen->EEDrawList = NewDrawStruct; + } + + /* Free the original DrawPickedStruct chain: */ + if( DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE ) + { + PickedList = (DrawPickedStruct*) DrawStruct; + PickedList->DeleteWrapperList(); + } + + return NewDrawStruct; } + /*********************************************************************************/ -void DeleteStruct(WinEDA_DrawPanel * panel, wxDC * DC, EDA_BaseStruct *DrawStruct) +void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, EDA_BaseStruct* DrawStruct ) /*********************************************************************************/ + /* Routine to delete an object from global drawing object list. - Object is put in Undo list -*/ + * Object is put in Undo list + */ { -SCH_SCREEN * screen = (SCH_SCREEN *)panel->GetScreen(); -DrawPickedStruct *PickedList = NULL; -WinEDA_SchematicFrame * frame = (WinEDA_SchematicFrame *) panel->m_Parent; + SCH_SCREEN* screen = (SCH_SCREEN*) panel->GetScreen(); + DrawPickedStruct* PickedList = NULL; + WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) panel->m_Parent; - if ( !DrawStruct ) return; + if( !DrawStruct ) + return; - if (DrawStruct->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE) - { /* Cette stucture est rattachee a une feuille, et n'est pas - accessible par la liste globale directement */ - frame->SaveCopyInUndoList(((DrawSheetLabelStruct*) DrawStruct)->m_Parent, IS_CHANGED); - frame->DeleteSheetLabel(DC, (DrawSheetLabelStruct*) DrawStruct); - return; - } + if( DrawStruct->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE ) + { /* Cette stucture est rattachee a une feuille, et n'est pas + * accessible par la liste globale directement */ + frame->SaveCopyInUndoList( ( (DrawSheetLabelStruct*) DrawStruct )->m_Parent, IS_CHANGED ); + frame->DeleteSheetLabel( DC, (DrawSheetLabelStruct*) DrawStruct ); + return; + } - if (DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) - { - /* Unlink all picked structs from current EEDrawList */ - PickedList = (DrawPickedStruct *) DrawStruct; - while (PickedList) - { - screen->RemoveFromDrawList(PickedList->m_PickedStruct); - PickedList->m_PickedStruct->Pnext = - PickedList->m_PickedStruct->Pback = NULL; - PickedList->m_PickedStruct->m_Flags = IS_DELETED; - PickedList = PickedList->Next(); - } - RedrawStructList(panel, DC, DrawStruct, g_XorMode); + if( DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE ) + { + /* Unlink all picked structs from current EEDrawList */ + PickedList = (DrawPickedStruct*) DrawStruct; + while( PickedList ) + { + screen->RemoveFromDrawList( PickedList->m_PickedStruct ); + PickedList->m_PickedStruct->Pnext = + PickedList->m_PickedStruct->Pback = NULL; + PickedList->m_PickedStruct->m_Flags = IS_DELETED; + PickedList = PickedList->Next(); + } - /* Removed items are put to the Undo list */ - frame->SaveCopyInUndoList(DrawStruct, IS_DELETED); - } + RedrawStructList( panel, DC, DrawStruct, g_XorMode ); - else /* structure classique */ - { - screen->RemoveFromDrawList(DrawStruct); + /* Removed items are put to the Undo list */ + frame->SaveCopyInUndoList( DrawStruct, IS_DELETED ); + } + else /* structure classique */ + { + screen->RemoveFromDrawList( DrawStruct ); - RedrawOneStruct(panel, DC, DrawStruct, g_XorMode); - /* Unlink the structure */ - DrawStruct->Pnext = DrawStruct->Pback = NULL; // Only one struct -> no link - frame->SaveCopyInUndoList(DrawStruct, IS_DELETED); - } + RedrawOneStruct( panel, DC, DrawStruct, g_XorMode ); + /* Unlink the structure */ + DrawStruct->Pnext = DrawStruct->Pback = NULL; // Only one struct -> no link + frame->SaveCopyInUndoList( DrawStruct, IS_DELETED ); + } } + /*****************************************************************/ -EDA_BaseStruct * SaveStructListForPaste(EDA_BaseStruct *DrawStruct) +EDA_BaseStruct* SaveStructListForPaste( EDA_BaseStruct* DrawStruct ) /*****************************************************************/ /* Routine to Save an object from global drawing object list. - This routine is the same as delete but: - - the original list is NOT removed. - - List is saved in g_BlockSaveDataList -*/ + * This routine is the same as delete but: + * - the original list is NOT removed. + * - List is saved in g_BlockSaveDataList + */ { -DrawPickedStruct *PickedList; -EDA_BaseStruct *DrawStructCopy; + DrawPickedStruct* PickedList; + EDA_BaseStruct* DrawStructCopy; - if ( !DrawStruct ) return NULL; + if( !DrawStruct ) + return NULL; - /* Make a copy of the original picked item. */ - DrawStructCopy = DuplicateStruct(DrawStruct); + /* Make a copy of the original picked item. */ + DrawStructCopy = DuplicateStruct( DrawStruct ); - if (DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) - { - /* Delete the picked wrapper if this is a picked list. */ - PickedList = (DrawPickedStruct *) DrawStruct; - PickedList->DeleteWrapperList(); - } + if( DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE ) + { + /* Delete the picked wrapper if this is a picked list. */ + PickedList = (DrawPickedStruct*) DrawStruct; + PickedList->DeleteWrapperList(); + } - /* And delete old list and save the new list: */ - if (g_BlockSaveDataList ) /* Delete last deleted item or item list */ - { - EDA_BaseStruct * item = g_BlockSaveDataList, * next_item; - while (item) - { - next_item = item->Pnext; - delete item; - item = next_item; - } - } + /* And delete old list and save the new list: */ + if( g_BlockSaveDataList ) /* Delete last deleted item or item list */ + { + EDA_BaseStruct* item = g_BlockSaveDataList, * next_item; + while( item ) + { + next_item = item->Pnext; + delete item; + item = next_item; + } + } - g_BlockSaveDataList = DrawStructCopy; - DrawStructCopy->m_Parent = NULL; + g_BlockSaveDataList = DrawStructCopy; + DrawStructCopy->m_Parent = NULL; - return DrawStructCopy; + return DrawStructCopy; } @@ -960,634 +1015,690 @@ EDA_BaseStruct *DrawStructCopy; * Routine to paste a structure from the g_BlockSaveDataList stack. * * This routine is the same as undelete but original list is NOT removed. * *****************************************************************************/ -void WinEDA_SchematicFrame::PasteStruct(wxDC * DC) +void WinEDA_SchematicFrame::PasteStruct( wxDC* DC ) { -EDA_BaseStruct *DrawStruct; -DrawPickedStruct *PickedList = NULL; + EDA_BaseStruct* DrawStruct; + DrawPickedStruct* PickedList = NULL; - if (g_BlockSaveDataList == NULL) - { - DisplayError(this, wxT("No struct to paste") ); - return; - } + if( g_BlockSaveDataList == NULL ) + { + DisplayError( this, wxT( "No struct to paste" ) ); + return; + } - DrawStruct = DuplicateStruct(g_BlockSaveDataList); + DrawStruct = DuplicateStruct( g_BlockSaveDataList ); - PlaceStruct( GetScreen(), DrawStruct); + PlaceStruct( GetScreen(), DrawStruct ); - RedrawStructList(DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE); + RedrawStructList( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE ); - // Clear annotation and init new time stamp for the new components: - if (DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) - { - for(PickedList = (DrawPickedStruct *) DrawStruct; PickedList != NULL; ) // Clear annotation for new components - { - EDA_BaseStruct * Struct = PickedList->m_PickedStruct; - if ( Struct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE ) - { - ((EDA_SchComponentStruct*)Struct)->m_TimeStamp = GetTimeStamp(); - ((EDA_SchComponentStruct*)Struct)->ClearAnnotation(); - SetStructFather(Struct, GetScreen()); - } - PickedList = (DrawPickedStruct *)PickedList->Pnext; - } - RedrawStructList(DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE); - for(PickedList = (DrawPickedStruct *) DrawStruct; PickedList != NULL; ) - { - EDA_BaseStruct * Struct = PickedList->m_PickedStruct; - Struct->Pnext = GetScreen()->EEDrawList; - SetStructFather(Struct, GetScreen()); - GetScreen()->EEDrawList = Struct; - PickedList = (DrawPickedStruct *)PickedList->Pnext; - } - /* Save wrapper list in undo stack */ - SaveCopyInUndoList(DrawStruct, IS_NEW); - } - else - { - if ( DrawStruct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE ) - { - ((EDA_SchComponentStruct*)DrawStruct)->m_TimeStamp = GetTimeStamp(); - ((EDA_SchComponentStruct*)DrawStruct)->ClearAnnotation(); - } - SetStructFather(DrawStruct, GetScreen()); - RedrawOneStruct(DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE); - DrawStruct->Pnext = GetScreen()->EEDrawList; - GetScreen()->EEDrawList = DrawStruct; - SaveCopyInUndoList(DrawStruct, IS_NEW); - } + // Clear annotation and init new time stamp for the new components: + if( DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE ) + { + for( PickedList = (DrawPickedStruct*) DrawStruct; PickedList != NULL; ) // Clear annotation for new components + { + EDA_BaseStruct* Struct = PickedList->m_PickedStruct; + if( Struct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE ) + { + ( (EDA_SchComponentStruct*) Struct )->m_TimeStamp = GetTimeStamp(); + ( (EDA_SchComponentStruct*) Struct )->ClearAnnotation(); + SetStructFather( Struct, GetScreen() ); + } + PickedList = (DrawPickedStruct*) PickedList->Pnext; + } - /* clear .m_Flags member for all items */ - EDA_BaseStruct * Struct; - for(Struct = GetScreen()->EEDrawList; Struct != NULL; Struct=Struct->Pnext) - Struct->m_Flags = 0; - GetScreen()->SetModify(); + RedrawStructList( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE ); + for( PickedList = (DrawPickedStruct*) DrawStruct; PickedList != NULL; ) + { + EDA_BaseStruct* Struct = PickedList->m_PickedStruct; + Struct->Pnext = GetScreen()->EEDrawList; + SetStructFather( Struct, GetScreen() ); + GetScreen()->EEDrawList = Struct; + PickedList = (DrawPickedStruct*) PickedList->Pnext; + } - return; + /* Save wrapper list in undo stack */ + SaveCopyInUndoList( DrawStruct, IS_NEW ); + } + else + { + if( DrawStruct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE ) + { + ( (EDA_SchComponentStruct*) DrawStruct )->m_TimeStamp = GetTimeStamp(); + ( (EDA_SchComponentStruct*) DrawStruct )->ClearAnnotation(); + } + SetStructFather( DrawStruct, GetScreen() ); + RedrawOneStruct( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE ); + DrawStruct->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = DrawStruct; + SaveCopyInUndoList( DrawStruct, IS_NEW ); + } + + /* clear .m_Flags member for all items */ + EDA_BaseStruct* Struct; + for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Pnext ) + Struct->m_Flags = 0; + + GetScreen()->SetModify(); + + return; } /***************************************************************************** * Routine to place a given object. * *****************************************************************************/ -bool PlaceStruct( BASE_SCREEN * screen, EDA_BaseStruct *DrawStruct) +bool PlaceStruct( BASE_SCREEN* screen, EDA_BaseStruct* DrawStruct ) { -DrawPickedStruct * DrawStructs; -wxPoint move_vector; + DrawPickedStruct* DrawStructs; + wxPoint move_vector; - if ( !DrawStruct ) return FALSE; + if( !DrawStruct ) + return FALSE; - move_vector.x = screen->m_Curseur.x - - screen->BlockLocate.m_BlockLastCursorPosition.x; - move_vector.y = screen->m_Curseur.y - - screen->BlockLocate.m_BlockLastCursorPosition.y; + move_vector.x = screen->m_Curseur.x - + screen->BlockLocate.m_BlockLastCursorPosition.x; + move_vector.y = screen->m_Curseur.y - + screen->BlockLocate.m_BlockLastCursorPosition.y; - switch (DrawStruct->m_StructType) - { - default: - case TYPE_NOT_INIT: - return FALSE; + switch( DrawStruct->m_StructType ) + { + default: + case TYPE_NOT_INIT: + return FALSE; - case DRAW_POLYLINE_STRUCT_TYPE: - case DRAW_JUNCTION_STRUCT_TYPE: - case DRAW_SEGMENT_STRUCT_TYPE: - case DRAW_BUSENTRY_STRUCT_TYPE: - case DRAW_TEXT_STRUCT_TYPE: - case DRAW_LABEL_STRUCT_TYPE: - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - case DRAW_LIB_ITEM_STRUCT_TYPE: - case DRAW_SHEET_STRUCT_TYPE: - case DRAW_SHEETLABEL_STRUCT_TYPE: - case DRAW_MARKER_STRUCT_TYPE: - case DRAW_NOCONNECT_STRUCT_TYPE: - MoveOneStruct(DrawStruct, move_vector); - break; + case DRAW_POLYLINE_STRUCT_TYPE: + case DRAW_JUNCTION_STRUCT_TYPE: + case DRAW_SEGMENT_STRUCT_TYPE: + case DRAW_BUSENTRY_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_LIB_ITEM_STRUCT_TYPE: + case DRAW_SHEET_STRUCT_TYPE: + case DRAW_SHEETLABEL_STRUCT_TYPE: + case DRAW_MARKER_STRUCT_TYPE: + case DRAW_NOCONNECT_STRUCT_TYPE: + MoveOneStruct( DrawStruct, move_vector ); + break; - case DRAW_PICK_ITEM_STRUCT_TYPE: - DrawStructs = (DrawPickedStruct *) DrawStruct; - while (DrawStructs) - { - MoveOneStruct(DrawStructs->m_PickedStruct, move_vector); - DrawStructs = (DrawPickedStruct *)DrawStructs->Pnext; - } - break; - } - return TRUE; + case DRAW_PICK_ITEM_STRUCT_TYPE: + DrawStructs = (DrawPickedStruct*) DrawStruct; + while( DrawStructs ) + { + MoveOneStruct( DrawStructs->m_PickedStruct, move_vector ); + DrawStructs = (DrawPickedStruct*) DrawStructs->Pnext; + } + + break; + } + + return TRUE; } + /**************************************************************************/ -void MoveOneStruct(EDA_BaseStruct *DrawStruct, const wxPoint & move_vector) +void MoveOneStruct( EDA_BaseStruct* DrawStruct, const wxPoint& move_vector ) /*************************************************************************/ + /* Given a structure move it by Dx, Dy. -*/ + */ { -int ii, *Points; -DrawPolylineStruct *DrawPoly; -DrawJunctionStruct *DrawConnect; -EDA_DrawLineStruct *DrawSegment; -DrawBusEntryStruct *DrawRaccord; -EDA_SchComponentStruct *DrawLibItem; -DrawSheetStruct *DrawSheet; -DrawSheetLabelStruct *DrawSheetLabel; -DrawMarkerStruct * DrawMarker; -DrawNoConnectStruct * DrawNoConnect; + int ii, * Points; + DrawPolylineStruct* DrawPoly; + DrawJunctionStruct* DrawConnect; + EDA_DrawLineStruct* DrawSegment; + DrawBusEntryStruct* DrawRaccord; + EDA_SchComponentStruct* DrawLibItem; + DrawSheetStruct* DrawSheet; + DrawSheetLabelStruct* DrawSheetLabel; + DrawMarkerStruct* DrawMarker; + DrawNoConnectStruct* DrawNoConnect; - if ( !DrawStruct ) return; + if( !DrawStruct ) + return; - switch (DrawStruct->m_StructType) - { - case TYPE_NOT_INIT: - break; + switch( DrawStruct->m_StructType ) + { + case TYPE_NOT_INIT: + break; - case DRAW_POLYLINE_STRUCT_TYPE: - DrawPoly = (DrawPolylineStruct *) DrawStruct; - Points = DrawPoly->m_Points; - for (ii = 0; ii < DrawPoly->m_NumOfPoints; ii++) - { - Points[ii * 2] += move_vector.x; - Points[ii * 2 + 1] += move_vector.y; - } - break; + case DRAW_POLYLINE_STRUCT_TYPE: + DrawPoly = (DrawPolylineStruct*) DrawStruct; + Points = DrawPoly->m_Points; + for( ii = 0; ii < DrawPoly->m_NumOfPoints; ii++ ) + { + Points[ii * 2] += move_vector.x; + Points[ii * 2 + 1] += move_vector.y; + } - case DRAW_SEGMENT_STRUCT_TYPE: - DrawSegment = (EDA_DrawLineStruct *) DrawStruct; - if( (DrawSegment->m_Flags & STARTPOINT) == 0 ) - { - DrawSegment->m_Start += move_vector; - } - if( (DrawSegment->m_Flags & ENDPOINT) == 0 ) - { - DrawSegment->m_End += move_vector; - } - break; + break; - case DRAW_BUSENTRY_STRUCT_TYPE: - DrawRaccord = (DrawBusEntryStruct *) DrawStruct; - DrawRaccord->m_Pos += move_vector; - break; + case DRAW_SEGMENT_STRUCT_TYPE: + DrawSegment = (EDA_DrawLineStruct*) DrawStruct; + if( (DrawSegment->m_Flags & STARTPOINT) == 0 ) + { + DrawSegment->m_Start += move_vector; + } + if( (DrawSegment->m_Flags & ENDPOINT) == 0 ) + { + DrawSegment->m_End += move_vector; + } + break; - case DRAW_JUNCTION_STRUCT_TYPE: - DrawConnect = (DrawJunctionStruct *) DrawStruct; - DrawConnect->m_Pos += move_vector; - break; + case DRAW_BUSENTRY_STRUCT_TYPE: + DrawRaccord = (DrawBusEntryStruct*) DrawStruct; + DrawRaccord->m_Pos += move_vector; + break; - case DRAW_MARKER_STRUCT_TYPE: - DrawMarker = (DrawMarkerStruct *) DrawStruct; - DrawMarker->m_Pos += move_vector; - break; + case DRAW_JUNCTION_STRUCT_TYPE: + DrawConnect = (DrawJunctionStruct*) DrawStruct; + DrawConnect->m_Pos += move_vector; + break; - case DRAW_NOCONNECT_STRUCT_TYPE: - DrawNoConnect = (DrawNoConnectStruct *) DrawStruct; - DrawNoConnect->m_Pos += move_vector; - break; + case DRAW_MARKER_STRUCT_TYPE: + DrawMarker = (DrawMarkerStruct*) DrawStruct; + DrawMarker->m_Pos += move_vector; + break; - case DRAW_TEXT_STRUCT_TYPE: - #define DrawText ((DrawTextStruct *) DrawStruct) - DrawText->m_Pos += move_vector; - break; + case DRAW_NOCONNECT_STRUCT_TYPE: + DrawNoConnect = (DrawNoConnectStruct*) DrawStruct; + DrawNoConnect->m_Pos += move_vector; + break; - case DRAW_LABEL_STRUCT_TYPE: - #define DrawLabel ((DrawLabelStruct *) DrawStruct) - DrawLabel->m_Pos += move_vector; - break; + case DRAW_TEXT_STRUCT_TYPE: + #define DrawText ( (DrawTextStruct*) DrawStruct ) + DrawText->m_Pos += move_vector; + break; - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - #define DrawGlobalLabel ((DrawGlobalLabelStruct *) DrawStruct) - DrawGlobalLabel->m_Pos += move_vector; - break; + case DRAW_LABEL_STRUCT_TYPE: + #define DrawLabel ( (DrawLabelStruct*) DrawStruct ) + DrawLabel->m_Pos += move_vector; + break; - case DRAW_LIB_ITEM_STRUCT_TYPE: - DrawLibItem = (EDA_SchComponentStruct *) DrawStruct; - DrawLibItem->m_Pos += move_vector; - for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) - { - DrawLibItem->m_Field[ii].m_Pos += move_vector; - } - break; + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + #define DrawGlobalLabel ( (DrawGlobalLabelStruct*) DrawStruct ) + DrawGlobalLabel->m_Pos += move_vector; + break; - case DRAW_SHEET_STRUCT_TYPE: - DrawSheet = (DrawSheetStruct *) DrawStruct; - DrawSheet->m_Pos += move_vector; - DrawSheetLabel = DrawSheet->m_Label; - while( DrawSheetLabel != NULL ) - { - DrawSheetLabel->m_Pos += move_vector; - DrawSheetLabel = DrawSheetLabel->Next(); - } - break; + case DRAW_LIB_ITEM_STRUCT_TYPE: + DrawLibItem = (EDA_SchComponentStruct*) DrawStruct; + DrawLibItem->m_Pos += move_vector; + for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) + { + DrawLibItem->m_Field[ii].m_Pos += move_vector; + } - case DRAW_SHEETLABEL_STRUCT_TYPE: - DrawSheetLabel = (DrawSheetLabelStruct *) DrawStruct; - DrawSheetLabel->m_Pos += move_vector; - break; + break; - case DRAW_PICK_ITEM_STRUCT_TYPE : break; + case DRAW_SHEET_STRUCT_TYPE: + DrawSheet = (DrawSheetStruct*) DrawStruct; + DrawSheet->m_Pos += move_vector; + DrawSheetLabel = DrawSheet->m_Label; + while( DrawSheetLabel != NULL ) + { + DrawSheetLabel->m_Pos += move_vector; + DrawSheetLabel = DrawSheetLabel->Next(); + } - default: break; - } + break; + + case DRAW_SHEETLABEL_STRUCT_TYPE: + DrawSheetLabel = (DrawSheetLabelStruct*) DrawStruct; + DrawSheetLabel->m_Pos += move_vector; + break; + + case DRAW_PICK_ITEM_STRUCT_TYPE: + break; + + default: + break; + } } /************************************************************/ -EDA_BaseStruct * DuplicateStruct(EDA_BaseStruct *DrawStruct) +EDA_BaseStruct* DuplicateStruct( EDA_BaseStruct* DrawStruct ) /************************************************************/ + /* Routine to create a new copy of given struct. - The new object is not put in draw list (not linked) -*/ + * The new object is not put in draw list (not linked) + */ { -EDA_BaseStruct *NewDrawStruct = NULL; + EDA_BaseStruct* NewDrawStruct = NULL; - if ( DrawStruct == NULL ) - { - DisplayError(NULL, wxT("DuplicateStruct error: NULL struct") ); - return NULL; - } + if( DrawStruct == NULL ) + { + DisplayError( NULL, wxT( "DuplicateStruct error: NULL struct" ) ); + return NULL; + } - switch (DrawStruct->m_StructType) - { - case DRAW_POLYLINE_STRUCT_TYPE: - NewDrawStruct = ((DrawPolylineStruct*)DrawStruct)->GenCopy(); - break; - case DRAW_SEGMENT_STRUCT_TYPE: - NewDrawStruct = ((EDA_DrawLineStruct*)DrawStruct)->GenCopy(); - break; - case DRAW_BUSENTRY_STRUCT_TYPE: - NewDrawStruct = ((DrawBusEntryStruct*)DrawStruct)->GenCopy(); - break; - case DRAW_JUNCTION_STRUCT_TYPE: - NewDrawStruct = ((DrawJunctionStruct*)DrawStruct)->GenCopy(); - break; - case DRAW_MARKER_STRUCT_TYPE: - NewDrawStruct = ((DrawMarkerStruct*)DrawStruct)->GenCopy(); - break; - case DRAW_NOCONNECT_STRUCT_TYPE: - NewDrawStruct = ((DrawNoConnectStruct*)DrawStruct)->GenCopy(); - break; - case DRAW_TEXT_STRUCT_TYPE: - NewDrawStruct = ((DrawTextStruct*)DrawStruct)->GenCopy(); - break; - case DRAW_LABEL_STRUCT_TYPE: - NewDrawStruct = ((DrawLabelStruct*)DrawStruct)->GenCopy(); - break; - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - NewDrawStruct = ((DrawGlobalLabelStruct*)DrawStruct)->GenCopy(); - break; - case DRAW_LIB_ITEM_STRUCT_TYPE: - NewDrawStruct = ((EDA_SchComponentStruct*)DrawStruct)->GenCopy(); - break; - case DRAW_SHEET_STRUCT_TYPE: - NewDrawStruct = ((DrawSheetStruct*)DrawStruct)->GenCopy(); - break; + switch( DrawStruct->m_StructType ) + { + case DRAW_POLYLINE_STRUCT_TYPE: + NewDrawStruct = ( (DrawPolylineStruct*) DrawStruct )->GenCopy(); + break; - case DRAW_PICK_ITEM_STRUCT_TYPE: - { - DrawPickedStruct *NewPickedItem, *PickedList = NULL, - *LastPickedItem = NULL; - PickedList = (DrawPickedStruct *) DrawStruct; - while (PickedList) - { - NewPickedItem = new DrawPickedStruct(); - if (NewDrawStruct == NULL) NewDrawStruct = NewPickedItem; - if (LastPickedItem ) LastPickedItem->Pnext = NewPickedItem; - LastPickedItem = NewPickedItem; - NewPickedItem->m_PickedStruct = - DuplicateStruct(PickedList->m_PickedStruct); - PickedList = (DrawPickedStruct *)PickedList->Pnext; - } - break; - } + case DRAW_SEGMENT_STRUCT_TYPE: + NewDrawStruct = ( (EDA_DrawLineStruct*) DrawStruct )->GenCopy(); + break; - case DRAW_SHEETLABEL_STRUCT_TYPE: - case DRAW_PART_TEXT_STRUCT_TYPE: - case SCREEN_STRUCT_TYPE: - default: - { - wxString msg; - msg << wxT("DuplicateStruct error: unexpected StructType ") << - DrawStruct->m_StructType << wxT(" ") << DrawStruct->ReturnClassName(); - DisplayError(NULL, msg); - } - break; - } + case DRAW_BUSENTRY_STRUCT_TYPE: + NewDrawStruct = ( (DrawBusEntryStruct*) DrawStruct )->GenCopy(); + break; - NewDrawStruct->m_Image = DrawStruct; - return NewDrawStruct; + case DRAW_JUNCTION_STRUCT_TYPE: + NewDrawStruct = ( (DrawJunctionStruct*) DrawStruct )->GenCopy(); + break; + + case DRAW_MARKER_STRUCT_TYPE: + NewDrawStruct = ( (DrawMarkerStruct*) DrawStruct )->GenCopy(); + break; + + case DRAW_NOCONNECT_STRUCT_TYPE: + NewDrawStruct = ( (DrawNoConnectStruct*) DrawStruct )->GenCopy(); + break; + + case DRAW_TEXT_STRUCT_TYPE: + NewDrawStruct = ( (DrawTextStruct*) DrawStruct )->GenCopy(); + break; + + case DRAW_LABEL_STRUCT_TYPE: + NewDrawStruct = ( (DrawLabelStruct*) DrawStruct )->GenCopy(); + break; + + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + NewDrawStruct = ( (DrawGlobalLabelStruct*) DrawStruct )->GenCopy(); + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE: + NewDrawStruct = ( (EDA_SchComponentStruct*) DrawStruct )->GenCopy(); + break; + + case DRAW_SHEET_STRUCT_TYPE: + NewDrawStruct = ( (DrawSheetStruct*) DrawStruct )->GenCopy(); + break; + + case DRAW_PICK_ITEM_STRUCT_TYPE: + { + DrawPickedStruct* NewPickedItem, * PickedList = NULL, + * LastPickedItem = NULL; + PickedList = (DrawPickedStruct*) DrawStruct; + while( PickedList ) + { + NewPickedItem = new DrawPickedStruct(); + if( NewDrawStruct == NULL ) + NewDrawStruct = NewPickedItem; + if( LastPickedItem ) + LastPickedItem->Pnext = NewPickedItem; + LastPickedItem = NewPickedItem; + NewPickedItem->m_PickedStruct = + DuplicateStruct( PickedList->m_PickedStruct ); + PickedList = (DrawPickedStruct*) PickedList->Pnext; + } + + break; + } + + case DRAW_SHEETLABEL_STRUCT_TYPE: + case DRAW_PART_TEXT_STRUCT_TYPE: + case SCREEN_STRUCT_TYPE: + default: + { + wxString msg; + msg << wxT( "DuplicateStruct error: unexpected StructType " ) << + DrawStruct->m_StructType << wxT( " " ) << DrawStruct->ReturnClassName(); + DisplayError( NULL, msg ); + } + break; + } + + NewDrawStruct->m_Image = DrawStruct; + return NewDrawStruct; } /****************************************************/ -static void CollectStructsToDrag(SCH_SCREEN * screen) +static void CollectStructsToDrag( SCH_SCREEN* screen ) /****************************************************/ { -DrawPickedStruct * DrawStructs, *FirstPicked; -EDA_BaseStruct * Struct; -EDA_DrawLineStruct* SegmStruct; -int ox, oy, fx, fy; + DrawPickedStruct* DrawStructs, * FirstPicked; + EDA_BaseStruct* Struct; + EDA_DrawLineStruct* SegmStruct; + int ox, oy, fx, fy; - /* Set membre .m_Flags des segments */ - for(Struct = screen->EEDrawList; Struct != NULL; Struct=Struct->Pnext) - Struct->m_Flags = 0; + /* Set membre .m_Flags des segments */ + for( Struct = screen->EEDrawList; Struct != NULL; Struct = Struct->Pnext ) + Struct->m_Flags = 0; - if(screen->BlockLocate.m_BlockDrawStruct->m_StructType == DRAW_SEGMENT_STRUCT_TYPE ) - screen->BlockLocate.m_BlockDrawStruct->m_Flags = SELECTED; + if( screen->BlockLocate.m_BlockDrawStruct->m_StructType == DRAW_SEGMENT_STRUCT_TYPE ) + screen->BlockLocate.m_BlockDrawStruct->m_Flags = SELECTED; - else if (screen->BlockLocate.m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE ) - { - DrawStructs = (DrawPickedStruct *) screen->BlockLocate.m_BlockDrawStruct; - while (DrawStructs) - { - Struct = DrawStructs->m_PickedStruct; - DrawStructs = (DrawPickedStruct *)DrawStructs->Pnext; - Struct->m_Flags = SELECTED; - } - } + else if( screen->BlockLocate.m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE ) + { + DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + while( DrawStructs ) + { + Struct = DrawStructs->m_PickedStruct; + DrawStructs = (DrawPickedStruct*) DrawStructs->Pnext; + Struct->m_Flags = SELECTED; + } + } - if( screen->BlockLocate.m_Command != BLOCK_DRAG ) return; + if( screen->BlockLocate.m_Command != BLOCK_DRAG ) + return; - ox = screen->BlockLocate.GetX(); - oy = screen->BlockLocate.GetY(); - fx = screen->BlockLocate.GetRight(); - fy = screen->BlockLocate.GetBottom(); + ox = screen->BlockLocate.GetX(); + oy = screen->BlockLocate.GetY(); + fx = screen->BlockLocate.GetRight(); + fy = screen->BlockLocate.GetBottom(); - if (fx < ox) EXCHG(fx, ox); - if (fy < oy) EXCHG(fy, oy); + if( fx < ox ) + EXCHG( fx, ox ); + if( fy < oy ) + EXCHG( fy, oy ); - /* Pour Drag Block: remise sous forme de liste de structure, s'il n'y - a qu'un seul element ( pour homogeneiser les traitements ulterieurs */ - if(screen->BlockLocate.m_BlockDrawStruct->m_StructType != DRAW_PICK_ITEM_STRUCT_TYPE ) - { - DrawStructs = new DrawPickedStruct(screen->BlockLocate.m_BlockDrawStruct); - screen->BlockLocate.m_BlockDrawStruct = DrawStructs; - } + /* Pour Drag Block: remise sous forme de liste de structure, s'il n'y + * a qu'un seul element ( pour homogeneiser les traitements ulterieurs */ + if( screen->BlockLocate.m_BlockDrawStruct->m_StructType != DRAW_PICK_ITEM_STRUCT_TYPE ) + { + DrawStructs = new DrawPickedStruct( screen->BlockLocate.m_BlockDrawStruct ); + screen->BlockLocate.m_BlockDrawStruct = DrawStructs; + } - /* Suppression du deplacement des extremites de segments hors cadre - de selection */ - DrawStructs = (DrawPickedStruct *) screen->BlockLocate.m_BlockDrawStruct; - while (DrawStructs) - { - Struct = DrawStructs->m_PickedStruct; - DrawStructs = (DrawPickedStruct *)DrawStructs->Pnext; - if( Struct->m_StructType == DRAW_SEGMENT_STRUCT_TYPE) - { - SegmStruct = (EDA_DrawLineStruct*)Struct; - if( (SegmStruct->m_Start.x < ox) || (SegmStruct->m_Start.x > fx) || - (SegmStruct->m_Start.y < oy) || (SegmStruct->m_Start.y > fy) ) - SegmStruct->m_Flags |= STARTPOINT; + /* Suppression du deplacement des extremites de segments hors cadre + * de selection */ + DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + while( DrawStructs ) + { + Struct = DrawStructs->m_PickedStruct; + DrawStructs = (DrawPickedStruct*) DrawStructs->Pnext; + if( Struct->m_StructType == DRAW_SEGMENT_STRUCT_TYPE ) + { + SegmStruct = (EDA_DrawLineStruct*) Struct; + if( (SegmStruct->m_Start.x < ox) || (SegmStruct->m_Start.x > fx) + || (SegmStruct->m_Start.y < oy) || (SegmStruct->m_Start.y > fy) ) + SegmStruct->m_Flags |= STARTPOINT; - if( (SegmStruct->m_End.x < ox) || (SegmStruct->m_End.x > fx) || - (SegmStruct->m_End.y < oy) || (SegmStruct->m_End.y > fy) ) - SegmStruct->m_Flags |= ENDPOINT; - } - } + if( (SegmStruct->m_End.x < ox) || (SegmStruct->m_End.x > fx) + || (SegmStruct->m_End.y < oy) || (SegmStruct->m_End.y > fy) ) + SegmStruct->m_Flags |= ENDPOINT; + } + } - /* Recherche des elements complementaires a "dragger", c'est a dire les - fils et connexions hors bloc relies a des pins ou entries elles meme - draggees */ + /* Recherche des elements complementaires a "dragger", c'est a dire les + * fils et connexions hors bloc relies a des pins ou entries elles meme + * draggees */ - FirstPicked = DrawStructs = (DrawPickedStruct*)screen->BlockLocate.m_BlockDrawStruct; - while (DrawStructs) - { - Struct = DrawStructs->m_PickedStruct; - DrawStructs = (DrawPickedStruct * )DrawStructs->Pnext; - if( Struct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE) - { - LibEDA_BaseStruct *DrawItem; - int x, y; - DrawItem = GetNextPinPosition( (EDA_SchComponentStruct*)Struct, &x, &y); - while ( DrawItem ) - { - if( (x < ox) || (x > fx) || (y < oy) || (y > fy) ) - AddPickedItem(screen, x, y); + FirstPicked = DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + while( DrawStructs ) + { + Struct = DrawStructs->m_PickedStruct; + DrawStructs = (DrawPickedStruct*) DrawStructs->Pnext; + if( Struct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE ) + { + LibEDA_BaseStruct* DrawItem; + int x, y; + DrawItem = GetNextPinPosition( (EDA_SchComponentStruct*) Struct, &x, &y ); + while( DrawItem ) + { + if( (x < ox) || (x > fx) || (y < oy) || (y > fy) ) + AddPickedItem( screen, x, y ); - DrawItem = GetNextPinPosition( NULL, &x, &y); - } - } + DrawItem = GetNextPinPosition( NULL, &x, &y ); + } + } - if( Struct->m_StructType == DRAW_SHEET_STRUCT_TYPE) - { - DrawSheetLabelStruct * SLabel = ((DrawSheetStruct*)Struct)->m_Label; - while(SLabel) - { - if( SLabel->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE ) - AddPickedItem(screen, SLabel->m_Pos.x, SLabel->m_Pos.y); - SLabel = (DrawSheetLabelStruct*)SLabel->Pnext; - } - } + if( Struct->m_StructType == DRAW_SHEET_STRUCT_TYPE ) + { + DrawSheetLabelStruct* SLabel = ( (DrawSheetStruct*) Struct )->m_Label; + while( SLabel ) + { + if( SLabel->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE ) + AddPickedItem( screen, SLabel->m_Pos.x, SLabel->m_Pos.y ); + SLabel = (DrawSheetLabelStruct*) SLabel->Pnext; + } + } - if( Struct->m_StructType == DRAW_BUSENTRY_STRUCT_TYPE) - { - DrawBusEntryStruct * item = (DrawBusEntryStruct*)Struct; - AddPickedItem(screen, item->m_Pos.x, item->m_Pos.y); - AddPickedItem(screen, item->m_End().x, item->m_End().y); - } - } + if( Struct->m_StructType == DRAW_BUSENTRY_STRUCT_TYPE ) + { + DrawBusEntryStruct* item = (DrawBusEntryStruct*) Struct; + AddPickedItem( screen, item->m_Pos.x, item->m_Pos.y ); + AddPickedItem( screen, item->m_End().x, item->m_End().y ); + } + } } /******************************************************************/ -static void AddPickedItem( SCH_SCREEN * screen, int px, int py ) +static void AddPickedItem( SCH_SCREEN* screen, int px, int py ) /******************************************************************/ { -DrawPickedStruct * DrawStructs; -EDA_BaseStruct * Struct; + DrawPickedStruct* DrawStructs; + EDA_BaseStruct* Struct; - /* Examen de la liste des elements deja selectionnes */ - DrawStructs = (DrawPickedStruct *) screen->BlockLocate.m_BlockDrawStruct; - while (DrawStructs) - { - Struct = DrawStructs->m_PickedStruct; - DrawStructs = (DrawPickedStruct *)DrawStructs->Pnext; - switch( Struct->m_StructType ) - { - case DRAW_SEGMENT_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((EDA_DrawLineStruct*)Struct) - if( (STRUCT->m_Start.x == px) && (STRUCT->m_Start.y == py) ) - STRUCT->m_Flags &= ~STARTPOINT; + /* Examen de la liste des elements deja selectionnes */ + DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + while( DrawStructs ) + { + Struct = DrawStructs->m_PickedStruct; + DrawStructs = (DrawPickedStruct*) DrawStructs->Pnext; - if( (STRUCT->m_End.x == px) && (STRUCT->m_End.y == py) ) - STRUCT->m_Flags &= ~ENDPOINT; - break; - default: break; - } - } + switch( Struct->m_StructType ) + { + case DRAW_SEGMENT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (EDA_DrawLineStruct*) Struct ) + if( (STRUCT->m_Start.x == px) && (STRUCT->m_Start.y == py) ) + STRUCT->m_Flags &= ~STARTPOINT; - /* Examen de la liste des elements non selectionnes */ + if( (STRUCT->m_End.x == px) && (STRUCT->m_End.y == py) ) + STRUCT->m_Flags &= ~ENDPOINT; + break; - Struct = screen->EEDrawList; - while ( Struct ) - { - switch (Struct->m_StructType) - { - case TYPE_NOT_INIT: - break; - case DRAW_POLYLINE_STRUCT_TYPE: - if( Struct->m_Flags & SELECTED ) break; /* Deja en liste */ - break; + default: + break; + } + } - case DRAW_JUNCTION_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawJunctionStruct*)Struct) - if( Struct->m_Flags & SELECTED ) break; /* Deja en liste */ - if( STRUCT->m_Pos.x != px ) break; - if( STRUCT->m_Pos.y != py ) break; - DrawStructs = new DrawPickedStruct(Struct); - DrawStructs->Pnext = - (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; - screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; - break; + /* Examen de la liste des elements non selectionnes */ - case DRAW_SEGMENT_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((EDA_DrawLineStruct*)Struct) - if( Struct->m_Flags & SELECTED ) break; /* Deja en liste */ - if( (STRUCT->m_Start.x == px ) && ( STRUCT->m_Start.y == py ) ) - { - DrawStructs = new DrawPickedStruct(Struct); - DrawStructs->Pnext = - (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; - screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*)DrawStructs; - Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; - Struct->m_Flags &= ~STARTPOINT; - } - else if( (STRUCT->m_End.x == px ) && ( STRUCT->m_End.y == py ) ) - { - DrawStructs = new DrawPickedStruct(Struct); - DrawStructs->Pnext = - (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; - screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; - Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; - Struct->m_Flags &= ~ENDPOINT; - } - break; + Struct = screen->EEDrawList; + while( Struct ) + { + switch( Struct->m_StructType ) + { + case TYPE_NOT_INIT: + break; - case DRAW_BUSENTRY_STRUCT_TYPE: - break; + case DRAW_POLYLINE_STRUCT_TYPE: + if( Struct->m_Flags & SELECTED ) + break; /* Deja en liste */ + break; - case DRAW_TEXT_STRUCT_TYPE: - break; + case DRAW_JUNCTION_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawJunctionStruct*) Struct ) + if( Struct->m_Flags & SELECTED ) + break; /* Deja en liste */ + if( STRUCT->m_Pos.x != px ) + break; + if( STRUCT->m_Pos.y != py ) + break; + DrawStructs = new DrawPickedStruct( Struct ); + DrawStructs->Pnext = + (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; + break; - case DRAW_LABEL_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawLabelStruct*)Struct) - if( Struct->m_Flags & SELECTED ) break; /* Deja en liste */ - if( STRUCT->m_Pos.x != px ) break; - if( STRUCT->m_Pos.y != py ) break; - DrawStructs = new DrawPickedStruct(Struct); - DrawStructs->Pnext = - (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; - screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; - Struct->m_Flags |= SELECTED; - break; + case DRAW_SEGMENT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (EDA_DrawLineStruct*) Struct ) + if( Struct->m_Flags & SELECTED ) + break; /* Deja en liste */ + if( (STRUCT->m_Start.x == px ) && ( STRUCT->m_Start.y == py ) ) + { + DrawStructs = new DrawPickedStruct( Struct ); + DrawStructs->Pnext = + (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; + Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; + Struct->m_Flags &= ~STARTPOINT; + } + else if( (STRUCT->m_End.x == px ) && ( STRUCT->m_End.y == py ) ) + { + DrawStructs = new DrawPickedStruct( Struct ); + DrawStructs->Pnext = + (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; + Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; + Struct->m_Flags &= ~ENDPOINT; + } + break; - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawGlobalLabelStruct*)Struct) - if( Struct->m_Flags & SELECTED ) break; /* Deja en liste */ - if( STRUCT->m_Pos.x != px ) break; - if( STRUCT->m_Pos.y != py ) break; - DrawStructs = new DrawPickedStruct(Struct); - DrawStructs->Pnext = - (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; - screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; - Struct->m_Flags |= SELECTED; - break; + case DRAW_BUSENTRY_STRUCT_TYPE: + break; - case DRAW_LIB_ITEM_STRUCT_TYPE: - break; + case DRAW_TEXT_STRUCT_TYPE: + break; - case DRAW_SHEET_STRUCT_TYPE: - break; + case DRAW_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawLabelStruct*) Struct ) + if( Struct->m_Flags & SELECTED ) + break; /* Deja en liste */ + if( STRUCT->m_Pos.x != px ) + break; + if( STRUCT->m_Pos.y != py ) + break; + DrawStructs = new DrawPickedStruct( Struct ); + DrawStructs->Pnext = + (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; + Struct->m_Flags |= SELECTED; + break; - case DRAW_SHEETLABEL_STRUCT_TYPE: - break; + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawGlobalLabelStruct*) Struct ) + if( Struct->m_Flags & SELECTED ) + break; /* Deja en liste */ + if( STRUCT->m_Pos.x != px ) + break; + if( STRUCT->m_Pos.y != py ) + break; + DrawStructs = new DrawPickedStruct( Struct ); + DrawStructs->Pnext = + (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; + Struct->m_Flags |= SELECTED; + break; - case DRAW_PICK_ITEM_STRUCT_TYPE: - break; + case DRAW_LIB_ITEM_STRUCT_TYPE: + break; - case DRAW_MARKER_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawMarkerStruct*)Struct) - if( Struct->m_Flags & SELECTED ) break; /* Deja en liste */ - if( STRUCT->m_Pos.x != px ) break; - if( STRUCT->m_Pos.y != py ) break; - DrawStructs = new DrawPickedStruct(Struct); - DrawStructs->Pnext = - (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; - screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; - Struct->m_Flags |= SELECTED; - break; + case DRAW_SHEET_STRUCT_TYPE: + break; - case DRAW_NOCONNECT_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawNoConnectStruct*)Struct) - if( Struct->m_Flags & SELECTED ) break; /* Deja en liste */ - if( STRUCT->m_Pos.x != px ) break; - if( STRUCT->m_Pos.y != py ) break; - DrawStructs = new DrawPickedStruct(Struct); - DrawStructs->Pnext = - (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; - screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; - Struct->m_Flags |= SELECTED; - break; + case DRAW_SHEETLABEL_STRUCT_TYPE: + break; - default: - break; - } - Struct = Struct->Pnext; - } + case DRAW_PICK_ITEM_STRUCT_TYPE: + break; + + case DRAW_MARKER_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawMarkerStruct*) Struct ) + if( Struct->m_Flags & SELECTED ) + break; /* Deja en liste */ + if( STRUCT->m_Pos.x != px ) + break; + if( STRUCT->m_Pos.y != py ) + break; + DrawStructs = new DrawPickedStruct( Struct ); + DrawStructs->Pnext = + (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; + Struct->m_Flags |= SELECTED; + break; + + case DRAW_NOCONNECT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawNoConnectStruct*) Struct ) + if( Struct->m_Flags & SELECTED ) + break; /* Deja en liste */ + if( STRUCT->m_Pos.x != px ) + break; + if( STRUCT->m_Pos.y != py ) + break; + DrawStructs = new DrawPickedStruct( Struct ); + DrawStructs->Pnext = + (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; + Struct->m_Flags |= SELECTED; + break; + + default: + break; + } + Struct = Struct->Pnext; + } } + /*********************************************************************************/ -static LibEDA_BaseStruct * GetNextPinPosition( EDA_SchComponentStruct * DrawLibItem, - int * px, int * py ) +static LibEDA_BaseStruct* GetNextPinPosition( EDA_SchComponentStruct* DrawLibItem, + int* px, int* py ) /*********************************************************************************/ { -EDA_LibComponentStruct *Entry; -static LibEDA_BaseStruct *NextItem; -static int Multi, convert, PartX, PartY, TransMat[2][2]; -LibEDA_BaseStruct *DEntry; -int x2, y2, orient; -LibDrawPin * Pin; + EDA_LibComponentStruct* Entry; + static LibEDA_BaseStruct* NextItem; + static int Multi, convert, PartX, PartY, TransMat[2][2]; + LibEDA_BaseStruct* DEntry; + int x2, y2, orient; + LibDrawPin* Pin; - if( DrawLibItem ) - { - NextItem = NULL; - if((Entry = FindLibPart(DrawLibItem->m_ChipName.GetData(),wxEmptyString,FIND_ROOT)) == NULL) - return(NULL); - DEntry = Entry->m_Drawings; - Multi = DrawLibItem->m_Multi; - convert = DrawLibItem->m_Convert; - PartX = DrawLibItem->m_Pos.x; - PartY = DrawLibItem->m_Pos.y; - memcpy(TransMat, DrawLibItem->m_Transform, sizeof(TransMat) ); - } - else DEntry = NextItem; + if( DrawLibItem ) + { + NextItem = NULL; + if( ( Entry = FindLibPart( DrawLibItem->m_ChipName.GetData(), wxEmptyString, + FIND_ROOT ) ) == NULL ) + return NULL; + DEntry = Entry->m_Drawings; + Multi = DrawLibItem->m_Multi; + convert = DrawLibItem->m_Convert; + PartX = DrawLibItem->m_Pos.x; + PartY = DrawLibItem->m_Pos.y; + memcpy( TransMat, DrawLibItem->m_Transform, sizeof(TransMat) ); + } + else + DEntry = NextItem; - for( ; DEntry != NULL; DEntry = DEntry->Next()) - { - /* Elimination des elements non relatifs a l'unite */ - if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) ) continue; - if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) ) - continue; - if( DEntry->m_StructType != COMPONENT_PIN_DRAW_TYPE ) continue; + for( ; DEntry != NULL; DEntry = DEntry->Next() ) + { + /* Elimination des elements non relatifs a l'unite */ + if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) ) + continue; + if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) ) + continue; + if( DEntry->m_StructType != COMPONENT_PIN_DRAW_TYPE ) + continue; - Pin = (LibDrawPin * ) DEntry; + Pin = (LibDrawPin*) DEntry; - /* Calcul de l'orientation reelle de la Pin */ - orient = Pin->ReturnPinDrawOrient(TransMat); + /* Calcul de l'orientation reelle de la Pin */ + orient = Pin->ReturnPinDrawOrient( TransMat ); - /* Calcul de la position du point de reference */ - x2 = PartX + (TransMat[0][0] * Pin->m_Pos.x) - + (TransMat[0][1] * Pin->m_Pos.y); - y2 = PartY + (TransMat[1][0] * Pin->m_Pos.x) - + (TransMat[1][1] * Pin->m_Pos.y); - *px = x2; *py = y2; - NextItem = DEntry->Next(); - return(DEntry); - } + /* Calcul de la position du point de reference */ + x2 = PartX + (TransMat[0][0] * Pin->m_Pos.x) + + (TransMat[0][1] * Pin->m_Pos.y); + y2 = PartY + (TransMat[1][0] * Pin->m_Pos.x) + + (TransMat[1][1] * Pin->m_Pos.y); + *px = x2; *py = y2; + NextItem = DEntry->Next(); + return DEntry; + } - NextItem = NULL; - return(NULL); + NextItem = NULL; + return NULL; } - diff --git a/eeschema/block_libedit.cpp b/eeschema/block_libedit.cpp index 1255a3e9f6..9da5575cc2 100644 --- a/eeschema/block_libedit.cpp +++ b/eeschema/block_libedit.cpp @@ -18,653 +18,691 @@ /* Fonctions exportees */ /* Fonctions Locales */ -static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); -static int MarkItemsInBloc(EDA_LibComponentStruct * LibComponent, - EDA_Rect & Rect); +static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); +static int MarkItemsInBloc( EDA_LibComponentStruct* LibComponent, + EDA_Rect& Rect ); -static void ClearMarkItems(EDA_LibComponentStruct * LibComponent); -static void CopyMarkedItems(EDA_LibComponentStruct *LibEntry, wxPoint offset); -static void MoveMarkedItems(EDA_LibComponentStruct *LibEntry, wxPoint offset); -static void MirrorMarkedItems(EDA_LibComponentStruct *LibEntry, wxPoint offset); -static void DeleteMarkedItems(EDA_LibComponentStruct *LibEntry); +static void ClearMarkItems( EDA_LibComponentStruct* LibComponent ); +static void CopyMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ); +static void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ); +static void MirrorMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ); +static void DeleteMarkedItems( EDA_LibComponentStruct* LibEntry ); /*********************************************************/ -void ClearMarkItems(EDA_LibComponentStruct * LibComponent) +void ClearMarkItems( EDA_LibComponentStruct* LibComponent ) /*********************************************************/ { -LibEDA_BaseStruct * item; + LibEDA_BaseStruct* item; - if ( LibComponent == NULL ) return; + if( LibComponent == NULL ) + return; - item = LibComponent->m_Drawings; - for ( ; item != NULL; item = item->Next() ) - item->m_Flags = item->m_Selected = 0; + item = LibComponent->m_Drawings; + for( ; item != NULL; item = item->Next() ) + item->m_Flags = item->m_Selected = 0; } + /***************************************************************/ -int MarkItemsInBloc(EDA_LibComponentStruct * LibComponent, - EDA_Rect & Rect) +int MarkItemsInBloc( EDA_LibComponentStruct* LibComponent, + EDA_Rect& Rect ) /***************************************************************/ + /* Mark items inside rect. - Items are inside rect when an end point is inside rect - - Rules for convert drawings and other parts ( for multi part per package): - - Commons are always marked - - Specific graphic shapes must agree with the current displayed part and convert - - Because most of pins are specific to current part and current convert: - - if g_EditPinByPinIsOn == TRUE, or flag .m_UnitSelectionLocked == TRUE, - only the pins specific to current part and current convert are marked - - all specific to current convert pins are marked; -*/ + * Items are inside rect when an end point is inside rect + * + * Rules for convert drawings and other parts ( for multi part per package): + * - Commons are always marked + * - Specific graphic shapes must agree with the current displayed part and convert + * - Because most of pins are specific to current part and current convert: + * - if g_EditPinByPinIsOn == TRUE, or flag .m_UnitSelectionLocked == TRUE, + * only the pins specific to current part and current convert are marked + * - all specific to current convert pins are marked; + */ { -LibEDA_BaseStruct * item; -int ItemsCount = 0; -wxPoint pos; -bool ItemIsInOtherPart, ItemIsInOtherConvert; + LibEDA_BaseStruct* item; + int ItemsCount = 0; + wxPoint pos; + bool ItemIsInOtherPart, ItemIsInOtherConvert; - if ( LibComponent == NULL ) return 0; + if( LibComponent == NULL ) + return 0; - item = LibComponent->m_Drawings; - for ( ; item != NULL; item = item->Next() ) - { - item->m_Selected = 0; - // Do not consider other units or other convert items: - ItemIsInOtherPart = ItemIsInOtherConvert = FALSE; - if( item->m_Unit && (item->m_Unit != CurrentUnit) ) - ItemIsInOtherPart = TRUE; - if( item->m_Convert && (item->m_Convert != CurrentConvert) ) - ItemIsInOtherConvert = TRUE; - if ( ItemIsInOtherPart || ItemIsInOtherConvert ) - { - if (item->m_StructType == COMPONENT_PIN_DRAW_TYPE) - { // Specific rules for pins: - if ( g_EditPinByPinIsOn ) continue; - if ( LibComponent->m_UnitSelectionLocked ) continue; - if ( ItemIsInOtherConvert ) continue; - } - else continue; - } - switch( item->m_StructType ) - { - case COMPONENT_ARC_DRAW_TYPE: - { - pos = ((LibDrawArc*)item)->m_ArcStart; pos.y = -pos.y; - if ( Rect.Inside(pos) ) - { - item->m_Selected = IS_SELECTED; - ItemsCount++; - } - pos = ((LibDrawArc*)item)->m_ArcEnd; pos.y = -pos.y; - if ( Rect.Inside(pos) ) - { - item->m_Selected = IS_SELECTED; - ItemsCount++; - } - break; - } + item = LibComponent->m_Drawings; + for( ; item != NULL; item = item->Next() ) + { + item->m_Selected = 0; - case COMPONENT_CIRCLE_DRAW_TYPE: - pos = ((LibDrawCircle*)item)->m_Pos; pos.y = -pos.y; - if ( Rect.Inside(pos) ) - { - item->m_Selected = IS_SELECTED; - ItemsCount++; - } - break; + // Do not consider other units or other convert items: + ItemIsInOtherPart = ItemIsInOtherConvert = FALSE; + if( item->m_Unit && (item->m_Unit != CurrentUnit) ) + ItemIsInOtherPart = TRUE; + if( item->m_Convert && (item->m_Convert != CurrentConvert) ) + ItemIsInOtherConvert = TRUE; + if( ItemIsInOtherPart || ItemIsInOtherConvert ) + { + if( item->m_StructType == COMPONENT_PIN_DRAW_TYPE ) + { // Specific rules for pins: + if( g_EditPinByPinIsOn ) + continue; + if( LibComponent->m_UnitSelectionLocked ) + continue; + if( ItemIsInOtherConvert ) + continue; + } + else + continue; + } - case COMPONENT_RECT_DRAW_TYPE: - pos = ((LibDrawSquare*)item)->m_Pos; pos.y = -pos.y; - if ( Rect.Inside(pos) ) - { - item->m_Selected = IS_SELECTED; - ItemsCount++; - } - pos = ((LibDrawSquare*)item)->m_End; pos.y = -pos.y; - if ( Rect.Inside(pos) ) - { - item->m_Selected = IS_SELECTED; - ItemsCount++; - } - break; + switch( item->m_StructType ) + { + case COMPONENT_ARC_DRAW_TYPE: + { + pos = ( (LibDrawArc*) item )->m_ArcStart; pos.y = -pos.y; + if( Rect.Inside( pos ) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + pos = ( (LibDrawArc*) item )->m_ArcEnd; pos.y = -pos.y; + if( Rect.Inside( pos ) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + break; + } - case COMPONENT_POLYLINE_DRAW_TYPE: - { - int ii , imax = ((LibDrawPolyline*)item)->n * 2; - int * ptpoly = ((LibDrawPolyline*)item)->PolyList; - for ( ii = 0; ii < imax; ii += 2) - { - pos.x = ptpoly[ii]; pos.y = -ptpoly[ii + 1]; - if ( Rect.Inside(pos) ) - { - item->m_Selected = IS_SELECTED; - ItemsCount++; - break; - } - } - } - break; + case COMPONENT_CIRCLE_DRAW_TYPE: + pos = ( (LibDrawCircle*) item )->m_Pos; pos.y = -pos.y; + if( Rect.Inside( pos ) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + break; - case COMPONENT_LINE_DRAW_TYPE: - break; + case COMPONENT_RECT_DRAW_TYPE: + pos = ( (LibDrawSquare*) item )->m_Pos; pos.y = -pos.y; + if( Rect.Inside( pos ) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + pos = ( (LibDrawSquare*) item )->m_End; pos.y = -pos.y; + if( Rect.Inside( pos ) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + break; - case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: - pos = ((LibDrawText*)item)->m_Pos; pos.y = -pos.y; - if ( Rect.Inside(pos) ) - { - item->m_Selected = IS_SELECTED; - ItemsCount++; - } - break; + case COMPONENT_POLYLINE_DRAW_TYPE: + { + int ii, imax = ( (LibDrawPolyline*) item )->n * 2; + int* ptpoly = ( (LibDrawPolyline*) item )->PolyList; + for( ii = 0; ii < imax; ii += 2 ) + { + pos.x = ptpoly[ii]; pos.y = -ptpoly[ii + 1]; + if( Rect.Inside( pos ) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + break; + } + } + } + break; - case COMPONENT_PIN_DRAW_TYPE: - #undef STRUCT - #define STRUCT ((LibDrawPin*)item) - pos = STRUCT->m_Pos; pos.y = -pos.y; - if ( Rect.Inside(pos) ) - { - item->m_Selected = IS_SELECTED; - ItemsCount++; - } - pos = STRUCT->ReturnPinEndPoint(); pos.y = -pos.y; - if ( Rect.Inside(pos) ) - { - item->m_Selected = IS_SELECTED; - ItemsCount++; - } - break; + case COMPONENT_LINE_DRAW_TYPE: + break; - case COMPONENT_FIELD_DRAW_TYPE: - break; - default: - break; - } + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + pos = ( (LibDrawText*) item )->m_Pos; pos.y = -pos.y; + if( Rect.Inside( pos ) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + break; - } - return ItemsCount; + case COMPONENT_PIN_DRAW_TYPE: + #undef STRUCT + #define STRUCT ( (LibDrawPin*) item ) + pos = STRUCT->m_Pos; pos.y = -pos.y; + if( Rect.Inside( pos ) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + pos = STRUCT->ReturnPinEndPoint(); pos.y = -pos.y; + if( Rect.Inside( pos ) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + break; + case COMPONENT_FIELD_DRAW_TYPE: + break; + + default: + break; + } + } + + return ItemsCount; } + /*************************************************************************/ -int WinEDA_LibeditFrame::ReturnBlockCommand(int key) +int WinEDA_LibeditFrame::ReturnBlockCommand( int key ) /*************************************************************************/ + /* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to - the key (ALT, SHIFT ALT ..) -*/ + * the key (ALT, SHIFT ALT ..) + */ { -int cmd; + int cmd; - switch ( key ) - { - default: - cmd = key & 0x255; - break; + switch( key ) + { + default: + cmd = key & 0x255; + break; - case -1: - cmd = BLOCK_PRESELECT_MOVE; - break; + case - 1: + cmd = BLOCK_PRESELECT_MOVE; + break; - case 0: - cmd = BLOCK_MOVE; - break; + case 0: + cmd = BLOCK_MOVE; + break; - case GR_KB_ALT: - case GR_KB_SHIFT: - cmd = BLOCK_COPY; - break; + case GR_KB_ALT: + case GR_KB_SHIFT: + cmd = BLOCK_COPY; + break; - case GR_KB_SHIFTCTRL: - cmd = BLOCK_DELETE; - break; + case GR_KB_SHIFTCTRL: + cmd = BLOCK_DELETE; + break; - case GR_KB_CTRL: - cmd = BLOCK_INVERT; - break; + case GR_KB_CTRL: + cmd = BLOCK_INVERT; + break; - case MOUSE_MIDDLE: - cmd = BLOCK_ZOOM; - break; - } + case MOUSE_MIDDLE: + cmd = BLOCK_ZOOM; + break; + } - return cmd; + return cmd; } /****************************************************/ -int WinEDA_LibeditFrame::HandleBlockEnd(wxDC * DC) +int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) /****************************************************/ + /* Command BLOCK END (end of block sizing) - return : - 0 if command finished (zoom, delete ...) - 1 if HandleBlockPlace must follow (items found, and a block place command must follow) -*/ + * return : + * 0 if command finished (zoom, delete ...) + * 1 if HandleBlockPlace must follow (items found, and a block place command must follow) + */ { -int ItemsCount = 0, MustDoPlace = 0; + int ItemsCount = 0, MustDoPlace = 0; - if ( GetScreen()->BlockLocate.m_BlockDrawStruct ) - { - BlockState state = GetScreen()->BlockLocate.m_State; - CmdBlockType command = GetScreen()->BlockLocate.m_Command; - DrawPanel->ForceCloseManageCurseur(DrawPanel, DC); - GetScreen()->BlockLocate.m_State = state; - GetScreen()->BlockLocate.m_Command = command; - DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines; - DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand; - GetScreen()->m_Curseur.x = GetScreen()->BlockLocate.GetRight(); - GetScreen()->m_Curseur.y = GetScreen()->BlockLocate.GetBottom(); - DrawPanel->MouseToCursorSchema(); - } + if( GetScreen()->BlockLocate.m_BlockDrawStruct ) + { + BlockState state = GetScreen()->BlockLocate.m_State; + CmdBlockType command = GetScreen()->BlockLocate.m_Command; + DrawPanel->ForceCloseManageCurseur( DrawPanel, DC ); + GetScreen()->BlockLocate.m_State = state; + GetScreen()->BlockLocate.m_Command = command; + DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines; + DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand; + GetScreen()->m_Curseur.x = GetScreen()->BlockLocate.GetRight(); + GetScreen()->m_Curseur.y = GetScreen()->BlockLocate.GetBottom(); + DrawPanel->MouseToCursorSchema(); + } - switch( GetScreen()->BlockLocate.m_Command ) - { - case BLOCK_IDLE: - DisplayError(this, wxT("Error in HandleBlockPLace") ); - break; + switch( GetScreen()->BlockLocate.m_Command ) + { + case BLOCK_IDLE: + DisplayError( this, wxT( "Error in HandleBlockPLace" ) ); + break; - case BLOCK_DRAG: /* Drag */ - case BLOCK_MOVE: /* Move */ - case BLOCK_COPY: /* Copy */ - ItemsCount = MarkItemsInBloc(CurrentLibEntry, GetScreen()->BlockLocate); - if ( ItemsCount ) - { - MustDoPlace = 1; - if(DrawPanel->ManageCurseur != NULL) - { - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - DrawPanel->ManageCurseur = DrawMovingBlockOutlines; - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - } - GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; - DrawPanel->Refresh(TRUE); - } - break; + case BLOCK_DRAG: /* Drag */ + case BLOCK_MOVE: /* Move */ + case BLOCK_COPY: /* Copy */ + ItemsCount = MarkItemsInBloc( CurrentLibEntry, GetScreen()->BlockLocate ); + if( ItemsCount ) + { + MustDoPlace = 1; + if( DrawPanel->ManageCurseur != NULL ) + { + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + } + GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; + DrawPanel->Refresh( TRUE ); + } + break; - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ - MustDoPlace = 1; - DrawPanel->ManageCurseur = DrawMovingBlockOutlines; - GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; - break; + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + MustDoPlace = 1; + DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; + break; - case BLOCK_DELETE: /* Delete */ - ItemsCount = MarkItemsInBloc(CurrentLibEntry, GetScreen()->BlockLocate); - if ( ItemsCount ) SaveCopyInUndoList(CurrentLibEntry); - DeleteMarkedItems(CurrentLibEntry); - break; + case BLOCK_DELETE: /* Delete */ + ItemsCount = MarkItemsInBloc( CurrentLibEntry, GetScreen()->BlockLocate ); + if( ItemsCount ) + SaveCopyInUndoList( CurrentLibEntry ); + DeleteMarkedItems( CurrentLibEntry ); + break; - case BLOCK_SAVE: /* Save */ - case BLOCK_PASTE: - case BLOCK_ROTATE: - case BLOCK_MIRROR_X: - case BLOCK_MIRROR_Y: - break; + case BLOCK_SAVE: /* Save */ + case BLOCK_PASTE: + case BLOCK_ROTATE: + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: + break; - case BLOCK_INVERT: - ItemsCount = MarkItemsInBloc(CurrentLibEntry, GetScreen()->BlockLocate); - if ( ItemsCount ) SaveCopyInUndoList(CurrentLibEntry); - MirrorMarkedItems(CurrentLibEntry, GetScreen()->BlockLocate.Centre()); - break; + case BLOCK_INVERT: + ItemsCount = MarkItemsInBloc( CurrentLibEntry, GetScreen()->BlockLocate ); + if( ItemsCount ) + SaveCopyInUndoList( CurrentLibEntry ); + MirrorMarkedItems( CurrentLibEntry, GetScreen()->BlockLocate.Centre() ); + break; - case BLOCK_ZOOM: /* Window Zoom */ - Window_Zoom( GetScreen()->BlockLocate ); - break; + case BLOCK_ZOOM: /* Window Zoom */ + Window_Zoom( GetScreen()->BlockLocate ); + break; - case BLOCK_ABORT: - break; + case BLOCK_ABORT: + break; - case BLOCK_SELECT_ITEMS_ONLY: - break; - } + case BLOCK_SELECT_ITEMS_ONLY: + break; + } - if ( MustDoPlace <= 0 ) - { - if ( GetScreen()->BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY ) - { - ClearMarkItems(CurrentLibEntry); - } - GetScreen()->BlockLocate.m_Flags = 0; - GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; - GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->m_CurrentItem = NULL; - SetToolID(m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); - DrawPanel->Refresh(TRUE); - } + if( MustDoPlace <= 0 ) + { + if( GetScreen()->BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY ) + { + ClearMarkItems( CurrentLibEntry ); + } + GetScreen()->BlockLocate.m_Flags = 0; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->SetCurItem( NULL ); + SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); + DrawPanel->Refresh( TRUE ); + } - return(MustDoPlace); + return MustDoPlace; } /******************************************************/ -void WinEDA_LibeditFrame::HandleBlockPlace(wxDC * DC) +void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC ) /******************************************************/ + /* Routine to handle the BLOCK PLACE commande - Last routine for block operation for: - - block move & drag - - block copie & paste -*/ + * Last routine for block operation for: + * - block move & drag + * - block copie & paste + */ { -bool err = FALSE; + bool err = FALSE; - if(DrawPanel->ManageCurseur == NULL) - { - err = TRUE; - DisplayError(this, wxT("HandleBlockPLace : ManageCurseur = NULL") ); - } + if( DrawPanel->ManageCurseur == NULL ) + { + err = TRUE; + DisplayError( this, wxT( "HandleBlockPLace : ManageCurseur = NULL" ) ); + } - GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; - switch(GetScreen()->BlockLocate.m_Command ) - { - case BLOCK_IDLE: - err = TRUE; - break; + switch( GetScreen()->BlockLocate.m_Command ) + { + case BLOCK_IDLE: + err = TRUE; + break; - case BLOCK_DRAG: /* Drag */ - case BLOCK_MOVE: /* Move */ - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ - GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; - SaveCopyInUndoList(CurrentLibEntry); - MoveMarkedItems(CurrentLibEntry, GetScreen()->BlockLocate.m_MoveVector); - DrawPanel->Refresh(TRUE); - break; + case BLOCK_DRAG: /* Drag */ + case BLOCK_MOVE: /* Move */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + SaveCopyInUndoList( CurrentLibEntry ); + MoveMarkedItems( CurrentLibEntry, GetScreen()->BlockLocate.m_MoveVector ); + DrawPanel->Refresh( TRUE ); + break; - case BLOCK_COPY: /* Copy */ - GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; - SaveCopyInUndoList(CurrentLibEntry); - CopyMarkedItems(CurrentLibEntry, GetScreen()->BlockLocate.m_MoveVector); - break; + case BLOCK_COPY: /* Copy */ + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + SaveCopyInUndoList( CurrentLibEntry ); + CopyMarkedItems( CurrentLibEntry, GetScreen()->BlockLocate.m_MoveVector ); + break; - case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */ - GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; - break; + case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */ + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + break; - case BLOCK_INVERT: /* Invert by popup menu, from block move */ - SaveCopyInUndoList(CurrentLibEntry); - MirrorMarkedItems(CurrentLibEntry, GetScreen()->BlockLocate.Centre()); - break; + case BLOCK_INVERT: /* Invert by popup menu, from block move */ + SaveCopyInUndoList( CurrentLibEntry ); + MirrorMarkedItems( CurrentLibEntry, GetScreen()->BlockLocate.Centre() ); + break; - case BLOCK_ZOOM: // Handled by HandleBlockEnd - case BLOCK_DELETE: - case BLOCK_SAVE: - case BLOCK_ROTATE: - case BLOCK_ABORT: - default: - break; - } + case BLOCK_ZOOM: // Handled by HandleBlockEnd + case BLOCK_DELETE: + case BLOCK_SAVE: + case BLOCK_ROTATE: + case BLOCK_ABORT: + default: + break; + } - GetScreen()->SetModify(); + GetScreen()->SetModify(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->BlockLocate.m_Flags = 0; - GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; - GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; - GetScreen()->m_CurrentItem = NULL; - DrawPanel->Refresh(TRUE); + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->BlockLocate.m_Flags = 0; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + GetScreen()->SetCurItem( NULL ); + DrawPanel->Refresh( TRUE ); - SetToolID(m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); + SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); } /************************************************************************/ -static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, - bool erase ) +static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, + bool erase ) /************************************************************************/ + /* Retrace le contour du block de recherche de structures - L'ensemble du block suit le curseur -*/ + * L'ensemble du block suit le curseur + */ { -DrawBlockStruct * PtBlock; -BASE_SCREEN * screen = panel->m_Parent->GetScreen(); -LibEDA_BaseStruct * item; -wxPoint move_offset; + DrawBlockStruct* PtBlock; + BASE_SCREEN* screen = panel->m_Parent->GetScreen(); + LibEDA_BaseStruct* item; + wxPoint move_offset; - PtBlock = &panel->GetScreen()->BlockLocate; - GRSetDrawMode(DC, g_XorMode); + PtBlock = &panel->GetScreen()->BlockLocate; + GRSetDrawMode( DC, g_XorMode ); - /* Effacement ancien cadre */ - if( erase ) - { - PtBlock->Offset(PtBlock->m_MoveVector); - PtBlock->Draw(panel, DC); - PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y); + /* Effacement ancien cadre */ + if( erase ) + { + PtBlock->Offset( PtBlock->m_MoveVector ); + PtBlock->Draw( panel, DC ); + PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y ); - if ( CurrentLibEntry ) - { - item = CurrentLibEntry->m_Drawings; - for ( ; item != NULL; item = item->Next() ) - { - if ( item->m_Selected == 0 ) continue; - /* Do not draw items for other units */ - if( CurrentUnit && item->m_Unit && (item->m_Unit != CurrentUnit) ) - continue; - if( CurrentConvert && item->m_Convert && (item->m_Convert != CurrentConvert) ) - continue; - DrawLibraryDrawStruct(panel, DC, CurrentLibEntry, - PtBlock->m_MoveVector.x , PtBlock->m_MoveVector.y, - item, CurrentUnit, g_XorMode); - } - } - } + if( CurrentLibEntry ) + { + item = CurrentLibEntry->m_Drawings; + for( ; item != NULL; item = item->Next() ) + { + if( item->m_Selected == 0 ) + continue; + /* Do not draw items for other units */ + if( CurrentUnit && item->m_Unit && (item->m_Unit != CurrentUnit) ) + continue; + if( CurrentConvert && item->m_Convert && (item->m_Convert != CurrentConvert) ) + continue; + DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, + PtBlock->m_MoveVector.x, PtBlock->m_MoveVector.y, + item, CurrentUnit, g_XorMode ); + } + } + } - /* Redessin nouvel affichage */ - PtBlock->m_MoveVector.x = screen->m_Curseur.x - PtBlock->m_BlockLastCursorPosition.x; - PtBlock->m_MoveVector.y = screen->m_Curseur.y - PtBlock->m_BlockLastCursorPosition.y; + /* Redessin nouvel affichage */ + PtBlock->m_MoveVector.x = screen->m_Curseur.x - PtBlock->m_BlockLastCursorPosition.x; + PtBlock->m_MoveVector.y = screen->m_Curseur.y - PtBlock->m_BlockLastCursorPosition.y; - GRSetDrawMode(DC, g_XorMode); - PtBlock->Offset(PtBlock->m_MoveVector); - PtBlock->Draw(panel, DC); - PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y); + GRSetDrawMode( DC, g_XorMode ); + PtBlock->Offset( PtBlock->m_MoveVector ); + PtBlock->Draw( panel, DC ); + PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y ); - if ( CurrentLibEntry ) - { - item = CurrentLibEntry->m_Drawings; - for ( ; item != NULL; item = item->Next() ) - { - if ( item->m_Selected == 0 ) continue; - /* Do not draw items for other units */ - if( CurrentUnit && item->m_Unit && (item->m_Unit != CurrentUnit) ) - continue; - if( CurrentConvert && item->m_Convert && (item->m_Convert != CurrentConvert) ) - continue; - DrawLibraryDrawStruct(panel, DC, CurrentLibEntry, - PtBlock->m_MoveVector.x , PtBlock->m_MoveVector.y, - item, CurrentUnit, g_XorMode); - } - } + if( CurrentLibEntry ) + { + item = CurrentLibEntry->m_Drawings; + for( ; item != NULL; item = item->Next() ) + { + if( item->m_Selected == 0 ) + continue; + /* Do not draw items for other units */ + if( CurrentUnit && item->m_Unit && (item->m_Unit != CurrentUnit) ) + continue; + if( CurrentConvert && item->m_Convert && (item->m_Convert != CurrentConvert) ) + continue; + DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, + PtBlock->m_MoveVector.x, PtBlock->m_MoveVector.y, + item, CurrentUnit, g_XorMode ); + } + } } + /****************************************************************************/ -void CopyMarkedItems(EDA_LibComponentStruct *LibEntry, wxPoint offset) +void CopyMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) /****************************************************************************/ + /* Copy marked items, at new position = old position + offset -*/ + */ { -LibEDA_BaseStruct * item; + LibEDA_BaseStruct* item; - if ( LibEntry == NULL ) return; + if( LibEntry == NULL ) + return; - item = LibEntry->m_Drawings; - for ( ; item != NULL; item = item->Next() ) - { - if ( item->m_Selected == 0 ) continue; - item->m_Selected = 0; - LibEDA_BaseStruct * newitem = CopyDrawEntryStruct( NULL, item); - newitem->m_Selected = IS_SELECTED; - newitem->Pnext = LibEntry->m_Drawings; - LibEntry->m_Drawings = newitem; - } + item = LibEntry->m_Drawings; + for( ; item != NULL; item = item->Next() ) + { + if( item->m_Selected == 0 ) + continue; + item->m_Selected = 0; + LibEDA_BaseStruct* newitem = CopyDrawEntryStruct( NULL, item ); + newitem->m_Selected = IS_SELECTED; + newitem->Pnext = LibEntry->m_Drawings; + LibEntry->m_Drawings = newitem; + } - MoveMarkedItems(LibEntry, offset); + MoveMarkedItems( LibEntry, offset ); } + /****************************************************************************/ -void MoveMarkedItems(EDA_LibComponentStruct *LibEntry, wxPoint offset) +void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) /****************************************************************************/ + /* Move marked items, at new position = old position + offset -*/ + */ { -LibEDA_BaseStruct * item; + LibEDA_BaseStruct* item; - if ( LibEntry == NULL ) return; + if( LibEntry == NULL ) + return; - offset.y = - offset.y; // Y axis for lib items is Down to Up: reverse y offset value - item = LibEntry->m_Drawings; - for ( ; item != NULL; item = item->Next() ) - { - if ( item->m_Selected == 0 ) continue; + offset.y = -offset.y; // Y axis for lib items is Down to Up: reverse y offset value + item = LibEntry->m_Drawings; + for( ; item != NULL; item = item->Next() ) + { + if( item->m_Selected == 0 ) + continue; - switch ( item->m_StructType ) - { - case COMPONENT_PIN_DRAW_TYPE: - ((LibDrawPin*)item)->m_Pos.x += offset.x; - ((LibDrawPin*)item)->m_Pos.y += offset.y; - break; + switch( item->m_StructType ) + { + case COMPONENT_PIN_DRAW_TYPE: + ( (LibDrawPin*) item )->m_Pos.x += offset.x; + ( (LibDrawPin*) item )->m_Pos.y += offset.y; + break; - case COMPONENT_ARC_DRAW_TYPE: - { - ((LibDrawArc*)item)->m_Pos.x += offset.x; - ((LibDrawArc*)item)->m_Pos.y += offset.y; - ((LibDrawArc*)item)->m_ArcStart.x += offset.x; - ((LibDrawArc*)item)->m_ArcStart.y += offset.y; - ((LibDrawArc*)item)->m_ArcEnd.x += offset.x; - ((LibDrawArc*)item)->m_ArcEnd.y += offset.y; - break; - } + case COMPONENT_ARC_DRAW_TYPE: + { + ( (LibDrawArc*) item )->m_Pos.x += offset.x; + ( (LibDrawArc*) item )->m_Pos.y += offset.y; + ( (LibDrawArc*) item )->m_ArcStart.x += offset.x; + ( (LibDrawArc*) item )->m_ArcStart.y += offset.y; + ( (LibDrawArc*) item )->m_ArcEnd.x += offset.x; + ( (LibDrawArc*) item )->m_ArcEnd.y += offset.y; + break; + } - case COMPONENT_CIRCLE_DRAW_TYPE: - ((LibDrawCircle*)item)->m_Pos.x += offset.x; - ((LibDrawCircle*)item)->m_Pos.y += offset.y; - break; + case COMPONENT_CIRCLE_DRAW_TYPE: + ( (LibDrawCircle*) item )->m_Pos.x += offset.x; + ( (LibDrawCircle*) item )->m_Pos.y += offset.y; + break; - case COMPONENT_RECT_DRAW_TYPE: - ((LibDrawSquare*)item)->m_Pos.x += offset.x; - ((LibDrawSquare*)item)->m_Pos.y += offset.y; - ((LibDrawSquare*)item)->m_End.x += offset.x; - ((LibDrawSquare*)item)->m_End.y += offset.y; - break; + case COMPONENT_RECT_DRAW_TYPE: + ( (LibDrawSquare*) item )->m_Pos.x += offset.x; + ( (LibDrawSquare*) item )->m_Pos.y += offset.y; + ( (LibDrawSquare*) item )->m_End.x += offset.x; + ( (LibDrawSquare*) item )->m_End.y += offset.y; + break; - case COMPONENT_POLYLINE_DRAW_TYPE: - { - int ii , imax = ((LibDrawPolyline*)item)->n * 2; - int * ptpoly = ((LibDrawPolyline*)item)->PolyList; - for ( ii = 0; ii < imax; ii += 2) - { - ptpoly[ii] += offset.x; - ptpoly[ii + 1] += offset.y; - } - } - break; + case COMPONENT_POLYLINE_DRAW_TYPE: + { + int ii, imax = ( (LibDrawPolyline*) item )->n * 2; + int* ptpoly = ( (LibDrawPolyline*) item )->PolyList; + for( ii = 0; ii < imax; ii += 2 ) + { + ptpoly[ii] += offset.x; + ptpoly[ii + 1] += offset.y; + } + } + break; - case COMPONENT_LINE_DRAW_TYPE: - break; + case COMPONENT_LINE_DRAW_TYPE: + break; - case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: - ((LibDrawText*)item)->m_Pos.x += offset.x; - ((LibDrawText*)item)->m_Pos.y += offset.y; - break; - } - item->m_Flags = item->m_Selected = 0; - } + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + ( (LibDrawText*) item )->m_Pos.x += offset.x; + ( (LibDrawText*) item )->m_Pos.y += offset.y; + break; + } + + item->m_Flags = item->m_Selected = 0; + } } + /******************************************************/ -void DeleteMarkedItems(EDA_LibComponentStruct *LibEntry) +void DeleteMarkedItems( EDA_LibComponentStruct* LibEntry ) /******************************************************/ + /* Delete marked items -*/ + */ { -LibEDA_BaseStruct * item, * next_item; + LibEDA_BaseStruct* item, * next_item; - if ( LibEntry == NULL ) return; + if( LibEntry == NULL ) + return; - item = LibEntry->m_Drawings; - for ( ; item != NULL; item = next_item ) - { - next_item = item->Next(); - if ( item->m_Selected == 0 ) continue; - DeleteOneLibraryDrawStruct(NULL, NULL, LibEntry, item, 0); - } + item = LibEntry->m_Drawings; + for( ; item != NULL; item = next_item ) + { + next_item = item->Next(); + if( item->m_Selected == 0 ) + continue; + DeleteOneLibraryDrawStruct( NULL, NULL, LibEntry, item, 0 ); + } } /****************************************************************************/ -void MirrorMarkedItems(EDA_LibComponentStruct *LibEntry, wxPoint offset) +void MirrorMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) /****************************************************************************/ + /* Mirror marked items, refer to a Vertical axis at position offset -*/ + */ { -#define SETMIRROR(z) (z) -= offset.x; (z) = -(z); (z) += offset.x; -LibEDA_BaseStruct * item; +#define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x; + LibEDA_BaseStruct* item; - if ( LibEntry == NULL ) return; + if( LibEntry == NULL ) + return; - offset.y = - offset.y; // Y axis for lib items is Down to Up: reverse y offset value - item = LibEntry->m_Drawings; - for ( ; item != NULL; item = item->Next() ) - { - if ( item->m_Selected == 0 ) continue; + offset.y = -offset.y; // Y axis for lib items is Down to Up: reverse y offset value + item = LibEntry->m_Drawings; + for( ; item != NULL; item = item->Next() ) + { + if( item->m_Selected == 0 ) + continue; - switch ( item->m_StructType ) - { - case COMPONENT_PIN_DRAW_TYPE: - SETMIRROR(((LibDrawPin*)item)->m_Pos.x); - switch (((LibDrawPin*)item)->m_Orient) - { - case PIN_RIGHT: - ((LibDrawPin*)item)->m_Orient = PIN_LEFT; - break; + switch( item->m_StructType ) + { + case COMPONENT_PIN_DRAW_TYPE: + SETMIRROR( ( (LibDrawPin*) item )->m_Pos.x ); - case PIN_LEFT: - ((LibDrawPin*)item)->m_Orient = PIN_RIGHT; - break; + switch( ( (LibDrawPin*) item )->m_Orient ) + { + case PIN_RIGHT: + ( (LibDrawPin*) item )->m_Orient = PIN_LEFT; + break; - case PIN_UP: - case PIN_DOWN: - break; - } - break; + case PIN_LEFT: + ( (LibDrawPin*) item )->m_Orient = PIN_RIGHT; + break; - case COMPONENT_ARC_DRAW_TYPE: - { - SETMIRROR(((LibDrawArc*)item)->m_Pos.x); - SETMIRROR(((LibDrawArc*)item)->m_ArcStart.x); - SETMIRROR(((LibDrawArc*)item)->m_ArcEnd.x); - EXCHG(((LibDrawArc*)item)->m_ArcStart,((LibDrawArc*)item)->m_ArcEnd); - break; - } + case PIN_UP: + case PIN_DOWN: + break; + } - case COMPONENT_CIRCLE_DRAW_TYPE: - SETMIRROR(((LibDrawCircle*)item)->m_Pos.x); - break; + break; - case COMPONENT_RECT_DRAW_TYPE: - SETMIRROR(((LibDrawSquare*)item)->m_Pos.x); - SETMIRROR(((LibDrawSquare*)item)->m_End.x); - break; + case COMPONENT_ARC_DRAW_TYPE: + { + SETMIRROR( ( (LibDrawArc*) item )->m_Pos.x ); + SETMIRROR( ( (LibDrawArc*) item )->m_ArcStart.x ); + SETMIRROR( ( (LibDrawArc*) item )->m_ArcEnd.x ); + EXCHG( ( (LibDrawArc*) item )->m_ArcStart, ( (LibDrawArc*) item )->m_ArcEnd ); + break; + } - case COMPONENT_POLYLINE_DRAW_TYPE: - { - int ii , imax = ((LibDrawPolyline*)item)->n * 2; - int * ptpoly = ((LibDrawPolyline*)item)->PolyList; - for ( ii = 0; ii < imax; ii += 2) - { - SETMIRROR(ptpoly[ii]); - } - } - break; + case COMPONENT_CIRCLE_DRAW_TYPE: + SETMIRROR( ( (LibDrawCircle*) item )->m_Pos.x ); + break; - case COMPONENT_LINE_DRAW_TYPE: - break; + case COMPONENT_RECT_DRAW_TYPE: + SETMIRROR( ( (LibDrawSquare*) item )->m_Pos.x ); + SETMIRROR( ( (LibDrawSquare*) item )->m_End.x ); + break; - case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: - SETMIRROR(((LibDrawText*)item)->m_Pos.x); - break; - } - item->m_Flags = item->m_Selected = 0; - } + case COMPONENT_POLYLINE_DRAW_TYPE: + { + int ii, imax = ( (LibDrawPolyline*) item )->n * 2; + int* ptpoly = ( (LibDrawPolyline*) item )->PolyList; + for( ii = 0; ii < imax; ii += 2 ) + { + SETMIRROR( ptpoly[ii] ); + } + } + break; + + case COMPONENT_LINE_DRAW_TYPE: + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + SETMIRROR( ( (LibDrawText*) item )->m_Pos.x ); + break; + } + + item->m_Flags = item->m_Selected = 0; + } } diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index aeb83d5340..8d6b7188f3 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -14,811 +14,863 @@ /* Routines Locales */ -static void Show_Polyline_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); -static void Segment_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); -static void AbortCreateNewLine(WinEDA_DrawPanel * Panel, wxDC * DC); -static bool IsTerminalPoint(SCH_SCREEN * screen, const wxPoint & pos, int layer ); -static bool IsJunctionNeeded (WinEDA_SchematicFrame * frame, wxPoint & pos ); -static void ComputeBreakPoint(EDA_DrawLineStruct * segment, const wxPoint & new_pos); +static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); +static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); +static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC ); +static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ); +static bool IsJunctionNeeded( WinEDA_SchematicFrame* frame, wxPoint& pos ); +static void ComputeBreakPoint( EDA_DrawLineStruct* segment, const wxPoint& new_pos ); -EDA_BaseStruct * s_OldWiresList; -wxPoint s_ConnexionStartPoint; +EDA_BaseStruct* s_OldWiresList; +wxPoint s_ConnexionStartPoint; /*********************************************************/ -EDA_BaseStruct * SCH_SCREEN::ExtractWires(bool CreateCopy) +EDA_BaseStruct* SCH_SCREEN::ExtractWires( bool CreateCopy ) /*********************************************************/ + /* Extract the old wires, junctions and busses, an if CreateCopy replace them by a copy. -Old ones must be put in undo list, and the new ones can be modified by clean up -safely. -If an abord command is made, old wires must be put in EEDrawList, and copies must be deleted -This is because previously stored undo commands can handle pointers on wires or bus, -and we do not delete wires or bus, we must put they in undo list. - -Because cleanup delete and/or modify bus and wires, the more easy is to put all wires in undo list -and use a new copy of wires for cleanup -*/ + * Old ones must be put in undo list, and the new ones can be modified by clean up + * safely. + * If an abord command is made, old wires must be put in EEDrawList, and copies must be deleted + * This is because previously stored undo commands can handle pointers on wires or bus, + * and we do not delete wires or bus, we must put they in undo list. + * + * Because cleanup delete and/or modify bus and wires, the more easy is to put all wires in undo list + * and use a new copy of wires for cleanup + */ { -EDA_BaseStruct *item, *next_item, *new_item, * List = NULL; - - for (item = EEDrawList; item != NULL; item = next_item) - { - next_item = item->Pnext; - switch ( item->m_StructType ) - { - case DRAW_JUNCTION_STRUCT_TYPE: - case DRAW_SEGMENT_STRUCT_TYPE: - RemoveFromDrawList(item); - item->Pnext = List; - List = item; - if ( CreateCopy ) - { - if ( item->m_StructType == DRAW_JUNCTION_STRUCT_TYPE) - new_item = ((DrawJunctionStruct*)item)->GenCopy(); - else - new_item = ((EDA_DrawLineStruct*)item)->GenCopy(); - new_item->Pnext = EEDrawList; - EEDrawList = new_item; - } - break; - - default: - break; - } - } - - return List; - + EDA_BaseStruct* item, * next_item, * new_item, * List = NULL; + + for( item = EEDrawList; item != NULL; item = next_item ) + { + next_item = item->Pnext; + + switch( item->m_StructType ) + { + case DRAW_JUNCTION_STRUCT_TYPE: + case DRAW_SEGMENT_STRUCT_TYPE: + RemoveFromDrawList( item ); + item->Pnext = List; + List = item; + if( CreateCopy ) + { + if( item->m_StructType == DRAW_JUNCTION_STRUCT_TYPE ) + new_item = ( (DrawJunctionStruct*) item )->GenCopy(); + else + new_item = ( (EDA_DrawLineStruct*) item )->GenCopy(); + new_item->Pnext = EEDrawList; + EEDrawList = new_item; + } + break; + + default: + break; + } + } + + return List; } /*************************************************/ -static void RestoreOldWires(SCH_SCREEN * screen) +static void RestoreOldWires( SCH_SCREEN* screen ) /*************************************************/ + /* Replace the wires in screen->EEDrawList by s_OldWiresList wires. -*/ + */ { -EDA_BaseStruct *item, *next_item; - - for (item = screen->EEDrawList; item != NULL; item = next_item) - { - next_item = item->Pnext; - switch ( item->m_StructType ) - { - case DRAW_JUNCTION_STRUCT_TYPE: - case DRAW_SEGMENT_STRUCT_TYPE: - screen->RemoveFromDrawList(item); - delete item; - break; - - default: - break; - } - } - - while (s_OldWiresList) - { - next_item = s_OldWiresList->Pnext; - s_OldWiresList->Pnext = screen->EEDrawList, - screen->EEDrawList = s_OldWiresList; - s_OldWiresList = next_item; - } + EDA_BaseStruct* item, * next_item; + + for( item = screen->EEDrawList; item != NULL; item = next_item ) + { + next_item = item->Pnext; + + switch( item->m_StructType ) + { + case DRAW_JUNCTION_STRUCT_TYPE: + case DRAW_SEGMENT_STRUCT_TYPE: + screen->RemoveFromDrawList( item ); + delete item; + break; + + default: + break; + } + } + + while( s_OldWiresList ) + { + next_item = s_OldWiresList->Pnext; + s_OldWiresList->Pnext = screen->EEDrawList, + screen->EEDrawList = s_OldWiresList; + s_OldWiresList = next_item; + } } /*************************************************************/ -void WinEDA_SchematicFrame::BeginSegment(wxDC * DC, int type) +void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) /*************************************************************/ + /* Create a new segment ( WIRE, BUS ). -*/ + */ { -EDA_DrawLineStruct * oldsegment, * newsegment, * nextsegment; -wxPoint cursorpos = GetScreen()->m_Curseur; - - if ( GetScreen()->m_CurrentItem && (GetScreen()->m_CurrentItem->m_Flags == 0) ) - GetScreen()->m_CurrentItem = NULL; + EDA_DrawLineStruct* oldsegment, * newsegment, * nextsegment; + wxPoint cursorpos = GetScreen()->m_Curseur; - if ( GetScreen()->m_CurrentItem ) - { - switch (GetScreen()->m_CurrentItem->m_StructType ) - { - case DRAW_SEGMENT_STRUCT_TYPE: - case DRAW_POLYLINE_STRUCT_TYPE: - break; + if( GetScreen()->GetCurItem() && (GetScreen()->GetCurItem()->m_Flags == 0) ) + GetScreen()->SetCurItem( NULL ); - default: - return; - } - } + if( GetScreen()->GetCurItem() ) + { + switch( GetScreen()->GetCurItem()->m_StructType ) + { + case DRAW_SEGMENT_STRUCT_TYPE: + case DRAW_POLYLINE_STRUCT_TYPE: + break; - oldsegment = newsegment = - (EDA_DrawLineStruct *) GetScreen()->m_CurrentItem; + default: + return; + } + } - if (!newsegment) /* first point : Create first wire ou bus */ - { - s_ConnexionStartPoint = cursorpos; - s_OldWiresList = GetScreen()->ExtractWires(TRUE); - GetScreen()->SchematicCleanUp(NULL); - switch(type) - { - default: - newsegment = new EDA_DrawLineStruct(cursorpos, LAYER_NOTES); - break; - case LAYER_WIRE: - newsegment = new EDA_DrawLineStruct(cursorpos, LAYER_WIRE); - /* A junction will be created later, when w'll know the - segment end position, and if the junction is really needed */ - break; - case LAYER_BUS: - newsegment = new EDA_DrawLineStruct(cursorpos, LAYER_BUS); - break; - } + oldsegment = newsegment = + (EDA_DrawLineStruct*) GetScreen()->GetCurItem(); - newsegment->m_Flags = IS_NEW; - if( g_HVLines ) // We need 2 segments to go from a given start pint to an end point - { - nextsegment = newsegment->GenCopy(); - nextsegment->m_Flags = IS_NEW; - newsegment->Pnext = nextsegment; - nextsegment->Pback = newsegment; - } - GetScreen()->m_CurrentItem = newsegment; - DrawPanel->ManageCurseur = Segment_in_Ghost; - DrawPanel->ForceCloseManageCurseur = AbortCreateNewLine; - g_ItemToRepeat = NULL; - } + if( !newsegment ) /* first point : Create first wire ou bus */ + { + s_ConnexionStartPoint = cursorpos; + s_OldWiresList = GetScreen()->ExtractWires( TRUE ); + GetScreen()->SchematicCleanUp( NULL ); - else /* Trace en cours: Placement d'un point supplementaire */ - { - nextsegment = (EDA_DrawLineStruct*)oldsegment->Pnext; - if( ! g_HVLines ) - { /* if only one segment is needed and the current is has len = 0, do not create a new one*/ - if( oldsegment->IsNull() ) return; - } - else - { /* if we want 2 segment and the last two have len = 0, do not create a new one*/ - if ( oldsegment->IsNull() && nextsegment && nextsegment->IsNull() ) - return; - } + switch( type ) + { + default: + newsegment = new EDA_DrawLineStruct( cursorpos, LAYER_NOTES ); + break; - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + case LAYER_WIRE: + newsegment = new EDA_DrawLineStruct( cursorpos, LAYER_WIRE ); - /* Creation du segment suivant ou fin de trac� si point sur pin, jonction ...*/ - if ( IsTerminalPoint(GetScreen(), cursorpos, oldsegment->m_Layer) ) - { - EndSegment(DC); return; - } + /* A junction will be created later, when w'll know the + * segment end position, and if the junction is really needed */ + break; - /* Placement en liste generale */ - oldsegment->Pnext = GetScreen()->EEDrawList; - GetScreen()->EEDrawList = oldsegment; - DrawPanel->CursorOff(DC); // Erase schematic cursor - RedrawOneStruct(DrawPanel,DC, oldsegment, GR_DEFAULT_DRAWMODE); - DrawPanel->CursorOn(DC); // Display schematic cursor + case LAYER_BUS: + newsegment = new EDA_DrawLineStruct( cursorpos, LAYER_BUS ); + break; + } - /* Create a new segment, and chain it after the current new segment */ - if ( nextsegment ) - { - newsegment = nextsegment->GenCopy(); - nextsegment->m_Start = newsegment->m_End; - nextsegment->Pnext = NULL; - nextsegment->Pback = newsegment; - newsegment->Pnext = nextsegment; - newsegment->Pback = NULL; - } - else - { - newsegment = oldsegment->GenCopy(); - newsegment->m_Start = oldsegment->m_End; - } - newsegment->m_End = cursorpos; - oldsegment->m_Flags = SELECTED; - newsegment->m_Flags = IS_NEW; - GetScreen()->m_CurrentItem = newsegment; - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - if ( oldsegment->m_Start == s_ConnexionStartPoint ) - { /* This is the first segment: Now we know the start segment position. - Create a junction if needed. Note: a junction can be needed - later, if the new segment is merged (after a cleanup) with an older one - (tested when the connection will be finished)*/ - if ( IsJunctionNeeded(this, s_ConnexionStartPoint) ) - CreateNewJunctionStruct(DC, s_ConnexionStartPoint); - } - } + newsegment->m_Flags = IS_NEW; + if( g_HVLines ) // We need 2 segments to go from a given start pint to an end point + { + nextsegment = newsegment->GenCopy(); + nextsegment->m_Flags = IS_NEW; + newsegment->Pnext = nextsegment; + nextsegment->Pback = newsegment; + } + GetScreen()->SetCurItem( newsegment ); + DrawPanel->ManageCurseur = Segment_in_Ghost; + DrawPanel->ForceCloseManageCurseur = AbortCreateNewLine; + g_ItemToRepeat = NULL; + } + else /* Trace en cours: Placement d'un point supplementaire */ + { + nextsegment = (EDA_DrawLineStruct*) oldsegment->Pnext; + if( !g_HVLines ) + { /* if only one segment is needed and the current is has len = 0, do not create a new one*/ + if( oldsegment->IsNull() ) + return; + } + else + { + /* if we want 2 segment and the last two have len = 0, do not create a new one*/ + if( oldsegment->IsNull() && nextsegment && nextsegment->IsNull() ) + return; + } + + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + + /* Creation du segment suivant ou fin de trac� si point sur pin, jonction ...*/ + if( IsTerminalPoint( GetScreen(), cursorpos, oldsegment->m_Layer ) ) + { + EndSegment( DC ); return; + } + + /* Placement en liste generale */ + oldsegment->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = oldsegment; + DrawPanel->CursorOff( DC ); // Erase schematic cursor + RedrawOneStruct( DrawPanel, DC, oldsegment, GR_DEFAULT_DRAWMODE ); + DrawPanel->CursorOn( DC ); // Display schematic cursor + + /* Create a new segment, and chain it after the current new segment */ + if( nextsegment ) + { + newsegment = nextsegment->GenCopy(); + nextsegment->m_Start = newsegment->m_End; + nextsegment->Pnext = NULL; + nextsegment->Pback = newsegment; + newsegment->Pnext = nextsegment; + newsegment->Pback = NULL; + } + else + { + newsegment = oldsegment->GenCopy(); + newsegment->m_Start = oldsegment->m_End; + } + newsegment->m_End = cursorpos; + oldsegment->m_Flags = SELECTED; + newsegment->m_Flags = IS_NEW; + GetScreen()->SetCurItem( newsegment ); + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + if( oldsegment->m_Start == s_ConnexionStartPoint ) + { /* This is the first segment: Now we know the start segment position. + * Create a junction if needed. Note: a junction can be needed + * later, if the new segment is merged (after a cleanup) with an older one + * (tested when the connection will be finished)*/ + if( IsJunctionNeeded( this, s_ConnexionStartPoint ) ) + CreateNewJunctionStruct( DC, s_ConnexionStartPoint ); + } + } } /***********************************************/ -void WinEDA_SchematicFrame::EndSegment(wxDC *DC) +void WinEDA_SchematicFrame::EndSegment( wxDC* DC ) /***********************************************/ + /* Called to terminate a bus, wire, or line creation -*/ + */ { -EDA_DrawLineStruct * firstsegment = (EDA_DrawLineStruct *)GetScreen()->m_CurrentItem; -EDA_DrawLineStruct * lastsegment = firstsegment; -EDA_DrawLineStruct * segment; - - if ( firstsegment == NULL ) return; - if ( (firstsegment->m_Flags & IS_NEW) == 0) return; + EDA_DrawLineStruct* firstsegment = (EDA_DrawLineStruct*) GetScreen()->GetCurItem(); + EDA_DrawLineStruct* lastsegment = firstsegment; + EDA_DrawLineStruct* segment; - /* Delete Null segments and Put line it in Drawlist */ - lastsegment = firstsegment; - while ( lastsegment ) - { - EDA_DrawLineStruct * nextsegment = (EDA_DrawLineStruct *)lastsegment->Pnext; - if ( lastsegment->IsNull() ) - { - EDA_DrawLineStruct * previous_segment = (EDA_DrawLineStruct *)lastsegment->Pback; - if ( firstsegment == lastsegment ) firstsegment = nextsegment; - if ( nextsegment ) nextsegment->Pback = NULL; - if ( previous_segment ) previous_segment->Pnext = nextsegment; - delete lastsegment; - } - lastsegment = nextsegment; - } - /* put the segment list to the main linked list */ - segment = lastsegment = firstsegment; - while ( segment ) - { - lastsegment = segment; - segment = (EDA_DrawLineStruct *)segment->Pnext; - lastsegment->Pnext = GetScreen()->EEDrawList; - GetScreen()->EEDrawList = lastsegment; - } - - /* Fin de trace */ - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->m_CurrentItem = NULL; + if( firstsegment == NULL ) + return; + if( (firstsegment->m_Flags & IS_NEW) == 0 ) + return; -wxPoint end_point, alt_end_point; - /* A junction can be needed to connect the last segment - usually to m_End coordinate. - But if the last segment is removed by a cleanup, because od redundancy, - a junction can be needed to connect the previous segment m_End coordinate - with is also the lastsegment->m_Start coordinate */ - if ( lastsegment ) - { - end_point = lastsegment->m_End; - alt_end_point = lastsegment->m_Start; - } + /* Delete Null segments and Put line it in Drawlist */ + lastsegment = firstsegment; + while( lastsegment ) + { + EDA_DrawLineStruct* nextsegment = (EDA_DrawLineStruct*) lastsegment->Pnext; + if( lastsegment->IsNull() ) + { + EDA_DrawLineStruct* previous_segment = (EDA_DrawLineStruct*) lastsegment->Pback; + if( firstsegment == lastsegment ) + firstsegment = nextsegment; + if( nextsegment ) + nextsegment->Pback = NULL; + if( previous_segment ) + previous_segment->Pnext = nextsegment; + delete lastsegment; + } + lastsegment = nextsegment; + } - GetScreen()->SchematicCleanUp(NULL); + /* put the segment list to the main linked list */ + segment = lastsegment = firstsegment; + while( segment ) + { + lastsegment = segment; + segment = (EDA_DrawLineStruct*) segment->Pnext; + lastsegment->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = lastsegment; + } - /* clear flags and find last segment entered, for repeat function */ - segment = (EDA_DrawLineStruct *) GetScreen()->EEDrawList; - while ( segment ) - { - if ( segment->m_Flags ) - { - if ( ! g_ItemToRepeat ) g_ItemToRepeat = segment; - } - segment->m_Flags = 0; - segment = (EDA_DrawLineStruct *)segment->Pnext; - } + /* Fin de trace */ + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->SetCurItem( NULL ); - // Automatic place of a junction on the end point, if needed - if ( lastsegment ) - { - if( IsJunctionNeeded(this, end_point) ) - CreateNewJunctionStruct(DC, end_point); + wxPoint end_point, alt_end_point; - else if( IsJunctionNeeded(this, alt_end_point) ) - CreateNewJunctionStruct(DC, alt_end_point); - } - - /* Automatic place of a junction on the start point if necessary because the - Cleanup can suppress intermediate points by merging wire segments*/ - if ( IsJunctionNeeded(this, s_ConnexionStartPoint) ) - CreateNewJunctionStruct(DC, s_ConnexionStartPoint); + /* A junction can be needed to connect the last segment + * usually to m_End coordinate. + * But if the last segment is removed by a cleanup, because od redundancy, + * a junction can be needed to connect the previous segment m_End coordinate + * with is also the lastsegment->m_Start coordinate */ + if( lastsegment ) + { + end_point = lastsegment->m_End; + alt_end_point = lastsegment->m_Start; + } - TestDanglingEnds(GetScreen()->EEDrawList, DC); + GetScreen()->SchematicCleanUp( NULL ); - - /* Redraw wires and junctions which can be changed by TestDanglingEnds() */ - DrawPanel->CursorOff(DC); // Erase schematic cursor - EDA_BaseStruct *item = GetScreen()->EEDrawList; - while ( item ) - { - switch ( item->m_StructType ) - { - case DRAW_JUNCTION_STRUCT_TYPE: - case DRAW_SEGMENT_STRUCT_TYPE: - RedrawOneStruct(DrawPanel,DC, item, GR_DEFAULT_DRAWMODE); - break; - - default: - break; - } - item = item->Pnext; - } - + /* clear flags and find last segment entered, for repeat function */ + segment = (EDA_DrawLineStruct*) GetScreen()->EEDrawList; + while( segment ) + { + if( segment->m_Flags ) + { + if( !g_ItemToRepeat ) + g_ItemToRepeat = segment; + } + segment->m_Flags = 0; + segment = (EDA_DrawLineStruct*) segment->Pnext; + } - DrawPanel->CursorOn(DC); // Display schematic cursor - - SaveCopyInUndoList(s_OldWiresList, IS_WIRE_IMAGE); - s_OldWiresList = NULL; + // Automatic place of a junction on the end point, if needed + if( lastsegment ) + { + if( IsJunctionNeeded( this, end_point ) ) + CreateNewJunctionStruct( DC, end_point ); - GetScreen()->SetModify(); + else if( IsJunctionNeeded( this, alt_end_point ) ) + CreateNewJunctionStruct( DC, alt_end_point ); + } + + /* Automatic place of a junction on the start point if necessary because the + * Cleanup can suppress intermediate points by merging wire segments*/ + if( IsJunctionNeeded( this, s_ConnexionStartPoint ) ) + CreateNewJunctionStruct( DC, s_ConnexionStartPoint ); + + TestDanglingEnds( GetScreen()->EEDrawList, DC ); + + + /* Redraw wires and junctions which can be changed by TestDanglingEnds() */ + DrawPanel->CursorOff( DC ); // Erase schematic cursor + EDA_BaseStruct* item = GetScreen()->EEDrawList; + while( item ) + { + switch( item->m_StructType ) + { + case DRAW_JUNCTION_STRUCT_TYPE: + case DRAW_SEGMENT_STRUCT_TYPE: + RedrawOneStruct( DrawPanel, DC, item, GR_DEFAULT_DRAWMODE ); + break; + + default: + break; + } + + item = item->Pnext; + } + + + DrawPanel->CursorOn( DC ); // Display schematic cursor + + SaveCopyInUndoList( s_OldWiresList, IS_WIRE_IMAGE ); + s_OldWiresList = NULL; + + GetScreen()->SetModify(); } + /****************************************************************************/ -static void Segment_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /****************************************************************************/ + /* Redraw the segment (g_HVLines == FALSE ) or the two segments (g_HVLines == TRUE ) - from the start point to the cursor, when moving the mouse -*/ + * from the start point to the cursor, when moving the mouse + */ { -EDA_DrawLineStruct * CurrentLine = - (EDA_DrawLineStruct *) panel->m_Parent->GetScreen()->m_CurrentItem; -EDA_DrawLineStruct * segment; -int color; + EDA_DrawLineStruct* CurrentLine = + (EDA_DrawLineStruct*) panel->m_Parent->GetScreen()->GetCurItem(); + EDA_DrawLineStruct* segment; + int color; - if ( CurrentLine == NULL ) return; + if( CurrentLine == NULL ) + return; - color = ReturnLayerColor(CurrentLine->m_Layer) ^ HIGHT_LIGHT_FLAG; + color = ReturnLayerColor( CurrentLine->m_Layer ) ^ HIGHT_LIGHT_FLAG; - if( erase ) - { - segment = CurrentLine; - while ( segment ) - { - if ( ! segment->IsNull() ) // Redraw if segment lengtht != 0 - RedrawOneStruct(panel,DC, segment, g_XorMode, color); - segment = (EDA_DrawLineStruct*)segment->Pnext; - } - } + if( erase ) + { + segment = CurrentLine; + while( segment ) + { + if( !segment->IsNull() ) // Redraw if segment lengtht != 0 + RedrawOneStruct( panel, DC, segment, g_XorMode, color ); + segment = (EDA_DrawLineStruct*) segment->Pnext; + } + } -wxPoint endpos = panel->m_Parent->GetScreen()->m_Curseur; - if( g_HVLines ) /* Coerce the line to vertical or horizontal one: */ - { - ComputeBreakPoint( CurrentLine, endpos); - } + wxPoint endpos = panel->m_Parent->GetScreen()->m_Curseur; + if( g_HVLines ) /* Coerce the line to vertical or horizontal one: */ + { + ComputeBreakPoint( CurrentLine, endpos ); + } + else + CurrentLine->m_End = endpos; - else CurrentLine->m_End = endpos; - - segment = CurrentLine; - while ( segment ) - { - if ( ! segment->IsNull() ) // Redraw if segment lengtht != 0 - RedrawOneStruct(panel,DC, segment, g_XorMode, color); - segment = (EDA_DrawLineStruct*)segment->Pnext; - } + segment = CurrentLine; + while( segment ) + { + if( !segment->IsNull() ) // Redraw if segment lengtht != 0 + RedrawOneStruct( panel, DC, segment, g_XorMode, color ); + segment = (EDA_DrawLineStruct*) segment->Pnext; + } } /**************************************************************************************/ -static void ComputeBreakPoint( EDA_DrawLineStruct * segment, const wxPoint & new_pos ) +static void ComputeBreakPoint( EDA_DrawLineStruct* segment, const wxPoint& new_pos ) /**************************************************************************************/ + /* compute the middle coordinate for 2 segments, from the start point to new_pos - with the 2 segments kept H or V only -*/ + * with the 2 segments kept H or V only + */ { -EDA_DrawLineStruct * nextsegment = (EDA_DrawLineStruct *)segment->Pnext; -wxPoint middle_position = new_pos; - - if( nextsegment == NULL ) return; -#if 0 - if (ABS(middle_position.x - segment->m_Start.x) < ABS(middle_position.y - segment->m_Start.y)) - middle_position.x = segment->m_Start.x; - else - middle_position.y = segment->m_Start.y; + EDA_DrawLineStruct* nextsegment = (EDA_DrawLineStruct*) segment->Pnext; + wxPoint middle_position = new_pos; + + if( nextsegment == NULL ) + return; +#if 0 + if( ABS( middle_position.x - segment->m_Start.x ) < + ABS( middle_position.y - segment->m_Start.y ) ) + middle_position.x = segment->m_Start.x; + else + middle_position.y = segment->m_Start.y; #else -int iDx = segment->m_End.x - segment->m_Start.x; -int iDy = segment->m_End.y - segment->m_Start.y; - if ( iDy != 0 ) // keep the first segment orientation (currently horizontal) - { - middle_position.x = segment->m_Start.x; - } - else if ( iDx != 0 ) // keep the first segment orientation (currently vertical) - { - middle_position.y = segment->m_Start.y; - } - else - { - if (ABS(middle_position.x - segment->m_Start.x) < ABS(middle_position.y - segment->m_Start.y)) - middle_position.x = segment->m_Start.x; - else - middle_position.y = segment->m_Start.y; - } + int iDx = segment->m_End.x - segment->m_Start.x; + int iDy = segment->m_End.y - segment->m_Start.y; + if( iDy != 0 ) // keep the first segment orientation (currently horizontal) + { + middle_position.x = segment->m_Start.x; + } + else if( iDx != 0 ) // keep the first segment orientation (currently vertical) + { + middle_position.y = segment->m_Start.y; + } + else + { + if( ABS( middle_position.x - segment->m_Start.x ) < + ABS( middle_position.y - segment->m_Start.y ) ) + middle_position.x = segment->m_Start.x; + else + middle_position.y = segment->m_Start.y; + } #endif - - segment->m_End = middle_position; - - nextsegment->m_Start = middle_position; - nextsegment->m_End = new_pos; + + segment->m_End = middle_position; + + nextsegment->m_Start = middle_position; + nextsegment->m_End = new_pos; } + /*****************************************************************************/ -static void Show_Polyline_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /*****************************************************************************/ + /* Dessin du du Polyline Fantome lors des deplacements du curseur -*/ + */ { -DrawPolylineStruct * NewPoly = - (DrawPolylineStruct *)panel->m_Parent->GetScreen()->m_CurrentItem; -int color; -wxPoint endpos; + DrawPolylineStruct* NewPoly = + (DrawPolylineStruct*) panel->m_Parent->GetScreen()->GetCurItem(); + int color; + wxPoint endpos; - endpos = panel->m_Parent->GetScreen()->m_Curseur; - color = ReturnLayerColor(NewPoly->m_Layer); + endpos = panel->m_Parent->GetScreen()->m_Curseur; + color = ReturnLayerColor( NewPoly->m_Layer ); - GRSetDrawMode(DC, g_XorMode); + GRSetDrawMode( DC, g_XorMode ); - if( g_HVLines ) - { - /* Coerce the line to vertical or horizontal one: */ - if (ABS(endpos.x - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2]) < - ABS(endpos.y - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1])) - endpos.x = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2]; - else - endpos.y = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1]; - } + if( g_HVLines ) + { + /* Coerce the line to vertical or horizontal one: */ + if( ABS( endpos.x - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2] ) < + ABS( endpos.y - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1] ) ) + endpos.x = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2]; + else + endpos.y = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1]; + } - NewPoly->m_NumOfPoints++; - if( erase ) - RedrawOneStruct(panel,DC, NewPoly, g_XorMode, color); + NewPoly->m_NumOfPoints++; + if( erase ) + RedrawOneStruct( panel, DC, NewPoly, g_XorMode, color ); - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2] = endpos.x; - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1] = endpos.y; - RedrawOneStruct(panel,DC, NewPoly, g_XorMode, color); - NewPoly->m_NumOfPoints--; + NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2] = endpos.x; + NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1] = endpos.y; + RedrawOneStruct( panel, DC, NewPoly, g_XorMode, color ); + NewPoly->m_NumOfPoints--; } + /**********************************************************/ -void WinEDA_SchematicFrame::DeleteCurrentSegment(wxDC * DC) +void WinEDA_SchematicFrame::DeleteCurrentSegment( wxDC* DC ) /**********************************************************/ + /* -Routine effacant le dernier trait trace, ou l'element pointe par la souris -*/ + * Routine effacant le dernier trait trace, ou l'element pointe par la souris + */ { + g_ItemToRepeat = NULL; - g_ItemToRepeat = NULL; + if( (GetScreen()->GetCurItem() == NULL) + || ( (GetScreen()->GetCurItem()->m_Flags & IS_NEW) == 0 ) ) + { + return; + } - if( (GetScreen()->m_CurrentItem == NULL) || - ((GetScreen()->m_CurrentItem->m_Flags & IS_NEW) == 0) ) - { - return; - } + /* Trace en cours: annulation */ + if( GetScreen()->GetCurItem()->m_StructType == DRAW_POLYLINE_STRUCT_TYPE ) + { + Show_Polyline_in_Ghost( DrawPanel, DC, FALSE ); /* Effacement du trace en cours */ + } + else + { + Segment_in_Ghost( DrawPanel, DC, FALSE ); /* Effacement du trace en cours */ + } - /* Trace en cours: annulation */ - if (GetScreen()->m_CurrentItem->m_StructType == DRAW_POLYLINE_STRUCT_TYPE) - { - Show_Polyline_in_Ghost(DrawPanel, DC, FALSE); /* Effacement du trace en cours */ - } - - else - { - Segment_in_Ghost(DrawPanel, DC, FALSE); /* Effacement du trace en cours */ - } - - EraseStruct(GetScreen()->m_CurrentItem, GetScreen()); - DrawPanel->ManageCurseur = NULL; - GetScreen()->m_CurrentItem = NULL; + EraseStruct( GetScreen()->GetCurItem(), GetScreen() ); + DrawPanel->ManageCurseur = NULL; + GetScreen()->SetCurItem( NULL ); } /***************************************************************************/ -DrawJunctionStruct * WinEDA_SchematicFrame::CreateNewJunctionStruct( - wxDC * DC, const wxPoint & pos, bool PutInUndoList) +DrawJunctionStruct* WinEDA_SchematicFrame::CreateNewJunctionStruct( + wxDC* DC, const wxPoint& pos, bool PutInUndoList ) /***************************************************************************/ + /* Routine to create new connection struct. -*/ + */ { -DrawJunctionStruct *NewJunction; + DrawJunctionStruct* NewJunction; - NewJunction = new DrawJunctionStruct(pos); + NewJunction = new DrawJunctionStruct( pos ); - g_ItemToRepeat = NewJunction; + g_ItemToRepeat = NewJunction; - DrawPanel->CursorOff(DC); // Erase schematic cursor - RedrawOneStruct(DrawPanel,DC, NewJunction, GR_DEFAULT_DRAWMODE); - DrawPanel->CursorOn(DC); // Display schematic cursor + DrawPanel->CursorOff( DC ); // Erase schematic cursor + RedrawOneStruct( DrawPanel, DC, NewJunction, GR_DEFAULT_DRAWMODE ); + DrawPanel->CursorOn( DC ); // Display schematic cursor - NewJunction->Pnext = GetScreen()->EEDrawList; - GetScreen()->EEDrawList = NewJunction; - GetScreen()->SetModify(); - if ( PutInUndoList ) - SaveCopyInUndoList(NewJunction, IS_NEW); - return(NewJunction); + NewJunction->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = NewJunction; + GetScreen()->SetModify(); + if( PutInUndoList ) + SaveCopyInUndoList( NewJunction, IS_NEW ); + return NewJunction; } + /**************************************************************************/ -EDA_BaseStruct *WinEDA_SchematicFrame::CreateNewNoConnectStruct(wxDC * DC) +EDA_BaseStruct* WinEDA_SchematicFrame::CreateNewNoConnectStruct( wxDC* DC ) /**************************************************************************/ + /*Routine to create new NoConnect struct. ( Symbole de Non Connexion) -*/ + */ { -DrawNoConnectStruct *NewNoConnect; + DrawNoConnectStruct* NewNoConnect; - NewNoConnect = new DrawNoConnectStruct(GetScreen()->m_Curseur); - g_ItemToRepeat = NewNoConnect; + NewNoConnect = new DrawNoConnectStruct( GetScreen()->m_Curseur ); + g_ItemToRepeat = NewNoConnect; - DrawPanel->CursorOff(DC); // Erase schematic cursor - RedrawOneStruct(DrawPanel,DC, NewNoConnect, GR_DEFAULT_DRAWMODE); - DrawPanel->CursorOn(DC); // Display schematic cursor + DrawPanel->CursorOff( DC ); // Erase schematic cursor + RedrawOneStruct( DrawPanel, DC, NewNoConnect, GR_DEFAULT_DRAWMODE ); + DrawPanel->CursorOn( DC ); // Display schematic cursor - NewNoConnect->Pnext = GetScreen()->EEDrawList; - GetScreen()->EEDrawList = NewNoConnect; - GetScreen()->SetModify(); - SaveCopyInUndoList(NewNoConnect, IS_NEW); - return(NewNoConnect); + NewNoConnect->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = NewNoConnect; + GetScreen()->SetModify(); + SaveCopyInUndoList( NewNoConnect, IS_NEW ); + return NewNoConnect; } /*****************************************************************/ -static void AbortCreateNewLine(WinEDA_DrawPanel * Panel, wxDC * DC) +static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC ) /*****************************************************************/ + /* Abort function for wire, bus or line creation -*/ + */ { -SCH_SCREEN * Screen = (SCH_SCREEN *)Panel->GetScreen(); + SCH_SCREEN* Screen = (SCH_SCREEN*) Panel->GetScreen(); - if( Screen->m_CurrentItem) /* trace en cours */ - { - Panel->ManageCurseur(Panel, DC, FALSE); - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; - EraseStruct(Screen->m_CurrentItem,(SCH_SCREEN*) Screen); - Screen->m_CurrentItem = NULL; - RestoreOldWires(Screen); - } + if( Screen->GetCurItem() ) /* trace en cours */ + { + Panel->ManageCurseur( Panel, DC, FALSE ); + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + EraseStruct( Screen->GetCurItem(), (SCH_SCREEN*) Screen ); + Screen->SetCurItem( NULL ); + RestoreOldWires( Screen ); + } + else + g_ItemToRepeat = NULL; // Fin de commande generale - else g_ItemToRepeat = NULL; // Fin de commande generale - - /* Clear m_Flags wich is used in edit functions: */ - EDA_BaseStruct * item = Screen->EEDrawList; - while ( item ) - { - item->m_Flags = 0; - item = item->Pnext; - } + /* Clear m_Flags wich is used in edit functions: */ + EDA_BaseStruct* item = Screen->EEDrawList; + while( item ) + { + item->m_Flags = 0; + item = item->Pnext; + } } /***************************************************/ -void WinEDA_SchematicFrame::RepeatDrawItem(wxDC *DC) +void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) /***************************************************/ + /* Routine de recopie du dernier element dessine - Les elements duplicables sont - fils, bus, traits, textes, labels - Les labels termines par un nombre seront incrementes -*/ + * Les elements duplicables sont + * fils, bus, traits, textes, labels + * Les labels termines par un nombre seront incrementes + */ { -wxPoint new_pos; + wxPoint new_pos; - if( g_ItemToRepeat == NULL ) return; + if( g_ItemToRepeat == NULL ) + return; - switch( g_ItemToRepeat->m_StructType ) - { - case DRAW_JUNCTION_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawJunctionStruct*) g_ItemToRepeat) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos += g_RepeatStep; - new_pos = STRUCT->m_Pos; - break; + switch( g_ItemToRepeat->m_StructType ) + { + case DRAW_JUNCTION_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawJunctionStruct*) g_ItemToRepeat ) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos += g_RepeatStep; + new_pos = STRUCT->m_Pos; + break; - case DRAW_NOCONNECT_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawNoConnectStruct*) g_ItemToRepeat) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos += g_RepeatStep; - new_pos = STRUCT->m_Pos; - break; + case DRAW_NOCONNECT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawNoConnectStruct*) g_ItemToRepeat ) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos += g_RepeatStep; + new_pos = STRUCT->m_Pos; + break; - case DRAW_TEXT_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawTextStruct*) g_ItemToRepeat) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos += g_RepeatStep; - new_pos = STRUCT->m_Pos; - /*** Increment du numero de label ***/ - IncrementLabelMember(STRUCT->m_Text); - break; - - - case DRAW_LABEL_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawLabelStruct*) g_ItemToRepeat) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos += g_RepeatStep; - new_pos = STRUCT->m_Pos; - /*** Increment du numero de label ***/ - IncrementLabelMember(STRUCT->m_Text); - break; + case DRAW_TEXT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawTextStruct*) g_ItemToRepeat ) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos += g_RepeatStep; + new_pos = STRUCT->m_Pos; + /*** Increment du numero de label ***/ + IncrementLabelMember( STRUCT->m_Text ); + break; - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawGlobalLabelStruct*) g_ItemToRepeat) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos += g_RepeatStep; - new_pos = STRUCT->m_Pos; - /*** Increment du numero de label ***/ - IncrementLabelMember(STRUCT->m_Text); - break; + case DRAW_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawLabelStruct*) g_ItemToRepeat ) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos += g_RepeatStep; + new_pos = STRUCT->m_Pos; + /*** Increment du numero de label ***/ + IncrementLabelMember( STRUCT->m_Text ); + break; - case DRAW_SEGMENT_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((EDA_DrawLineStruct*) g_ItemToRepeat) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Start += g_RepeatStep; - new_pos = STRUCT->m_Start; - STRUCT->m_End += g_RepeatStep; - break; - case DRAW_BUSENTRY_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawBusEntryStruct*) g_ItemToRepeat) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos += g_RepeatStep; - new_pos = STRUCT->m_Pos; - break; + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawGlobalLabelStruct*) g_ItemToRepeat ) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos += g_RepeatStep; + new_pos = STRUCT->m_Pos; + /*** Increment du numero de label ***/ + IncrementLabelMember( STRUCT->m_Text ); + break; - case DRAW_LIB_ITEM_STRUCT_TYPE: // In repeat command the new component is put in move mode - #undef STRUCT - #define STRUCT ((EDA_SchComponentStruct*) g_ItemToRepeat) - // Create the duplicate component, position = mouse cursor - g_ItemToRepeat = STRUCT->GenCopy(); - new_pos.x = m_CurrentScreen->m_Curseur.x - STRUCT->m_Pos.x; - new_pos.y = m_CurrentScreen->m_Curseur.y - STRUCT->m_Pos.y; - STRUCT->m_Pos = m_CurrentScreen->m_Curseur; - STRUCT->m_Flags = IS_NEW; - STRUCT->m_TimeStamp = GetTimeStamp(); - for( int ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) - { - STRUCT->m_Field[ii].m_Pos +=new_pos; - } - RedrawOneStruct(DrawPanel, DC, STRUCT, g_XorMode); - StartMovePart(STRUCT, DC); - return; - break; + case DRAW_SEGMENT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (EDA_DrawLineStruct*) g_ItemToRepeat ) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Start += g_RepeatStep; + new_pos = STRUCT->m_Start; + STRUCT->m_End += g_RepeatStep; + break; - default: - g_ItemToRepeat = NULL; - DisplayError(this, wxT("Repeat Type Error"), 10); - break; - } + case DRAW_BUSENTRY_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawBusEntryStruct*) g_ItemToRepeat ) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos += g_RepeatStep; + new_pos = STRUCT->m_Pos; + break; - if ( g_ItemToRepeat ) - { - g_ItemToRepeat->Pnext = GetScreen()->EEDrawList; - GetScreen()->EEDrawList = g_ItemToRepeat; - TestDanglingEnds(GetScreen()->EEDrawList, NULL); - RedrawOneStruct(DrawPanel,DC, g_ItemToRepeat, GR_DEFAULT_DRAWMODE); - SaveCopyInUndoList(g_ItemToRepeat, IS_NEW); - g_ItemToRepeat->m_Flags = 0; -// GetScreen()->Curseur = new_pos; + case DRAW_LIB_ITEM_STRUCT_TYPE: // In repeat command the new component is put in move mode + #undef STRUCT + #define STRUCT ( (EDA_SchComponentStruct*) g_ItemToRepeat ) + + // Create the duplicate component, position = mouse cursor + g_ItemToRepeat = STRUCT->GenCopy(); + new_pos.x = m_CurrentScreen->m_Curseur.x - STRUCT->m_Pos.x; + new_pos.y = m_CurrentScreen->m_Curseur.y - STRUCT->m_Pos.y; + STRUCT->m_Pos = m_CurrentScreen->m_Curseur; + STRUCT->m_Flags = IS_NEW; + STRUCT->m_TimeStamp = GetTimeStamp(); + for( int ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) + { + STRUCT->m_Field[ii].m_Pos += new_pos; + } + + RedrawOneStruct( DrawPanel, DC, STRUCT, g_XorMode ); + StartMovePart( STRUCT, DC ); + return; + break; + + default: + g_ItemToRepeat = NULL; + DisplayError( this, wxT( "Repeat Type Error" ), 10 ); + break; + } + + if( g_ItemToRepeat ) + { + g_ItemToRepeat->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = g_ItemToRepeat; + TestDanglingEnds( GetScreen()->EEDrawList, NULL ); + RedrawOneStruct( DrawPanel, DC, g_ItemToRepeat, GR_DEFAULT_DRAWMODE ); + SaveCopyInUndoList( g_ItemToRepeat, IS_NEW ); + g_ItemToRepeat->m_Flags = 0; + +// GetScreen()->Curseur = new_pos; // GRMouseWarp(DrawPanel, DrawPanel->CursorScreenPosition() ); - } + } } /******************************************/ -void IncrementLabelMember(wxString & name) +void IncrementLabelMember( wxString& name ) /******************************************/ + /* Routine incrementant les labels, c'est a dire pour les textes finissant -par un nombre, ajoutant <RepeatDeltaLabel> a ce nombre -*/ + * par un nombre, ajoutant <RepeatDeltaLabel> a ce nombre + */ { -int ii, nn; -long number = 0; - - ii = name.Len() - 1; nn = 0; - if( !isdigit(name.GetChar(ii)) ) return; + int ii, nn; + long number = 0; - while( (ii >= 0) && isdigit(name.GetChar(ii)) ) { ii--; nn++ ; } - ii++; /* digits are starting at ii position */ -wxString litt_number = name.Right(nn); - if ( litt_number.ToLong(&number) ) - { - number += g_RepeatDeltaLabel; - name.Remove(ii); name << number; - } + ii = name.Len() - 1; nn = 0; + if( !isdigit( name.GetChar( ii ) ) ) + return; + + while( (ii >= 0) && isdigit( name.GetChar( ii ) ) ) + { + ii--; nn++; + } + + ii++; /* digits are starting at ii position */ + wxString litt_number = name.Right( nn ); + if( litt_number.ToLong( &number ) ) + { + number += g_RepeatDeltaLabel; + name.Remove( ii ); name << number; + } } + /***************************************************************************/ -static bool IsTerminalPoint(SCH_SCREEN * screen, const wxPoint & pos, int layer) +static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ) /***************************************************************************/ + /* Returne TRUE si pos est un point possible pour terminer automatiquement un -segment, c'est a dire pour - - type WIRE, si il y a - - une jonction - - ou une pin - - ou une extr�mit� unique de fil - - - type BUS, si il y a - - ou une extr�mit� unique de BUS -*/ + * segment, c'est a dire pour + * - type WIRE, si il y a + * - une jonction + * - ou une pin + * - ou une extr�mit� unique de fil + * + * - type BUS, si il y a + * - ou une extr�mit� unique de BUS + */ { -EDA_BaseStruct * item; -LibDrawPin * pin; -EDA_SchComponentStruct * LibItem = NULL; -DrawSheetLabelStruct * pinsheet; -wxPoint itempos; + EDA_BaseStruct* item; + LibDrawPin* pin; + EDA_SchComponentStruct* LibItem = NULL; + DrawSheetLabelStruct* pinsheet; + wxPoint itempos; - switch ( layer ) - { - case LAYER_BUS: - item = PickStruct(pos, screen->EEDrawList, BUSITEM); - if ( item ) return TRUE; - pinsheet = LocateAnyPinSheet(pos, screen->EEDrawList ); - if ( pinsheet && IsBusLabel(pinsheet->m_Text) ) - { - itempos = pinsheet->m_Pos; - if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE; - } - break; + switch( layer ) + { + case LAYER_BUS: + item = PickStruct( pos, screen->EEDrawList, BUSITEM ); + if( item ) + return TRUE; + pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList ); + if( pinsheet && IsBusLabel( pinsheet->m_Text ) ) + { + itempos = pinsheet->m_Pos; + if( (itempos.x == pos.x) && (itempos.y == pos.y) ) + return TRUE; + } + break; - case LAYER_NOTES: - item = PickStruct(pos, screen->EEDrawList, DRAWITEM); - if ( item ) - return TRUE; - break; + case LAYER_NOTES: + item = PickStruct( pos, screen->EEDrawList, DRAWITEM ); + if( item ) + return TRUE; + break; - case LAYER_WIRE: - item = PickStruct(pos, screen->EEDrawList, RACCORDITEM |JUNCTIONITEM); - if ( item ) return TRUE; + case LAYER_WIRE: + item = PickStruct( pos, screen->EEDrawList, RACCORDITEM | JUNCTIONITEM ); + if( item ) + return TRUE; - pin = LocateAnyPin( screen->EEDrawList, pos, &LibItem ); - if ( pin && LibItem ) - { - // calcul de la position exacte du point de connexion de la pin, - // selon orientation du composant: - itempos = LibItem->GetScreenCoord(pin->m_Pos); - itempos.x += LibItem->m_Pos.x; - itempos.y += LibItem->m_Pos.y; - if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE; - } + pin = LocateAnyPin( screen->EEDrawList, pos, &LibItem ); + if( pin && LibItem ) + { + // calcul de la position exacte du point de connexion de la pin, + // selon orientation du composant: + itempos = LibItem->GetScreenCoord( pin->m_Pos ); + itempos.x += LibItem->m_Pos.x; + itempos.y += LibItem->m_Pos.y; + if( (itempos.x == pos.x) && (itempos.y == pos.y) ) + return TRUE; + } - item = PickStruct(pos, screen->EEDrawList, WIREITEM); - if ( item ) return TRUE; + item = PickStruct( pos, screen->EEDrawList, WIREITEM ); + if( item ) + return TRUE; - item = PickStruct(pos, screen->EEDrawList, LABELITEM); - if ( item && (item->m_StructType != DRAW_TEXT_STRUCT_TYPE) && - ( ((DrawGlobalLabelStruct*)item)->m_Pos.x == pos.x) && - ( ((DrawGlobalLabelStruct*)item)->m_Pos.y == pos.y) ) - return TRUE; + item = PickStruct( pos, screen->EEDrawList, LABELITEM ); + if( item && (item->m_StructType != DRAW_TEXT_STRUCT_TYPE) + && ( ( (DrawGlobalLabelStruct*) item )->m_Pos.x == pos.x ) + && ( ( (DrawGlobalLabelStruct*) item )->m_Pos.y == pos.y ) ) + return TRUE; - pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList ); - if ( pinsheet && ! IsBusLabel(pinsheet->m_Text) ) - { - itempos = pinsheet->m_Pos; - if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE; - } + pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList ); + if( pinsheet && !IsBusLabel( pinsheet->m_Text ) ) + { + itempos = pinsheet->m_Pos; + if( (itempos.x == pos.x) && (itempos.y == pos.y) ) + return TRUE; + } - break; + break; - default: - break; - } + default: + break; + } - return FALSE; + return FALSE; } /****************************************************************/ -bool IsJunctionNeeded (WinEDA_SchematicFrame * frame, wxPoint & pos ) +bool IsJunctionNeeded( WinEDA_SchematicFrame* frame, wxPoint& pos ) /****************************************************************/ + /* Return True when a wire is located at pos "pos" if - - there is no junction. - - The wire has no ends at pos "pos", - and therefore it is considered as no connected. - - One (or more) wire has one end at pos "pos" - or - - a pin is on location pos -*/ + * - there is no junction. + * - The wire has no ends at pos "pos", + * and therefore it is considered as no connected. + * - One (or more) wire has one end at pos "pos" + * or + * - a pin is on location pos + */ { - if ( PickStruct(pos,frame->GetScreen()->EEDrawList, JUNCTIONITEM ) ) return FALSE; - - if ( PickStruct(pos,frame->GetScreen()->EEDrawList, WIREITEM |EXCLUDE_WIRE_BUS_ENDPOINTS ) ) - { - if ( PickStruct(pos,frame->GetScreen()->EEDrawList, WIREITEM |WIRE_BUS_ENDPOINTS_ONLY ) ) - return TRUE; - if ( frame->LocatePinEnd(frame->GetScreen()->EEDrawList, pos) ) - return TRUE; - } + if( PickStruct( pos, frame->GetScreen()->EEDrawList, JUNCTIONITEM ) ) + return FALSE; - return FALSE; + if( PickStruct( pos, frame->GetScreen()->EEDrawList, WIREITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) ) + { + if( PickStruct( pos, frame->GetScreen()->EEDrawList, WIREITEM | WIRE_BUS_ENDPOINTS_ONLY ) ) + return TRUE; + if( frame->LocatePinEnd( frame->GetScreen()->EEDrawList, pos ) ) + return TRUE; + } + + return FALSE; } - diff --git a/eeschema/busentry.cpp b/eeschema/busentry.cpp index 6005dc4ce6..80f70cc26d 100644 --- a/eeschema/busentry.cpp +++ b/eeschema/busentry.cpp @@ -17,156 +17,164 @@ /* Routines Locales */ /* Variables locales */ -static int s_LastShape = '\\'; +static int s_LastShape = '\\'; static wxPoint ItemInitialPosition; /**************************************************************/ -static void ExitBusEntry( WinEDA_DrawPanel * Panel, wxDC * DC ) +static void ExitBusEntry( WinEDA_DrawPanel* Panel, wxDC* DC ) /**************************************************************/ /* Routine de sortie des menus de trace */ { -DrawBusEntryStruct *BusEntry = - (DrawBusEntryStruct *)Panel->GetScreen()->m_CurrentItem; + DrawBusEntryStruct* BusEntry = + (DrawBusEntryStruct*) Panel->GetScreen()->GetCurItem(); - if( BusEntry) /* trace en cours */ - { - RedrawOneStruct(Panel, DC, BusEntry, g_XorMode); - if( BusEntry->m_Flags & IS_NEW ) - { - delete BusEntry; - Panel->GetScreen()->m_CurrentItem = NULL; - } - else - { - BusEntry->m_Pos = ItemInitialPosition; - RedrawOneStruct(Panel, DC, BusEntry, GR_DEFAULT_DRAWMODE); - BusEntry->m_Flags = 0; - } - } + if( BusEntry ) /* trace en cours */ + { + RedrawOneStruct( Panel, DC, BusEntry, g_XorMode ); + if( BusEntry->m_Flags & IS_NEW ) + { + delete BusEntry; + Panel->GetScreen()->SetCurItem( NULL ); + } + else + { + BusEntry->m_Pos = ItemInitialPosition; + RedrawOneStruct( Panel, DC, BusEntry, GR_DEFAULT_DRAWMODE ); + BusEntry->m_Flags = 0; + } + } - g_ItemToRepeat = NULL; - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; + g_ItemToRepeat = NULL; + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; } + /************************************************************************/ -static void ShowWhileMoving(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /************************************************************************/ + /* Dessin du Segment "BusEntry" lors des deplacements du curseur -*/ + */ { -BASE_SCREEN * screen = panel->m_Parent->GetScreen(); -DrawBusEntryStruct *BusEntry = (DrawBusEntryStruct *) screen->m_CurrentItem; - - if( BusEntry == NULL ) return; + BASE_SCREEN* screen = panel->m_Parent->GetScreen(); + DrawBusEntryStruct* BusEntry = (DrawBusEntryStruct*) screen->GetCurItem(); - /* effacement apres deplacement curseur */ - if( erase ) - RedrawOneStruct(panel, DC, BusEntry, g_XorMode); + if( BusEntry == NULL ) + return; - /* Reaffichage au bon endroit */ - BusEntry->m_Pos = screen->m_Curseur; - RedrawOneStruct(panel, DC, BusEntry, g_XorMode); + /* effacement apres deplacement curseur */ + if( erase ) + RedrawOneStruct( panel, DC, BusEntry, g_XorMode ); + + /* Reaffichage au bon endroit */ + BusEntry->m_Pos = screen->m_Curseur; + RedrawOneStruct( panel, DC, BusEntry, g_XorMode ); } + /**********************************************************************************/ -DrawBusEntryStruct * WinEDA_SchematicFrame::CreateBusEntry(wxDC * DC, int entry_type) +DrawBusEntryStruct* WinEDA_SchematicFrame::CreateBusEntry( wxDC* DC, int entry_type ) /**********************************************************************************/ + /* Create a new bus entry, and prepare moving function (for later place it) -*/ + */ { -DrawBusEntryStruct * BusEntry = new DrawBusEntryStruct(GetScreen()->m_Curseur, - s_LastShape , entry_type); - BusEntry->m_Flags = IS_NEW; + DrawBusEntryStruct* BusEntry = new DrawBusEntryStruct( GetScreen()->m_Curseur, + s_LastShape, entry_type ); - DrawPanel->CursorOff(DC); // Erase schematic cursor - RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode); - DrawPanel->CursorOn(DC); // Display schematic cursor + BusEntry->m_Flags = IS_NEW; - GetScreen()->SetModify(); + DrawPanel->CursorOff( DC ); // Erase schematic cursor + RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode ); + DrawPanel->CursorOn( DC ); // Display schematic cursor - StartMoveBusEntry(BusEntry, DC); - return BusEntry; + GetScreen()->SetModify(); + + StartMoveBusEntry( BusEntry, DC ); + return BusEntry; } /**************************************************************************/ -void WinEDA_SchematicFrame::StartMoveBusEntry(DrawBusEntryStruct * BusEntry, - wxDC * DC) +void WinEDA_SchematicFrame::StartMoveBusEntry( DrawBusEntryStruct* BusEntry, + wxDC* DC ) /**************************************************************************/ { - if ( BusEntry == NULL ) return; + if( BusEntry == NULL ) + return; - if ( (BusEntry->m_Flags & IS_NEW) == 0 ) // => not already in edit, save shape */ - { - delete g_ItemToUndoCopy; - g_ItemToUndoCopy = BusEntry->GenCopy(); - } + if( (BusEntry->m_Flags & IS_NEW) == 0 ) // => not already in edit, save shape */ + { + delete g_ItemToUndoCopy; + g_ItemToUndoCopy = BusEntry->GenCopy(); + } - BusEntry->m_Flags |= IS_MOVED; + BusEntry->m_Flags |= IS_MOVED; - ItemInitialPosition = BusEntry->m_Pos; + ItemInitialPosition = BusEntry->m_Pos; - DrawPanel->CursorOff(DC); - GetScreen()->m_Curseur = BusEntry->m_Pos; - DrawPanel->MouseToCursorSchema(); - - GetScreen()->m_CurrentItem = BusEntry; - DrawPanel->ManageCurseur = ShowWhileMoving; - DrawPanel->ForceCloseManageCurseur = ExitBusEntry; - - DrawPanel->CursorOn(DC); + DrawPanel->CursorOff( DC ); + GetScreen()->m_Curseur = BusEntry->m_Pos; + DrawPanel->MouseToCursorSchema(); + + GetScreen()->SetCurItem( BusEntry ); + DrawPanel->ManageCurseur = ShowWhileMoving; + DrawPanel->ForceCloseManageCurseur = ExitBusEntry; + + DrawPanel->CursorOn( DC ); } /************************************************************/ -void WinEDA_SchematicFrame::SetBusEntryShape(wxDC * DC, - DrawBusEntryStruct *BusEntry, int entry_shape) +void WinEDA_SchematicFrame::SetBusEntryShape( wxDC* DC, + DrawBusEntryStruct* BusEntry, int entry_shape ) /************************************************************/ + /* set the shape of BusEntry (shape = / or \ ) -*/ + */ { - if ( BusEntry == NULL ) return; + if( BusEntry == NULL ) + return; - if ( BusEntry->m_StructType != DRAW_BUSENTRY_STRUCT_TYPE ) - { - DisplayError(this, wxT("SetBusEntryType: Bad StructType") ); - return; - } + if( BusEntry->m_StructType != DRAW_BUSENTRY_STRUCT_TYPE ) + { + DisplayError( this, wxT( "SetBusEntryType: Bad StructType" ) ); + return; + } - /* Put old item in undo list if it is not currently in edit */ - if ( BusEntry->m_Flags == 0 ) SaveCopyInUndoList(BusEntry, IS_CHANGED); + /* Put old item in undo list if it is not currently in edit */ + if( BusEntry->m_Flags == 0 ) + SaveCopyInUndoList( BusEntry, IS_CHANGED ); - RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode); + RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode ); - switch( entry_shape ) - { - case '\\' : - s_LastShape = '\\'; - BusEntry->m_Size.y = 100; - break; + switch( entry_shape ) + { + case '\\': + s_LastShape = '\\'; + BusEntry->m_Size.y = 100; + break; - case '/' : - s_LastShape = '/'; - BusEntry->m_Size.y = -100; - break; - } + case '/': + s_LastShape = '/'; + BusEntry->m_Size.y = -100; + break; + } - TestDanglingEnds(GetScreen()->EEDrawList, NULL); - RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode); - GetScreen()->SetModify(); + TestDanglingEnds( GetScreen()->EEDrawList, NULL ); + RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode ); + GetScreen()->SetModify(); } /************************************************************************/ -int WinEDA_SchematicFrame::GetBusEntryShape( DrawBusEntryStruct *BusEntry) +int WinEDA_SchematicFrame::GetBusEntryShape( DrawBusEntryStruct* BusEntry ) /************************************************************************/ { -int entry_shape = '\\'; + int entry_shape = '\\'; - if ( BusEntry->m_Size.y < 0 ) entry_shape = '/'; - return entry_shape; + if( BusEntry->m_Size.y < 0 ) + entry_shape = '/'; + return entry_shape; } - - - diff --git a/eeschema/class_screen.cpp b/eeschema/class_screen.cpp index eb4b96338f..6910f8d9a2 100644 --- a/eeschema/class_screen.cpp +++ b/eeschema/class_screen.cpp @@ -14,130 +14,135 @@ #include "protos.h" /******************************************************************/ -void SetStructFather(EDA_BaseStruct * Struct, BASE_SCREEN * Screen) +void SetStructFather( EDA_BaseStruct* Struct, BASE_SCREEN* Screen ) /******************************************************************/ { - switch( Struct->m_StructType ) - { - case DRAW_POLYLINE_STRUCT_TYPE: - case DRAW_JUNCTION_STRUCT_TYPE: - case DRAW_TEXT_STRUCT_TYPE: - case DRAW_LABEL_STRUCT_TYPE: - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - case DRAW_LIB_ITEM_STRUCT_TYPE: - case DRAW_SEGMENT_STRUCT_TYPE: - case DRAW_BUSENTRY_STRUCT_TYPE: - case DRAW_SHEET_STRUCT_TYPE: - case DRAW_MARKER_STRUCT_TYPE: - case DRAW_NOCONNECT_STRUCT_TYPE: - Struct->m_Parent = Screen; - break; + switch( Struct->m_StructType ) + { + case DRAW_POLYLINE_STRUCT_TYPE: + case DRAW_JUNCTION_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_LIB_ITEM_STRUCT_TYPE: + case DRAW_SEGMENT_STRUCT_TYPE: + case DRAW_BUSENTRY_STRUCT_TYPE: + case DRAW_SHEET_STRUCT_TYPE: + case DRAW_MARKER_STRUCT_TYPE: + case DRAW_NOCONNECT_STRUCT_TYPE: + Struct->m_Parent = Screen; + break; - case DRAW_SHEETLABEL_STRUCT_TYPE: - case DRAW_PICK_ITEM_STRUCT_TYPE: - break; + case DRAW_SHEETLABEL_STRUCT_TYPE: + case DRAW_PICK_ITEM_STRUCT_TYPE: + break; - default: - break; - } + default: + break; + } } + /***************************************************************/ -void EDA_BaseStruct::Place(WinEDA_DrawFrame * frame, wxDC * DC) +void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) /***************************************************************/ + /* place the struct in EEDrawList. - if it is a new item, it it also put in undo list - for an "old" item, saving it in undo list must be done before editiing, and not here! -*/ + * if it is a new item, it it also put in undo list + * for an "old" item, saving it in undo list must be done before editiing, and not here! + */ { - if( m_Flags & IS_NEW) - { - Pnext = frame->m_CurrentScreen->EEDrawList; - frame->m_CurrentScreen->EEDrawList = this; - g_ItemToRepeat = this; - if ( frame->m_Ident == SCHEMATIC_FRAME ) - ((WinEDA_SchematicFrame *)frame)->SaveCopyInUndoList(this, IS_NEW); - } + if( m_Flags & IS_NEW ) + { + Pnext = frame->m_CurrentScreen->EEDrawList; + frame->m_CurrentScreen->EEDrawList = this; + g_ItemToRepeat = this; + if( frame->m_Ident == SCHEMATIC_FRAME ) + ( (WinEDA_SchematicFrame*) frame )->SaveCopyInUndoList( this, IS_NEW ); + } - m_Flags = 0; - frame->GetScreen()->SetModify(); - frame->GetScreen()->m_CurrentItem = NULL; - frame->DrawPanel->ManageCurseur = NULL; - frame->DrawPanel->ForceCloseManageCurseur = NULL; + m_Flags = 0; + frame->GetScreen()->SetModify(); + frame->GetScreen()->SetCurItem( NULL ); + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; - if ( DC ) - { - frame->DrawPanel->CursorOff(DC); // Erase schematic cursor - RedrawOneStruct(frame->DrawPanel, DC, this, GR_DEFAULT_DRAWMODE); - frame->DrawPanel->CursorOn(DC); // Display schematic cursor - } + if( DC ) + { + frame->DrawPanel->CursorOff( DC ); // Erase schematic cursor + RedrawOneStruct( frame->DrawPanel, DC, this, GR_DEFAULT_DRAWMODE ); + frame->DrawPanel->CursorOn( DC ); // Display schematic cursor + } } /***********************************************************************/ /* Class SCH_SCREEN: classe de gestion d'un affichage pour schematique */ /***********************************************************************/ -static int table_zoom[] = {1,2,4,8,16,32,64,128, 0}; /* Valeurs standards du zoom */ +static int table_zoom[] = { 1, 2, 4, 8, 16, 32, 64, 128, 0 }; /* Valeurs standards du zoom */ /* Constructeur de SCREEN */ -SCH_SCREEN::SCH_SCREEN(int screentype): BASE_SCREEN(screentype) +SCH_SCREEN::SCH_SCREEN( int screentype ) : BASE_SCREEN( screentype ) { - EEDrawList = NULL; /* Schematic items list */ - m_Zoom = 32; - m_Grid = wxSize(50,50); /* pas de la grille */ - SetZoomList(table_zoom); - SetGridList(g_GridList); - m_UndoRedoCountMax = 10; - + EEDrawList = NULL; /* Schematic items list */ + m_Zoom = 32; + m_Grid = wxSize( 50, 50 ); /* pas de la grille */ + SetZoomList( table_zoom ); + SetGridList( g_GridList ); + m_UndoRedoCountMax = 10; } + /****************************/ -SCH_SCREEN::~SCH_SCREEN(void) +SCH_SCREEN::~SCH_SCREEN( void ) /****************************/ { - ClearUndoRedoList(); - FreeDrawList(); + ClearUndoRedoList(); + FreeDrawList(); } /***********************************/ -void SCH_SCREEN::FreeDrawList(void) +void SCH_SCREEN::FreeDrawList( void ) /***********************************/ + /* Routine to clear (free) EESchema drawing list of a screen. -*/ + */ { -EDA_BaseStruct *DrawStruct; + EDA_BaseStruct* DrawStruct; - while (EEDrawList != NULL) - { - DrawStruct = EEDrawList; - EEDrawList = EEDrawList->Pnext; - delete DrawStruct; - } + while( EEDrawList != NULL ) + { + DrawStruct = EEDrawList; + EEDrawList = EEDrawList->Pnext; + delete DrawStruct; + } } + /**************************************************************/ -void SCH_SCREEN::RemoveFromDrawList(EDA_BaseStruct *DrawStruct) +void SCH_SCREEN::RemoveFromDrawList( EDA_BaseStruct* DrawStruct ) /**************************************************************/ + /* If found in EEDrawList, remove DrawStruct from EEDrawList. - DrawStruct is not deleted or modified -*/ + * DrawStruct is not deleted or modified + */ { - if (DrawStruct == EEDrawList) - EEDrawList = EEDrawList->Pnext; - else - { - EDA_BaseStruct * DrawList = EEDrawList; - while (DrawList->Pnext) - { - if (DrawList->Pnext == DrawStruct) - { - DrawList->Pnext = DrawList->Pnext->Pnext; - break; - } - DrawList = DrawList->Pnext; - } - } + if( DrawStruct == EEDrawList ) + EEDrawList = EEDrawList->Pnext; + else + { + EDA_BaseStruct* DrawList = EEDrawList; + while( DrawList->Pnext ) + { + if( DrawList->Pnext == DrawStruct ) + { + DrawList->Pnext = DrawList->Pnext->Pnext; + break; + } + DrawList = DrawList->Pnext; + } + } } @@ -145,156 +150,175 @@ void SCH_SCREEN::RemoveFromDrawList(EDA_BaseStruct *DrawStruct) /* Class EDA_ScreenList to handle the list of screens in a hierarchy */ /*********************************************************************/ -EDA_ScreenList::EDA_ScreenList(EDA_BaseStruct * DrawStruct) +EDA_ScreenList::EDA_ScreenList( EDA_BaseStruct* DrawStruct ) + /* create the list of screens (i.e hierarchycal sheets) found in DrawStruct -if DrawStruct == NULL: start from root sheet and the root screen is included in list -*/ + * if DrawStruct == NULL: start from root sheet and the root screen is included in list + */ { - m_Count = 0; - m_List = NULL; - m_Index = 0; - - /* Count the number of screens */ - BuildScreenList(NULL, DrawStruct, & m_Count); - if( m_Count > NB_MAX_SHEET ) - { - wxString msg; - msg.Printf(wxT("ReturnScreenList: Error: screen count > %d"), NB_MAX_SHEET); - DisplayError(NULL, msg); - } + m_Count = 0; + m_List = NULL; + m_Index = 0; + + /* Count the number of screens */ + BuildScreenList( NULL, DrawStruct, &m_Count ); + if( m_Count > NB_MAX_SHEET ) + { + wxString msg; + msg.Printf( wxT( "ReturnScreenList: Error: screen count > %d" ), NB_MAX_SHEET ); + DisplayError( NULL, msg ); + } - m_List = (SCH_SCREEN **) MyZMalloc( sizeof(SCH_SCREEN *) * (m_Count + 2) ); - /* Fill the list */ - BuildScreenList(m_List, DrawStruct, & m_Count); + m_List = (SCH_SCREEN**) MyZMalloc( sizeof(SCH_SCREEN *) * (m_Count + 2) ); + /* Fill the list */ + BuildScreenList( m_List, DrawStruct, &m_Count ); } + /*****************************************/ EDA_ScreenList::~EDA_ScreenList() /*****************************************/ { - if ( m_List ) free( m_List ); - m_List = NULL; + if( m_List ) + free( m_List ); + m_List = NULL; } + /*****************************************/ -SCH_SCREEN * EDA_ScreenList::GetFirst(void) +SCH_SCREEN* EDA_ScreenList::GetFirst( void ) /*****************************************/ { - m_Index = 0; - if ( m_List ) return * m_List; - else return NULL; + m_Index = 0; + if( m_List ) + return *m_List; + else + return NULL; } + /*****************************************/ -SCH_SCREEN * EDA_ScreenList::GetNext(void) +SCH_SCREEN* EDA_ScreenList::GetNext( void ) /*****************************************/ { - if (m_Index < m_Count) m_Index ++; - - if ( (m_Index < m_Count) && m_List ) - { - return m_List[m_Index]; - } - else return NULL; + if( m_Index < m_Count ) + m_Index++; + + if( (m_Index < m_Count) && m_List ) + { + return m_List[m_Index]; + } + else + return NULL; } + /************************************************/ -SCH_SCREEN * EDA_ScreenList::GetScreen(int index) +SCH_SCREEN* EDA_ScreenList::GetScreen( int index ) /************************************************/ + /* return the m_List[index] item -*/ + */ { -SCH_SCREEN * screen = NULL; - - if( (index >= 0) && index < m_Count ) - screen = m_List[index]; + SCH_SCREEN* screen = NULL; - return screen; + if( (index >= 0) && index < m_Count ) + screen = m_List[index]; + + return screen; } + /**************************************************/ -void EDA_ScreenList::UpdateSheetNumberAndDate(void) +void EDA_ScreenList::UpdateSheetNumberAndDate( void ) /**************************************************/ + /* Update the sheet number, the sheet count and the date for all sheets in list -*/ + */ { -int SheetNumber = 1; -SCH_SCREEN * screen; -wxString sheet_date = GenDate(); - - for ( screen = GetFirst(); screen != NULL; screen = GetNext() ) - { - screen->m_SheetNumber = SheetNumber++; /* Update the sheet number */ - screen->m_NumberOfSheet = m_Count; /* Update the number of sheets */ - screen->m_Date = sheet_date; /* Update the sheet date */ - } + int SheetNumber = 1; + SCH_SCREEN* screen; + wxString sheet_date = GenDate(); + + for( screen = GetFirst(); screen != NULL; screen = GetNext() ) + { + screen->m_SheetNumber = SheetNumber++; /* Update the sheet number */ + screen->m_NumberOfSheet = m_Count; /* Update the number of sheets */ + screen->m_Date = sheet_date; /* Update the sheet date */ + } } + /************************************************************************/ -SCH_SCREEN ** EDA_ScreenList::BuildScreenList(SCH_SCREEN ** ScreenList, - EDA_BaseStruct * DrawStruct, int * Count) +SCH_SCREEN** EDA_ScreenList::BuildScreenList( SCH_SCREEN** ScreenList, + EDA_BaseStruct* DrawStruct, int* Count ) /************************************************************************/ + /* Count the Hierachical sheet number (ScreenList == NULL ) - or fill the screen pointer buffer (ScreenList != NULL ) - If DrawStruct = NULL, search starts from Root screen, and puts root screen in list - Recursive function ! -*/ + * or fill the screen pointer buffer (ScreenList != NULL ) + * If DrawStruct = NULL, search starts from Root screen, and puts root screen in list + * Recursive function ! + */ { -bool HasSubhierarchy = FALSE; -EDA_BaseStruct * CurrStruct; - - if( * Count > NB_MAX_SHEET ) - { - return ScreenList; - } + bool HasSubhierarchy = FALSE; + EDA_BaseStruct* CurrStruct; - /* Read the current list and put Screen pointers in list */ - if ( DrawStruct == NULL ) - { - DrawStruct = ScreenSch->EEDrawList; - if ( ScreenList ) - { - *ScreenList = ScreenSch; - ScreenList++; - } - else (*Count)++; - } - - CurrStruct = DrawStruct; - while( CurrStruct ) - { - if(CurrStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE ) - { - HasSubhierarchy = TRUE; - if ( ScreenList ) - { - *ScreenList = (SCH_SCREEN*) CurrStruct; - ScreenList++; - } - else (*Count)++; - } - CurrStruct = CurrStruct->Pnext; - } - - if ( ! HasSubhierarchy ) return ScreenList; - - /* Read the Sub Hierarchies */ - CurrStruct = DrawStruct; - while( CurrStruct ) - { - if(CurrStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE ) - { - SCH_SCREEN* Screen = (SCH_SCREEN*) CurrStruct; - /* Go to Subhierachy if needed - (warning: BuildScreenList must not called with a NULL parameter - for DrawStruct, because BuildScreenList restart from the root screen - when DrawStruct == NULL */ - if ( Screen->EEDrawList ) - ScreenList = BuildScreenList(ScreenList, Screen->EEDrawList,Count); - } - CurrStruct = CurrStruct->Pnext; - } - return ScreenList; + if( *Count > NB_MAX_SHEET ) + { + return ScreenList; + } + + /* Read the current list and put Screen pointers in list */ + if( DrawStruct == NULL ) + { + DrawStruct = ScreenSch->EEDrawList; + if( ScreenList ) + { + *ScreenList = ScreenSch; + ScreenList++; + } + else + (*Count)++; + } + + CurrStruct = DrawStruct; + while( CurrStruct ) + { + if( CurrStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE ) + { + HasSubhierarchy = TRUE; + if( ScreenList ) + { + *ScreenList = (SCH_SCREEN*) CurrStruct; + ScreenList++; + } + else + (*Count)++; + } + CurrStruct = CurrStruct->Pnext; + } + + if( !HasSubhierarchy ) + return ScreenList; + + /* Read the Sub Hierarchies */ + CurrStruct = DrawStruct; + while( CurrStruct ) + { + if( CurrStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE ) + { + SCH_SCREEN* Screen = (SCH_SCREEN*) CurrStruct; + + /* Go to Subhierachy if needed + * (warning: BuildScreenList must not called with a NULL parameter + * for DrawStruct, because BuildScreenList restart from the root screen + * when DrawStruct == NULL */ + if( Screen->EEDrawList ) + ScreenList = BuildScreenList( ScreenList, Screen->EEDrawList, Count ); + } + CurrStruct = CurrStruct->Pnext; + } + + return ScreenList; } - diff --git a/eeschema/class_screen.h b/eeschema/class_screen.h index 467ac548a4..29f1c88dcb 100644 --- a/eeschema/class_screen.h +++ b/eeschema/class_screen.h @@ -1,6 +1,6 @@ - /********************************************/ - /* Definitions for the EESchema program: */ - /********************************************/ +/********************************************/ +/* Definitions for the EESchema program: */ +/********************************************/ #ifndef CLASS_SCREEN_H #define CLASS_SCREEN_H @@ -18,66 +18,66 @@ /* Type des labels sur sheet (Labels sur hierarchie) et forme des Global-Labels*/ typedef enum { - NET_INPUT, - NET_OUTPUT, - NET_BIDI, - NET_TRISTATE, - NET_UNSPECIFIED, - NET_TMAX /* Derniere valeur: fin de tableau */ + NET_INPUT, + NET_OUTPUT, + NET_BIDI, + NET_TRISTATE, + NET_UNSPECIFIED, + NET_TMAX /* Derniere valeur: fin de tableau */ } TypeSheetLabel; /* Messages correspondants aux types ou forme des labels */ #ifdef MAIN -const char * SheetLabelType[] = - { - "Input", - "Output", - "BiDi", - "3State", - "UnSpc", - "?????" - }; +const char* SheetLabelType[] = +{ + "Input", + "Output", + "BiDi", + "3State", + "UnSpc", + "?????" +}; #else -extern const char * SheetLabelType[]; +extern const char* SheetLabelType[]; #endif /* Description du graphisme des icones associes aux types des Global_Labels */ #ifdef MAIN -int TemplateIN_HN[] = {6, 0,0, -1,-1, -2,-1, -2,1, -1,1, 0,0}; -int TemplateIN_HI[] = {6, 0,0, 1,1, 2,1, 2,-1, 1,-1, 0,0}; -int TemplateIN_BOTTOM[] = {6, 0,0, 1,-1, 1,-2, -1,-2, -1,-1, 0,0}; -int TemplateIN_UP[] = {6, 0,0, 1,1, 1,2, -1,2, -1,1, 0,0}; - -int TemplateOUT_HN[] = {6, -2,0, -1,1, 0,1, 0,-1, -1,-1, -2,0}; -int TemplateOUT_HI[] = {6, 2,0, 1,-1, 0,-1, 0,1, 1,1, 2,0}; -int TemplateOUT_BOTTOM[] = {6, 0,-2, 1,-1, 1,0, -1,0, -1,-1, 0,-2}; -int TemplateOUT_UP[] = {6, 0,2, 1,1, 1,0, -1,0, -1,1, 0,2}; - -int TemplateUNSPC_HN[] = {5, 0,-1, -2,-1, -2,1, 0,1, 0,-1}; -int TemplateUNSPC_HI[] = {5, 0,-1, 2,-1, 2,1, 0,1, 0,-1}; -int TemplateUNSPC_BOTTOM[] = {5, 1,0, 1,-2, -1,-2, -1,0, 1,0}; -int TemplateUNSPC_UP[] = {5, 1,0, 1,2, -1,2, -1,0, 1,0}; - -int TemplateBIDI_HN[] = {5, 0,0, -1,-1, -2,0, -1,1, 0,0}; -int TemplateBIDI_HI[] = {5, 0,0, 1,-1, 2,0, 1,1, 0,0}; -int TemplateBIDI_BOTTOM[] = {5, 0,0, -1,-1, 0,-2, 1,-1, 0,0}; -int TemplateBIDI_UP[] = {5, 0,0, -1, 1, 0, 2, 1, 1, 0,0}; - -int Template3STATE_HN[] = {5, 0,0, -1,-1, -2,0, -1,1, 0,0}; -int Template3STATE_HI[] = {5, 0,0, 1,-1, 2,0, 1,1, 0,0}; -int Template3STATE_BOTTOM[] = {5, 0,0, -1,-1, 0,-2, 1,-1, 0,0}; -int Template3STATE_UP[] = {5, 0,0, -1,1, 0,2, 1,1, 0,0}; - -int * TemplateShape[5][4] = - { - {TemplateIN_HN,TemplateIN_UP,TemplateIN_HI,TemplateIN_BOTTOM}, - {TemplateOUT_HN,TemplateOUT_UP,TemplateOUT_HI,TemplateOUT_BOTTOM}, - {TemplateBIDI_HN,TemplateBIDI_UP,TemplateBIDI_HI,TemplateBIDI_BOTTOM}, - {Template3STATE_HN,Template3STATE_UP,Template3STATE_HI,Template3STATE_BOTTOM}, - {TemplateUNSPC_HN,TemplateUNSPC_UP,TemplateUNSPC_HI,TemplateUNSPC_BOTTOM} - }; +int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 }; +int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 }; +int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 }; +int TemplateIN_UP[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 }; + +int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 }; +int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 }; +int TemplateOUT_BOTTOM[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 }; +int TemplateOUT_UP[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 }; + +int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 }; +int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 }; +int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 }; +int TemplateUNSPC_UP[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 }; + +int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 }; +int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 }; +int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 }; +int TemplateBIDI_UP[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 }; + +int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 }; +int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 }; +int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 }; +int Template3STATE_UP[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 }; + +int* TemplateShape[5][4] = +{ + { TemplateIN_HN, TemplateIN_UP, TemplateIN_HI, TemplateIN_BOTTOM }, + { TemplateOUT_HN, TemplateOUT_UP, TemplateOUT_HI, TemplateOUT_BOTTOM }, + { TemplateBIDI_HN, TemplateBIDI_UP, TemplateBIDI_HI, TemplateBIDI_BOTTOM }, + { Template3STATE_HN, Template3STATE_UP, Template3STATE_HI, Template3STATE_BOTTOM }, + { TemplateUNSPC_HN, TemplateUNSPC_UP, TemplateUNSPC_HI, TemplateUNSPC_BOTTOM } +}; #else -extern int * TemplateShape[5][4]; +extern int* TemplateShape[5][4]; #endif @@ -85,69 +85,76 @@ extern int * TemplateShape[5][4]; class DrawSheetStruct; -class SCH_SCREEN: public BASE_SCREEN +class SCH_SCREEN : public BASE_SCREEN { - public: - SCH_SCREEN(int idtype); - ~SCH_SCREEN(); + SCH_SCREEN( int idtype ); + ~SCH_SCREEN(); - void FreeDrawList(void); // Free EESchema drawing list (does not delete the sub hierarchies) - void Place(WinEDA_DrawFrame * frame, wxDC * DC) {}; - void RemoveFromDrawList(EDA_BaseStruct *DrawStruct);/* remove DrawStruct from EEDrawList. */ - void ClearUndoORRedoList(EDA_BaseStruct *List); - - bool SchematicCleanUp( wxDC * DC = NULL ); - EDA_BaseStruct * ExtractWires(bool CreateCopy); + void FreeDrawList( void ); // Free EESchema drawing list (does not delete the sub hierarchies) - /* full undo redo management : */ - virtual void ClearUndoRedoList(void); - virtual void AddItemToUndoList(EDA_BaseStruct * item); - virtual void AddItemToRedoList(EDA_BaseStruct * item); + void Place( WinEDA_DrawFrame* frame, wxDC* DC ) { }; + void RemoveFromDrawList( EDA_BaseStruct* DrawStruct );/* remove DrawStruct from EEDrawList. */ + void ClearUndoORRedoList( EDA_BaseStruct* List ); + + bool SchematicCleanUp( wxDC* DC = NULL ); + EDA_BaseStruct* ExtractWires( bool CreateCopy ); + + /* full undo redo management : */ + virtual void ClearUndoRedoList( void ); + virtual void AddItemToUndoList( EDA_BaseStruct* item ); + virtual void AddItemToRedoList( EDA_BaseStruct* item ); }; - -class DrawSheetLabelStruct: public EDA_BaseStruct, public EDA_TextStruct +class DrawSheetLabelStruct : public EDA_BaseStruct + , public EDA_TextStruct { public: - int m_Edge, m_Shape; - bool m_IsDangling; // TRUE si non connect� + int m_Edge, m_Shape; + bool m_IsDangling; // TRUE si non connect� public: - DrawSheetLabelStruct(DrawSheetStruct * parent, - const wxPoint & pos = wxPoint(0,0), const wxString & text = wxEmptyString); - ~DrawSheetLabelStruct(void) {} - DrawSheetLabelStruct * GenCopy(void); - DrawSheetLabelStruct * Next(void) - { return (DrawSheetLabelStruct *) Pnext;} - void Place(WinEDA_DrawFrame * frame, wxDC * DC); - virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); + DrawSheetLabelStruct( DrawSheetStruct* parent, + const wxPoint& pos = wxPoint( 0, 0 ), + const wxString& text = wxEmptyString ); + + ~DrawSheetLabelStruct( void ) { } + DrawSheetLabelStruct* GenCopy( void ); + + DrawSheetLabelStruct* Next( void ) + { return (DrawSheetLabelStruct*) Pnext; } + + void Place( WinEDA_DrawFrame* frame, wxDC* DC ); + virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, + int draw_mode, int Color = -1 ); }; -class DrawSheetStruct: public SCH_SCREEN /* Gestion de la hierarchie */ +class DrawSheetStruct : public SCH_SCREEN /* Gestion de la hierarchie */ { public: - wxString m_SheetName; - int m_SheetNameSize; + wxString m_SheetName; + int m_SheetNameSize; + // wxString m_FileName; in SCH_SCREEN - int m_FileNameSize; - wxPoint m_Pos; - wxSize m_Size; /* Position and Size of sheet symbol */ - int m_Layer; - DrawSheetLabelStruct *m_Label; /* Points de connection */ - int m_NbLabel; /* Nombre de points de connexion */ + int m_FileNameSize; + wxPoint m_Pos; + wxSize m_Size; /* Position and Size of sheet symbol */ + int m_Layer; + DrawSheetLabelStruct* m_Label; /* Points de connection */ + int m_NbLabel; /* Nombre de points de connexion */ public: - DrawSheetStruct(const wxPoint & pos = wxPoint(0,0) ); - ~DrawSheetStruct(void); - void Place(WinEDA_DrawFrame * frame, wxDC * DC); - DrawSheetStruct * GenCopy(void); - void Display_Infos(WinEDA_DrawFrame * frame); - void CleanupSheet(WinEDA_SchematicFrame * frame, wxDC *DC); - virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); - void SwapData(DrawSheetStruct * copyitem); + DrawSheetStruct( const wxPoint& pos = wxPoint( 0, 0 ) ); + ~DrawSheetStruct( void ); + void Place( WinEDA_DrawFrame* frame, wxDC* DC ); + DrawSheetStruct* GenCopy( void ); + void Display_Infos( WinEDA_DrawFrame* frame ); + void CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC ); + virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, + int draw_mode, int Color = -1 ); + void SwapData( DrawSheetStruct* copyitem ); }; @@ -155,23 +162,22 @@ public: class EDA_ScreenList { private: - int m_Count; - SCH_SCREEN ** m_List; - int m_Index; + int m_Count; + SCH_SCREEN** m_List; + int m_Index; public: - EDA_ScreenList(EDA_BaseStruct * DrawStruct); - ~EDA_ScreenList(); - int GetCount(void) { return m_Count; } - SCH_SCREEN * GetFirst(void); - SCH_SCREEN * GetNext(void); - SCH_SCREEN * GetScreen(int index); - void UpdateSheetNumberAndDate(void); - + EDA_ScreenList( EDA_BaseStruct* DrawStruct ); + ~EDA_ScreenList(); + int GetCount( void ) { return m_Count; } + SCH_SCREEN* GetFirst( void ); + SCH_SCREEN* GetNext( void ); + SCH_SCREEN* GetScreen( int index ); + void UpdateSheetNumberAndDate( void ); + private: - SCH_SCREEN ** BuildScreenList(SCH_SCREEN ** ScreenList, - EDA_BaseStruct * DrawStruct, int * Count); + SCH_SCREEN** BuildScreenList( SCH_SCREEN** ScreenList, + EDA_BaseStruct* DrawStruct, int* Count ); }; #endif /* CLASS_SCREEN_H */ - diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index 16bdf57fdb..66debf52c1 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -395,9 +395,9 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels if( hotkey ) { - if( m_CurrentScreen->m_CurrentItem - && m_CurrentScreen->m_CurrentItem->m_Flags ) - OnHotKey( DC, hotkey, m_CurrentScreen->m_CurrentItem ); + if( m_CurrentScreen->GetCurItem() + && m_CurrentScreen->GetCurItem()->m_Flags ) + OnHotKey( DC, hotkey, m_CurrentScreen->GetCurItem() ); else OnHotKey( DC, hotkey, NULL ); } diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp index cae0c1034d..c83195bcee 100644 --- a/eeschema/edit_component_in_schematic.cpp +++ b/eeschema/edit_component_in_schematic.cpp @@ -1,6 +1,6 @@ - /********************************/ - /* Scehematic component edition */ - /********************************/ +/********************************/ +/* Scehematic component edition */ +/********************************/ #include "fctsys.h" #include "gr_basic.h" @@ -18,141 +18,156 @@ /* Fonctions exportees */ /* Fonctions locales */ -static void AbortMoveCmpField(WinEDA_DrawPanel * Panel, wxDC * DC); -static void MoveCmpField(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC ); +static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); /* variables locales */ -static PartTextStruct * CurrentField; -static int Multiflag; -static int TextFieldSize = DEFAULT_SIZE_TEXT; -static wxPoint OldPos; +static PartTextStruct* CurrentField; +static int Multiflag; +static int TextFieldSize = DEFAULT_SIZE_TEXT; +static wxPoint OldPos; - /************************************/ - /* class WinEDA_PartPropertiesFrame */ - /************************************/ +/************************************/ +/* class WinEDA_PartPropertiesFrame */ +/************************************/ #define ID_ON_SELECT_FIELD 3000 #include "dialog_edit_component_in_schematic.cpp" /**********************************************************************/ -void InstallCmpeditFrame(WinEDA_SchematicFrame * parent, wxPoint & pos, - EDA_SchComponentStruct * cmp) +void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos, + EDA_SchComponentStruct* cmp ) /*********************************************************************/ + /* Create the dialog box for the current component edition -*/ + */ { - parent->DrawPanel->m_IgnoreMouseEvents = TRUE; - if ( cmp->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) - { - DisplayError( parent, wxT("InstallCmpeditFrame() error: This struct is not a component") ); - } - else - { - WinEDA_ComponentPropertiesFrame * frame = - new WinEDA_ComponentPropertiesFrame(parent, cmp); - frame->ShowModal(); frame->Destroy(); - } + parent->DrawPanel->m_IgnoreMouseEvents = TRUE; + if( cmp->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + { + DisplayError( parent, + wxT( "InstallCmpeditFrame() error: This struct is not a component" ) ); + } + else + { + WinEDA_ComponentPropertiesFrame* frame = + new WinEDA_ComponentPropertiesFrame( parent, cmp ); + frame->ShowModal(); frame->Destroy(); + } - parent->DrawPanel->MouseToCursorSchema(); - parent->DrawPanel->m_IgnoreMouseEvents = FALSE; + parent->DrawPanel->MouseToCursorSchema(); + parent->DrawPanel->m_IgnoreMouseEvents = FALSE; } + /*****************************************************/ -void WinEDA_ComponentPropertiesFrame::InitBuffers(void) +void WinEDA_ComponentPropertiesFrame::InitBuffers( void ) /*****************************************************/ + /* Init the buffers to a default value, - or to values from Component!= NULL -*/ + * or to values from Component!= NULL + */ { -int ii; + int ii; - m_CurrentFieldId = REFERENCE; + m_CurrentFieldId = REFERENCE; - /* Init default values */ - for ( ii = 0; ii < NUMBER_OF_FIELDS; ii++) - { - m_FieldSize[ii] = DEFAULT_SIZE_TEXT; - m_FieldFlags[ii] = 1; - m_FieldOrient[ii] = 0; - } + /* Init default values */ + for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) + { + m_FieldSize[ii] = DEFAULT_SIZE_TEXT; + m_FieldFlags[ii] = 1; + m_FieldOrient[ii] = 0; + } - if ( m_Cmp == NULL ) return; + if( m_Cmp == NULL ) + return; - for ( ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ ) - { - m_FieldName[ii] = m_Cmp->ReturnFieldName(ii); - m_FieldText[ii] = m_Cmp->m_Field[ii].m_Text; - m_FieldSize[ii] = m_Cmp->m_Field[ii].m_Size.x; - m_FieldFlags[ii] = - (m_Cmp->m_Field[ii].m_Attributs & TEXT_NO_VISIBLE) ? 0 : 1; - m_FieldOrient[ii] = m_Cmp->m_Field[ii].m_Orient == TEXT_ORIENT_VERT ? 1 : 0; + for( ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ ) + { + m_FieldName[ii] = m_Cmp->ReturnFieldName( ii ); + m_FieldText[ii] = m_Cmp->m_Field[ii].m_Text; + m_FieldSize[ii] = m_Cmp->m_Field[ii].m_Size.x; + m_FieldFlags[ii] = + (m_Cmp->m_Field[ii].m_Attributs & TEXT_NO_VISIBLE) ? 0 : 1; + m_FieldOrient[ii] = m_Cmp->m_Field[ii].m_Orient == TEXT_ORIENT_VERT ? 1 : 0; - if ( m_Cmp->m_Field[ii].m_Text.IsEmpty() ) continue; - // These values have meaning only if this field is not void: - m_FieldPosition[ii] = m_Cmp->m_Field[ii].m_Pos; - m_FieldPosition[ii].x -= m_Cmp->m_Pos.x; - m_FieldPosition[ii].y -= m_Cmp->m_Pos.y; - } + if( m_Cmp->m_Field[ii].m_Text.IsEmpty() ) + continue; + + // These values have meaning only if this field is not void: + m_FieldPosition[ii] = m_Cmp->m_Field[ii].m_Pos; + m_FieldPosition[ii].x -= m_Cmp->m_Pos.x; + m_FieldPosition[ii].y -= m_Cmp->m_Pos.y; + } } /****************************************************************/ -void WinEDA_ComponentPropertiesFrame::CopyDataToPanelField(void) +void WinEDA_ComponentPropertiesFrame::CopyDataToPanelField( void ) /****************************************************************/ + /* Set the values displayed on the panel field according to - the current field number -*/ + * the current field number + */ { -int fieldId = m_CurrentFieldId; + int fieldId = m_CurrentFieldId; - for ( int ii = FIELD1; ii < NUMBER_OF_FIELDS; ii++ ) - m_FieldSelection->SetString(ii, m_FieldName[ii]); + for( int ii = FIELD1; ii < NUMBER_OF_FIELDS; ii++ ) + m_FieldSelection->SetString( ii, m_FieldName[ii] ); - if ( fieldId == VALUE && m_LibEntry && m_LibEntry->m_Options == ENTRY_POWER ) - m_FieldTextCtrl->Enable(FALSE); + if( fieldId == VALUE && m_LibEntry && m_LibEntry->m_Options == ENTRY_POWER ) + m_FieldTextCtrl->Enable( FALSE ); - if ( m_FieldFlags[fieldId] ) - m_ShowFieldTextCtrl->SetValue(TRUE); - else m_ShowFieldTextCtrl->SetValue(FALSE); + if( m_FieldFlags[fieldId] ) + m_ShowFieldTextCtrl->SetValue( TRUE ); + else + m_ShowFieldTextCtrl->SetValue( FALSE ); - // If the field value is empty and the position is zero, we set the - // initial position as a small offset from the ref field, and orient - // it the same as the ref field. That is likely to put it at least - // close to the desired position. - if ( (m_FieldPosition[fieldId] == wxPoint(0,0)) && - m_FieldText[fieldId].IsEmpty()) { - m_VorientFieldText->SetValue(m_FieldOrient[REFERENCE] != 0); - m_FieldPositionCtrl->SetValue(m_FieldPosition[REFERENCE].x + 100, - m_FieldPosition[REFERENCE].y + 100 ); - } - else { - m_FieldPositionCtrl->SetValue(m_FieldPosition[fieldId].x, m_FieldPosition[fieldId].y ); - m_VorientFieldText->SetValue(m_FieldOrient[fieldId] != 0); - } + // If the field value is empty and the position is zero, we set the + // initial position as a small offset from the ref field, and orient + // it the same as the ref field. That is likely to put it at least + // close to the desired position. + if( ( m_FieldPosition[fieldId] == wxPoint( 0, 0 ) ) + && m_FieldText[fieldId].IsEmpty() ) + { + m_VorientFieldText->SetValue( m_FieldOrient[REFERENCE] != 0 ); + m_FieldPositionCtrl->SetValue( m_FieldPosition[REFERENCE].x + 100, + m_FieldPosition[REFERENCE].y + 100 ); + } + else + { + m_FieldPositionCtrl->SetValue( m_FieldPosition[fieldId].x, m_FieldPosition[fieldId].y ); + m_VorientFieldText->SetValue( m_FieldOrient[fieldId] != 0 ); + } - m_FieldNameCtrl->SetValue(m_FieldName[fieldId]); - if ( fieldId < FIELD1 ) m_FieldNameCtrl->Enable(FALSE ); - else m_FieldNameCtrl->Enable( TRUE ); - m_FieldTextCtrl->SetValue(m_FieldText[fieldId]); - m_FieldTextCtrl->SetValue(m_FieldSize[fieldId]); + m_FieldNameCtrl->SetValue( m_FieldName[fieldId] ); + if( fieldId < FIELD1 ) + m_FieldNameCtrl->Enable( FALSE ); + else + m_FieldNameCtrl->Enable( TRUE ); + m_FieldTextCtrl->SetValue( m_FieldText[fieldId] ); + m_FieldTextCtrl->SetValue( m_FieldSize[fieldId] ); } -/****************************************************************/ -void WinEDA_ComponentPropertiesFrame::CopyPanelFieldToData(void) -/****************************************************************/ -/* Copy the values displayed on the panel field to the buffers according to - the current field number -*/ -{ -int id = m_CurrentFieldId; - m_FieldFlags[id] = m_ShowFieldTextCtrl->GetValue(); - m_FieldOrient[id] = m_VorientFieldText->GetValue(); - m_FieldText[id] = m_FieldTextCtrl->GetText(); - m_FieldName[id] = m_FieldNameCtrl->GetValue(); - m_FieldPosition[id] = m_FieldPositionCtrl->GetValue(); - m_FieldSize[id] = m_FieldTextCtrl->GetTextSize(); +/****************************************************************/ +void WinEDA_ComponentPropertiesFrame::CopyPanelFieldToData( void ) +/****************************************************************/ + +/* Copy the values displayed on the panel field to the buffers according to + * the current field number + */ +{ + int id = m_CurrentFieldId; + + m_FieldFlags[id] = m_ShowFieldTextCtrl->GetValue(); + m_FieldOrient[id] = m_VorientFieldText->GetValue(); + m_FieldText[id] = m_FieldTextCtrl->GetText(); + m_FieldName[id] = m_FieldNameCtrl->GetValue(); + m_FieldPosition[id] = m_FieldPositionCtrl->GetValue(); + m_FieldSize[id] = m_FieldTextCtrl->GetTextSize(); } @@ -160,621 +175,676 @@ int id = m_CurrentFieldId; void WinEDA_ComponentPropertiesFrame::BuildPanelFields( void ) /*************************************************************/ { -int ii, FieldId; -wxPoint field_pos; + int ii, FieldId; + wxPoint field_pos; - m_CurrentFieldId = FieldId = REFERENCE; + m_CurrentFieldId = FieldId = REFERENCE; - // Create the box field selection: -wxString fieldnamelist[NUMBER_OF_FIELDS]; - for ( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) - { - if ( m_FieldName[ii].IsEmpty() ) - fieldnamelist[ii] = ReturnDefaultFieldName(ii); - else fieldnamelist[ii] = m_FieldName[ii]; - } - m_FieldSelection = new wxRadioBox(m_PanelField, ID_ON_SELECT_FIELD, - _("Field to edit"), wxDefaultPosition, wxDefaultSize, - NUMBER_OF_FIELDS, fieldnamelist, 2 , wxRA_SPECIFY_COLS); - m_FieldSelectionBoxSizer->Add(m_FieldSelection, 0 , wxGROW|wxALL, 5); + // Create the box field selection: + wxString fieldnamelist[NUMBER_OF_FIELDS]; + for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) + { + if( m_FieldName[ii].IsEmpty() ) + fieldnamelist[ii] = ReturnDefaultFieldName( ii ); + else + fieldnamelist[ii] = m_FieldName[ii]; + } - // Create the box for field name display - m_FieldNameCtrl = new WinEDA_EnterText( m_PanelField, - _("Field Name:"), m_FieldName[FieldId], - m_FieldDatasBoxSizer, wxSize( 200, -1) ); - if ( FieldId < FIELD1 ) m_FieldNameCtrl->Enable(FALSE ); - else m_FieldNameCtrl->Enable( TRUE ); + m_FieldSelection = new wxRadioBox( m_PanelField, ID_ON_SELECT_FIELD, + _( "Field to edit" ), wxDefaultPosition, wxDefaultSize, + NUMBER_OF_FIELDS, fieldnamelist, 2, wxRA_SPECIFY_COLS ); + m_FieldSelectionBoxSizer->Add( m_FieldSelection, 0, wxGROW | wxALL, 5 ); - // Create the box for text editing (text, size) - m_FieldTextCtrl = new WinEDA_GraphicTextCtrl( m_PanelField, - _("Value:"), - m_FieldText[FieldId], - m_FieldSize[FieldId], - g_UnitMetric , - m_FieldDatasBoxSizer, 200, m_Parent->m_InternalUnits); + // Create the box for field name display + m_FieldNameCtrl = new WinEDA_EnterText( m_PanelField, + _( "Field Name:" ), m_FieldName[FieldId], + m_FieldDatasBoxSizer, wxSize( 200, -1 ) ); + if( FieldId < FIELD1 ) + m_FieldNameCtrl->Enable( FALSE ); + else + m_FieldNameCtrl->Enable( TRUE ); - // Create the box for text editing (position) - m_FieldPositionCtrl = new WinEDA_PositionCtrl( m_PanelField, _("Pos"), - m_FieldPosition[FieldId], - g_UnitMetric , - m_FieldDatasBoxSizer, - m_Parent->m_InternalUnits ); + // Create the box for text editing (text, size) + m_FieldTextCtrl = new WinEDA_GraphicTextCtrl( m_PanelField, + _( + "Value:" ), + m_FieldText[FieldId], + m_FieldSize[FieldId], + g_UnitMetric, + m_FieldDatasBoxSizer, 200, + m_Parent->m_InternalUnits ); - CopyDataToPanelField(); + // Create the box for text editing (position) + m_FieldPositionCtrl = new WinEDA_PositionCtrl( m_PanelField, _( "Pos" ), + m_FieldPosition[FieldId], + g_UnitMetric, + m_FieldDatasBoxSizer, + m_Parent->m_InternalUnits ); + + CopyDataToPanelField(); } + /**********************************************************/ -void WinEDA_ComponentPropertiesFrame::BuildPanelBasic(void) +void WinEDA_ComponentPropertiesFrame::BuildPanelBasic( void ) /**********************************************************/ + /* create the basic panel for component properties editing -*/ + */ { -int Nb_Max_Unit = m_SelectUnit->GetCount(); -int ii; + int Nb_Max_Unit = m_SelectUnit->GetCount(); + int ii; -int nb_units = m_LibEntry ? MAX(m_LibEntry->m_UnitCount, 1) : 0; + int nb_units = m_LibEntry ? MAX( m_LibEntry->m_UnitCount, 1 ) : 0; - // Disable non existant units selection buttons - for ( ii = nb_units; ii < Nb_Max_Unit; ii++ ) - { - m_SelectUnit->Enable(ii, FALSE); - } - if ( m_Cmp->m_Multi <= Nb_Max_Unit ) - m_SelectUnit->SetSelection(m_Cmp->m_Multi -1); + // Disable non existant units selection buttons + for( ii = nb_units; ii < Nb_Max_Unit; ii++ ) + { + m_SelectUnit->Enable( ii, FALSE ); + } - ii = m_Cmp->GetRotationMiroir() & ~(CMP_MIROIR_X|CMP_MIROIR_Y); + if( m_Cmp->m_Multi <= Nb_Max_Unit ) + m_SelectUnit->SetSelection( m_Cmp->m_Multi - 1 ); - if ( ii == CMP_ORIENT_90) m_OrientUnit->SetSelection(1); - else if ( ii == CMP_ORIENT_180) m_OrientUnit->SetSelection(2); - else if ( ii == CMP_ORIENT_270) m_OrientUnit->SetSelection(3); + ii = m_Cmp->GetRotationMiroir() & ~(CMP_MIROIR_X | CMP_MIROIR_Y); - ii = m_Cmp->GetRotationMiroir() & (CMP_MIROIR_X|CMP_MIROIR_Y) ; - if ( ii == CMP_MIROIR_X ) m_MirrorUnit->SetSelection(1); - else if ( ii == CMP_MIROIR_Y ) m_MirrorUnit->SetSelection(2); + if( ii == CMP_ORIENT_90 ) + m_OrientUnit->SetSelection( 1 ); + else if( ii == CMP_ORIENT_180 ) + m_OrientUnit->SetSelection( 2 ); + else if( ii == CMP_ORIENT_270 ) + m_OrientUnit->SetSelection( 3 ); - // Positionnement de la selection normal/convert - if ( m_Cmp->m_Convert > 1 ) m_ConvertButt->SetValue(TRUE); + ii = m_Cmp->GetRotationMiroir() & (CMP_MIROIR_X | CMP_MIROIR_Y); + if( ii == CMP_MIROIR_X ) + m_MirrorUnit->SetSelection( 1 ); + else if( ii == CMP_MIROIR_Y ) + m_MirrorUnit->SetSelection( 2 ); - if ( (m_LibEntry == NULL) || LookForConvertPart(m_LibEntry) <= 1) - { - m_ConvertButt->Enable(FALSE); - } + // Positionnement de la selection normal/convert + if( m_Cmp->m_Convert > 1 ) + m_ConvertButt->SetValue( TRUE ); - // Show the "Parts Locked" option: - if ( ! m_LibEntry || ! m_LibEntry->m_UnitSelectionLocked ) - { - m_MsgPartLocked->Show(false); - } + if( (m_LibEntry == NULL) || LookForConvertPart( m_LibEntry ) <= 1 ) + { + m_ConvertButt->Enable( FALSE ); + } - // Positionnement de la reference en librairie - m_RefInLib->SetValue(m_Cmp->m_ChipName); + // Show the "Parts Locked" option: + if( !m_LibEntry || !m_LibEntry->m_UnitSelectionLocked ) + { + m_MsgPartLocked->Show( false ); + } + // Positionnement de la reference en librairie + m_RefInLib->SetValue( m_Cmp->m_ChipName ); } + /*************************************************************************/ -void WinEDA_ComponentPropertiesFrame::SelectNewField(wxCommandEvent& event) +void WinEDA_ComponentPropertiesFrame::SelectNewField( wxCommandEvent& event ) /*************************************************************************/ + /* called when changing the current field selected - Save the current field settings in buffer and display the new one -*/ + * Save the current field settings in buffer and display the new one + */ { - CopyPanelFieldToData(); - m_CurrentFieldId = m_FieldSelection->GetSelection(); - CopyDataToPanelField(); + CopyPanelFieldToData(); + m_CurrentFieldId = m_FieldSelection->GetSelection(); + CopyDataToPanelField(); } + /***********************************************************************************/ -void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept(wxCommandEvent& event) +void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept( wxCommandEvent& event ) /***********************************************************************************/ + /* Update the new parameters for the current edited component -*/ + */ { -wxPoint cmp_pos = m_Cmp->m_Pos; -wxClientDC dc(m_Parent->DrawPanel); -wxString newname; + wxPoint cmp_pos = m_Cmp->m_Pos; + wxClientDC dc( m_Parent->DrawPanel ); + wxString newname; - /* save old cmp in undo list if not already in edit, or moving ... */ - if ( m_Cmp->m_Flags == 0 ) - m_Parent->SaveCopyInUndoList(m_Cmp, IS_CHANGED); + /* save old cmp in undo list if not already in edit, or moving ... */ + if( m_Cmp->m_Flags == 0 ) + m_Parent->SaveCopyInUndoList( m_Cmp, IS_CHANGED ); - CopyPanelFieldToData(); + CopyPanelFieldToData(); - m_Parent->DrawPanel->PrepareGraphicContext(&dc); - - - RedrawOneStruct(m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode); - - newname = m_RefInLib->GetValue(); - newname.MakeUpper(); - newname.Replace(wxT(" "), wxT("_")); - - if ( newname.IsEmpty() ) DisplayError(this, _("No Component Name!")); - else if ( newname.CmpNoCase(m_Cmp->m_ChipName) ) - { - if ( FindLibPart(newname.GetData(), wxEmptyString, FIND_ALIAS) == NULL ) - { - wxString msg; - msg.Printf( _("Component [%s] not found!"), newname.GetData() ); - DisplayError(this, msg); - } - else // Changement de composant! - { - m_Cmp->m_ChipName = newname; - } - } - - // Mise a jour de la representation: - if ( m_ConvertButt->IsEnabled() ) - (m_ConvertButt->GetValue() == TRUE) ? - m_Cmp->m_Convert = 2 : m_Cmp->m_Convert = 1; - - //Mise a jour de la selection de l'�l�ment dans le boitier - if ( m_Cmp->m_Multi ) m_Cmp->m_Multi = m_SelectUnit->GetSelection() + 1; - - //Mise a jour de l'orientation: - switch (m_OrientUnit->GetSelection() ) - { - case 0: - m_Cmp->SetRotationMiroir(CMP_ORIENT_0); - break; - case 1: - m_Cmp->SetRotationMiroir(CMP_ORIENT_90); - break; - case 2: - m_Cmp->SetRotationMiroir(CMP_ORIENT_180); - break; - case 3: - m_Cmp->SetRotationMiroir(CMP_ORIENT_270); - break; - } - - switch (m_MirrorUnit->GetSelection() ) - { - case 0: - break; - case 1: - m_Cmp->SetRotationMiroir(CMP_MIROIR_X); - break; - case 2: - m_Cmp->SetRotationMiroir(CMP_MIROIR_Y); - break; - } + m_Parent->DrawPanel->PrepareGraphicContext( &dc ); - // Mise a jour des textes - for ( int ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ ) - { - if( ii == REFERENCE ) // la reference ne peut etre vide - { - if ( ! m_FieldText[ii].IsEmpty() ) - m_Cmp->m_Field[ii].m_Text = m_FieldText[ii]; - } - else if( ii == VALUE ) // la valeur ne peut etre vide et ne peut etre change sur un POWER - { - EDA_LibComponentStruct *Entry = FindLibPart(m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); - if( Entry && (Entry->m_Options == ENTRY_POWER) ) - m_Cmp->m_Field[ii].m_Text = m_Cmp->m_ChipName; - else if ( ! m_FieldText[ii].IsEmpty() ) - { - m_Cmp->m_Field[ii].m_Text = m_FieldText[ii]; - } - } - else - m_Cmp->m_Field[ii].m_Text = m_FieldText[ii]; + RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode ); - if ( ii >= FIELD1 && m_FieldName[ii] != ReturnDefaultFieldName(ii) ) - m_Cmp->m_Field[ii].m_Name = m_FieldName[ii]; - else m_Cmp->m_Field[ii].m_Name.Empty(); + newname = m_RefInLib->GetValue(); + newname.MakeUpper(); + newname.Replace( wxT( " " ), wxT( "_" ) ); - m_Cmp->m_Field[ii].m_Size.x = - m_Cmp->m_Field[ii].m_Size.y = m_FieldSize[ii]; - if ( m_FieldFlags[ii] ) - m_Cmp->m_Field[ii].m_Attributs &= ~TEXT_NO_VISIBLE; - else - m_Cmp->m_Field[ii].m_Attributs |= TEXT_NO_VISIBLE; - m_Cmp->m_Field[ii].m_Orient = m_FieldOrient[ii] ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; - m_Cmp->m_Field[ii].m_Pos = m_FieldPosition[ii]; - m_Cmp->m_Field[ii].m_Pos.x += cmp_pos.x; - m_Cmp->m_Field[ii].m_Pos.y += cmp_pos.y; - } - m_Parent->m_CurrentScreen->SetModify(); + if( newname.IsEmpty() ) + DisplayError( this, _( "No Component Name!" ) ); + else if( newname.CmpNoCase( m_Cmp->m_ChipName ) ) + { + if( FindLibPart( newname.GetData(), wxEmptyString, FIND_ALIAS ) == NULL ) + { + wxString msg; + msg.Printf( _( "Component [%s] not found!" ), newname.GetData() ); + DisplayError( this, msg ); + } + else // Changement de composant! + { + m_Cmp->m_ChipName = newname; + } + } - RedrawOneStruct(m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE); - m_Parent->TestDanglingEnds(m_Parent->m_CurrentScreen->EEDrawList, &dc); + // Mise a jour de la representation: + if( m_ConvertButt->IsEnabled() ) + (m_ConvertButt->GetValue() == TRUE) ? + m_Cmp->m_Convert = 2 : m_Cmp->m_Convert = 1; - Close(); + //Mise a jour de la selection de l'�l�ment dans le boitier + if( m_Cmp->m_Multi ) + m_Cmp->m_Multi = m_SelectUnit->GetSelection() + 1; + + //Mise a jour de l'orientation: + switch( m_OrientUnit->GetSelection() ) + { + case 0: + m_Cmp->SetRotationMiroir( CMP_ORIENT_0 ); + break; + + case 1: + m_Cmp->SetRotationMiroir( CMP_ORIENT_90 ); + break; + + case 2: + m_Cmp->SetRotationMiroir( CMP_ORIENT_180 ); + break; + + case 3: + m_Cmp->SetRotationMiroir( CMP_ORIENT_270 ); + break; + } + + switch( m_MirrorUnit->GetSelection() ) + { + case 0: + break; + + case 1: + m_Cmp->SetRotationMiroir( CMP_MIROIR_X ); + break; + + case 2: + m_Cmp->SetRotationMiroir( CMP_MIROIR_Y ); + break; + } + + + // Mise a jour des textes + for( int ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ ) + { + if( ii == REFERENCE ) // la reference ne peut etre vide + { + if( !m_FieldText[ii].IsEmpty() ) + m_Cmp->m_Field[ii].m_Text = m_FieldText[ii]; + } + else if( ii == VALUE ) // la valeur ne peut etre vide et ne peut etre change sur un POWER + { + EDA_LibComponentStruct* Entry = FindLibPart( m_Cmp->m_ChipName.GetData( + ), wxEmptyString, FIND_ROOT ); + if( Entry && (Entry->m_Options == ENTRY_POWER) ) + m_Cmp->m_Field[ii].m_Text = m_Cmp->m_ChipName; + else if( !m_FieldText[ii].IsEmpty() ) + { + m_Cmp->m_Field[ii].m_Text = m_FieldText[ii]; + } + } + else + m_Cmp->m_Field[ii].m_Text = m_FieldText[ii]; + + if( ii >= FIELD1 && m_FieldName[ii] != ReturnDefaultFieldName( ii ) ) + m_Cmp->m_Field[ii].m_Name = m_FieldName[ii]; + else + m_Cmp->m_Field[ii].m_Name.Empty(); + + m_Cmp->m_Field[ii].m_Size.x = + m_Cmp->m_Field[ii].m_Size.y = m_FieldSize[ii]; + if( m_FieldFlags[ii] ) + m_Cmp->m_Field[ii].m_Attributs &= ~TEXT_NO_VISIBLE; + else + m_Cmp->m_Field[ii].m_Attributs |= TEXT_NO_VISIBLE; + m_Cmp->m_Field[ii].m_Orient = m_FieldOrient[ii] ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; + m_Cmp->m_Field[ii].m_Pos = m_FieldPosition[ii]; + m_Cmp->m_Field[ii].m_Pos.x += cmp_pos.x; + m_Cmp->m_Field[ii].m_Pos.y += cmp_pos.y; + } + + m_Parent->m_CurrentScreen->SetModify(); + + RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE ); + m_Parent->TestDanglingEnds( m_Parent->m_CurrentScreen->EEDrawList, &dc ); + + Close(); } +/************************************************************************************/ +void WinEDA_SchematicFrame::StartMoveCmpField( PartTextStruct* Field, wxDC* DC ) +/************************************************************************************/ -/************************************************************************************/ -void WinEDA_SchematicFrame::StartMoveCmpField(PartTextStruct * Field, wxDC * DC) -/************************************************************************************/ /* Prepare le deplacement du texte en cours d'edition -*/ + */ { -EDA_LibComponentStruct *Entry; - + EDA_LibComponentStruct* Entry; - CurrentField = Field; - if ( Field == NULL ) return; - if(Field->m_Text == wxEmptyString) - { - DisplayError(this, _("No Field to move"), 10); - return; - } + CurrentField = Field; + if( Field == NULL ) + return; -wxPoint pos, newpos; -int x1, y1; -EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) CurrentField->m_Parent; + if( Field->m_Text == wxEmptyString ) + { + DisplayError( this, _( "No Field to move" ), 10 ); + return; + } - delete g_ItemToUndoCopy; - g_ItemToUndoCopy = Cmp->GenCopy(); + wxPoint pos, newpos; + int x1, y1; + EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) CurrentField->m_Parent; - pos = Cmp->m_Pos; + delete g_ItemToUndoCopy; + g_ItemToUndoCopy = Cmp->GenCopy(); - /* Les positions sont calculees par la matrice TRANSPOSEE de la matrice - de rotation-miroir */ - x1 = Field->m_Pos.x - pos.x; - y1 = Field->m_Pos.y - pos.y; - // Empirically this is necessary. The Y coordinate appears to be inverted - // under some circumstances, but that inversion is not preserved by all - // combinations of mirroring and rotation. The following clause is true - // when the number of rotations and the number of mirrorings are both odd. - if (Cmp->m_Transform[1][0] * Cmp->m_Transform[0][1] < 0) { - y1 = -y1; - } - newpos.x = pos.x + Cmp->m_Transform[0][0] * x1 + Cmp->m_Transform[1][0] * y1; - newpos.y = pos.y + Cmp->m_Transform[0][1] * x1 + Cmp->m_Transform[1][1] * y1; + pos = Cmp->m_Pos; - DrawPanel->CursorOff(DC); - m_CurrentScreen->m_Curseur = newpos; - DrawPanel->MouseToCursorSchema(); + /* Les positions sont calculees par la matrice TRANSPOSEE de la matrice + * de rotation-miroir */ + x1 = Field->m_Pos.x - pos.x; + y1 = Field->m_Pos.y - pos.y; - OldPos = Field->m_Pos; - Multiflag = 0; - if( Field->m_FieldId == REFERENCE ) - { - Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); - if( Entry != NULL ) - { - if ( Entry->m_UnitCount > 1 ) Multiflag = 1; - } - } + // Empirically this is necessary. The Y coordinate appears to be inverted + // under some circumstances, but that inversion is not preserved by all + // combinations of mirroring and rotation. The following clause is true + // when the number of rotations and the number of mirrorings are both odd. + if( Cmp->m_Transform[1][0] * Cmp->m_Transform[0][1] < 0 ) + { + y1 = -y1; + } + newpos.x = pos.x + Cmp->m_Transform[0][0] * x1 + Cmp->m_Transform[1][0] * y1; + newpos.y = pos.y + Cmp->m_Transform[0][1] * x1 + Cmp->m_Transform[1][1] * y1; - DrawPanel->ForceCloseManageCurseur = AbortMoveCmpField; - DrawPanel->ManageCurseur = MoveCmpField; - Field->m_Flags = IS_MOVED; + DrawPanel->CursorOff( DC ); + m_CurrentScreen->m_Curseur = newpos; + DrawPanel->MouseToCursorSchema(); - DrawPanel->CursorOn(DC); + OldPos = Field->m_Pos; + Multiflag = 0; + if( Field->m_FieldId == REFERENCE ) + { + Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); + if( Entry != NULL ) + { + if( Entry->m_UnitCount > 1 ) + Multiflag = 1; + } + } + + DrawPanel->ForceCloseManageCurseur = AbortMoveCmpField; + DrawPanel->ManageCurseur = MoveCmpField; + Field->m_Flags = IS_MOVED; + + DrawPanel->CursorOn( DC ); } /**********************************************************************************/ -void WinEDA_SchematicFrame::EditCmpFieldText(PartTextStruct * Field, wxDC *DC) +void WinEDA_SchematicFrame::EditCmpFieldText( PartTextStruct* Field, wxDC* DC ) /**********************************************************************************/ /* Edit the field Field (text, size) */ { -int FieldNumber, flag; -EDA_LibComponentStruct *Entry; + int FieldNumber, flag; + EDA_LibComponentStruct* Entry; - if( Field == NULL ) - { - DisplayError(this, _("No Field To Edit"), 10); - return; - } + if( Field == NULL ) + { + DisplayError( this, _( "No Field To Edit" ), 10 ); + return; + } -EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) Field->m_Parent; + EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) Field->m_Parent; - FieldNumber = Field->m_FieldId; - if( FieldNumber == VALUE ) - { - Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); - if( Entry && (Entry->m_Options == ENTRY_POWER) ) - { - DisplayInfo(this, - _("Part is a POWER, value cannot be modified!\nYou must create a new power") ); - return; - } - } + FieldNumber = Field->m_FieldId; + if( FieldNumber == VALUE ) + { + Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); + if( Entry && (Entry->m_Options == ENTRY_POWER) ) + { + DisplayInfo( this, + _( + "Part is a POWER, value cannot be modified!\nYou must create a new power" ) + ); + return; + } + } - flag = 0; - if( FieldNumber == REFERENCE ) - { - Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); - if( Entry != NULL ) - { - if ( Entry->m_UnitCount > 1 ) flag = 1; - } - } + flag = 0; + if( FieldNumber == REFERENCE ) + { + Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); + if( Entry != NULL ) + { + if( Entry->m_UnitCount > 1 ) + flag = 1; + } + } - /* save old cmp in undo list if not already in edit, or moving ... */ - if ( Field->m_Flags == 0 ) SaveCopyInUndoList(Cmp, IS_CHANGED); + /* save old cmp in undo list if not already in edit, or moving ... */ + if( Field->m_Flags == 0 ) + SaveCopyInUndoList( Cmp, IS_CHANGED ); - wxString newtext = Field->m_Text; - DrawPanel->m_IgnoreMouseEvents = TRUE; - Get_Message(Field->m_Name, newtext, this); - DrawPanel->MouseToCursorSchema(); - DrawPanel->m_IgnoreMouseEvents = FALSE; + wxString newtext = Field->m_Text; + DrawPanel->m_IgnoreMouseEvents = TRUE; + Get_Message( Field->m_Name, newtext, this ); + DrawPanel->MouseToCursorSchema(); + DrawPanel->m_IgnoreMouseEvents = FALSE; - DrawTextField(DrawPanel, DC, Field, flag, g_XorMode); + DrawTextField( DrawPanel, DC, Field, flag, g_XorMode ); - if ( ! newtext.IsEmpty() ) - { - if (Field->m_Text.IsEmpty()) - { - Field->m_Pos = Cmp->m_Pos; - Field->m_Size.x = Field->m_Size.y = TextFieldSize; - } - Field->m_Text = newtext; - } + if( !newtext.IsEmpty() ) + { + if( Field->m_Text.IsEmpty() ) + { + Field->m_Pos = Cmp->m_Pos; + Field->m_Size.x = Field->m_Size.y = TextFieldSize; + } + Field->m_Text = newtext; + } + else /* Nouveau texte NULL */ + { + if( FieldNumber == REFERENCE ) + { + DisplayError( this, _( "Reference needed !, No change" ) ); + } + else if( FieldNumber == VALUE ) + { + DisplayError( this, _( "Value needed !, No change" ) ); + } + else + { + Field->m_Text = wxT( "~" ); + } + } - else /* Nouveau texte NULL */ - { - if( FieldNumber == REFERENCE ) - { - DisplayError(this, _("Reference needed !, No change")); - } - else if( FieldNumber == VALUE ) - { - DisplayError(this, _("Value needed !, No change")); - } - else - { - Field->m_Text = wxT("~"); - } - } - - DrawTextField(DrawPanel, DC, Field, flag, g_XorMode); - Cmp->Display_Infos(this); - m_CurrentScreen->SetModify(); + DrawTextField( DrawPanel, DC, Field, flag, g_XorMode ); + Cmp->Display_Infos( this ); + m_CurrentScreen->SetModify(); } /************************************************************************/ -static void MoveCmpField(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /************************************************************************/ + /* Routine de deplacement d'un texte type Field. - Celle routine est normalement attachee au deplacement du curseur -*/ + * Celle routine est normalement attachee au deplacement du curseur + */ { -wxPoint pos; -int x1, y1; -int FieldNumber; + wxPoint pos; + int x1, y1; + int FieldNumber; - if( CurrentField == NULL) return; + if( CurrentField == NULL ) + return; -EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*)CurrentField->m_Parent; - FieldNumber = CurrentField->m_FieldId; + EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) CurrentField->m_Parent; + FieldNumber = CurrentField->m_FieldId; - /* Effacement: */ - if( erase ) - DrawTextField(panel, DC, CurrentField, Multiflag, g_XorMode); + /* Effacement: */ + if( erase ) + DrawTextField( panel, DC, CurrentField, Multiflag, g_XorMode ); - pos = ((EDA_SchComponentStruct*)CurrentField->m_Parent)->m_Pos; + pos = ( (EDA_SchComponentStruct*) CurrentField->m_Parent )->m_Pos; - /* Les positions sont caculees par la matrice TRANSPOSEE de la matrice - de rotation-miroir */ - x1 = panel->GetScreen()->m_Curseur.x - pos.x; - y1 = panel->GetScreen()->m_Curseur.y - pos.y; - CurrentField->m_Pos.x = pos.x + Cmp->m_Transform[0][0] * x1 + Cmp->m_Transform[1][0] * y1; - CurrentField->m_Pos.y = pos.y + Cmp->m_Transform[0][1] * x1 + Cmp->m_Transform[1][1] * y1; + /* Les positions sont caculees par la matrice TRANSPOSEE de la matrice + * de rotation-miroir */ + x1 = panel->GetScreen()->m_Curseur.x - pos.x; + y1 = panel->GetScreen()->m_Curseur.y - pos.y; + CurrentField->m_Pos.x = pos.x + Cmp->m_Transform[0][0] * x1 + Cmp->m_Transform[1][0] * y1; + CurrentField->m_Pos.y = pos.y + Cmp->m_Transform[0][1] * x1 + Cmp->m_Transform[1][1] * y1; - DrawTextField(panel, DC, CurrentField, Multiflag, g_XorMode); + DrawTextField( panel, DC, CurrentField, Multiflag, g_XorMode ); } /******************************************************************/ -static void AbortMoveCmpField(WinEDA_DrawPanel * Panel, wxDC * DC) +static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC ) /******************************************************************/ { - Panel->ForceCloseManageCurseur = NULL; - Panel->ManageCurseur = NULL; - if ( CurrentField ) - { - DrawTextField(Panel, DC, CurrentField,Multiflag, g_XorMode); - CurrentField->m_Flags = 0; - CurrentField->m_Pos = OldPos; - DrawTextField(Panel, DC, CurrentField,Multiflag, GR_DEFAULT_DRAWMODE); - } - CurrentField = NULL; - delete g_ItemToUndoCopy; g_ItemToUndoCopy = NULL; + Panel->ForceCloseManageCurseur = NULL; + Panel->ManageCurseur = NULL; + if( CurrentField ) + { + DrawTextField( Panel, DC, CurrentField, Multiflag, g_XorMode ); + CurrentField->m_Flags = 0; + CurrentField->m_Pos = OldPos; + DrawTextField( Panel, DC, CurrentField, Multiflag, GR_DEFAULT_DRAWMODE ); + } + CurrentField = NULL; + delete g_ItemToUndoCopy; g_ItemToUndoCopy = NULL; } + /*********************************************************************************/ -void WinEDA_SchematicFrame::RotateCmpField(PartTextStruct * Field, wxDC * DC) +void WinEDA_SchematicFrame::RotateCmpField( PartTextStruct* Field, wxDC* DC ) /*********************************************************************************/ { -int FieldNumber, flag; -EDA_LibComponentStruct *Entry; + int FieldNumber, flag; + EDA_LibComponentStruct* Entry; - if (Field == NULL ) return; - if (Field->m_Text == wxEmptyString ) return; + if( Field == NULL ) + return; + if( Field->m_Text == wxEmptyString ) + return; -EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*)Field->m_Parent; + EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) Field->m_Parent; - FieldNumber = Field->m_FieldId; - flag = 0; - if( FieldNumber == REFERENCE ) - { - Entry = FindLibPart( ((EDA_SchComponentStruct*)Field->m_Parent)->m_ChipName.GetData(), - wxEmptyString, FIND_ROOT); - if( Entry != NULL ) - { - if ( Entry->m_UnitCount > 1 ) flag = 1; - } - } + FieldNumber = Field->m_FieldId; + flag = 0; + if( FieldNumber == REFERENCE ) + { + Entry = FindLibPart( ( (EDA_SchComponentStruct*) Field->m_Parent )->m_ChipName.GetData(), + wxEmptyString, FIND_ROOT ); + if( Entry != NULL ) + { + if( Entry->m_UnitCount > 1 ) + flag = 1; + } + } - /* save old cmp in undo list if not already in edit, or moving ... */ - if ( Field->m_Flags == 0 ) SaveCopyInUndoList(Cmp, IS_CHANGED); + /* save old cmp in undo list if not already in edit, or moving ... */ + if( Field->m_Flags == 0 ) + SaveCopyInUndoList( Cmp, IS_CHANGED ); - DrawTextField(DrawPanel, DC, Field, flag, g_XorMode); + DrawTextField( DrawPanel, DC, Field, flag, g_XorMode ); - if( Field->m_Orient == TEXT_ORIENT_HORIZ ) Field->m_Orient = TEXT_ORIENT_VERT; - else Field->m_Orient = TEXT_ORIENT_HORIZ; - DrawTextField(DrawPanel, DC, Field,flag, g_XorMode); + if( Field->m_Orient == TEXT_ORIENT_HORIZ ) + Field->m_Orient = TEXT_ORIENT_VERT; + else + Field->m_Orient = TEXT_ORIENT_HORIZ; + DrawTextField( DrawPanel, DC, Field, flag, g_XorMode ); - GetScreen()->SetModify(); + GetScreen()->SetModify(); } /*********************************************************************/ -void PartTextStruct::Place( WinEDA_DrawFrame * frame, wxDC * DC) +void PartTextStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) /*********************************************************************/ { -int FieldNumber, flag; -EDA_LibComponentStruct *Entry; + int FieldNumber, flag; + EDA_LibComponentStruct* Entry; - frame->DrawPanel->ManageCurseur = NULL; - frame->DrawPanel->ForceCloseManageCurseur = NULL; + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; -EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) m_Parent; - /* save old cmp in undo list */ - if ( g_ItemToUndoCopy && ( g_ItemToUndoCopy->m_StructType == Cmp->m_StructType) ) - { - Cmp->SwapData( (EDA_SchComponentStruct*) g_ItemToUndoCopy); - ((WinEDA_SchematicFrame *) frame)->SaveCopyInUndoList(Cmp, IS_CHANGED); - Cmp->SwapData( (EDA_SchComponentStruct*) g_ItemToUndoCopy); - } + EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) m_Parent; + /* save old cmp in undo list */ + if( g_ItemToUndoCopy && ( g_ItemToUndoCopy->m_StructType == Cmp->m_StructType) ) + { + Cmp->SwapData( (EDA_SchComponentStruct*) g_ItemToUndoCopy ); + ( (WinEDA_SchematicFrame*) frame )->SaveCopyInUndoList( Cmp, IS_CHANGED ); + Cmp->SwapData( (EDA_SchComponentStruct*) g_ItemToUndoCopy ); + } - FieldNumber = m_FieldId; - flag = 0; - if( FieldNumber == REFERENCE ) - { - Entry = FindLibPart( Cmp->m_ChipName.GetData(), - wxEmptyString, FIND_ROOT); - if( Entry != NULL ) - { - if ( Entry->m_UnitCount > 1 ) flag = 1; - } - } + FieldNumber = m_FieldId; + flag = 0; + if( FieldNumber == REFERENCE ) + { + Entry = FindLibPart( Cmp->m_ChipName.GetData(), + wxEmptyString, FIND_ROOT ); + if( Entry != NULL ) + { + if( Entry->m_UnitCount > 1 ) + flag = 1; + } + } - DrawTextField(frame->DrawPanel, DC, this, flag, GR_DEFAULT_DRAWMODE); - m_Flags = 0; - frame->GetScreen()->m_CurrentItem = NULL; - frame->GetScreen()->SetModify(); - CurrentField = NULL; + DrawTextField( frame->DrawPanel, DC, this, flag, GR_DEFAULT_DRAWMODE ); + m_Flags = 0; + frame->GetScreen()->SetCurItem( NULL ); + frame->GetScreen()->SetModify(); + CurrentField = NULL; } - /**************************************************************************************************/ -void WinEDA_SchematicFrame::EditComponentReference(EDA_SchComponentStruct * Cmp, wxDC * DC) +void WinEDA_SchematicFrame::EditComponentReference( EDA_SchComponentStruct* Cmp, wxDC* DC ) /**************************************************************************************************/ /* Edit the component text reference*/ { -wxString msg; -EDA_LibComponentStruct *Entry; -int flag = 0; + wxString msg; + EDA_LibComponentStruct* Entry; + int flag = 0; - if( Cmp == NULL ) return; + if( Cmp == NULL ) + return; - Entry = FindLibPart(Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); - if ( Entry == NULL ) return; + Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); + if( Entry == NULL ) + return; - if ( Entry->m_UnitCount > 1 ) flag = 1; + if( Entry->m_UnitCount > 1 ) + flag = 1; - PartTextStruct * TextField = &Cmp->m_Field[REFERENCE]; + PartTextStruct* TextField = &Cmp->m_Field[REFERENCE]; - msg = TextField->m_Text; - Get_Message(_("Reference") , msg, this); + msg = TextField->m_Text; + Get_Message( _( "Reference" ), msg, this ); - if ( ! msg.IsEmpty() ) // New text entered - { - /* save old cmp in undo list if not already in edit, or moving ... */ - if ( Cmp->m_Flags == 0 ) SaveCopyInUndoList(Cmp, IS_CHANGED); + if( !msg.IsEmpty() ) // New text entered + { + /* save old cmp in undo list if not already in edit, or moving ... */ + if( Cmp->m_Flags == 0 ) + SaveCopyInUndoList( Cmp, IS_CHANGED ); - DrawTextField(DrawPanel, DC, &Cmp->m_Field[REFERENCE], flag, g_XorMode); - TextField->m_Text = msg; - DrawTextField(DrawPanel, DC, &Cmp->m_Field[REFERENCE], flag, - Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE); - GetScreen()->SetModify(); - } - Cmp->Display_Infos(this); + DrawTextField( DrawPanel, DC, &Cmp->m_Field[REFERENCE], flag, g_XorMode ); + TextField->m_Text = msg; + DrawTextField( DrawPanel, DC, &Cmp->m_Field[REFERENCE], flag, + Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE ); + GetScreen()->SetModify(); + } + Cmp->Display_Infos( this ); } + /*****************************************************************************************/ -void WinEDA_SchematicFrame::EditComponentValue(EDA_SchComponentStruct * Cmp, wxDC * DC) +void WinEDA_SchematicFrame::EditComponentValue( EDA_SchComponentStruct* Cmp, wxDC* DC ) /*****************************************************************************************/ /* Routine de changement du texte selectionne */ { -wxString msg; -EDA_LibComponentStruct *Entry; -int flag = 0; + wxString msg; + EDA_LibComponentStruct* Entry; + int flag = 0; - if( Cmp == NULL ) return; + if( Cmp == NULL ) + return; - Entry = FindLibPart(Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); - if ( Entry == NULL ) return; - if ( Entry->m_UnitCount > 1 ) flag = 1; + Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); + if( Entry == NULL ) + return; + if( Entry->m_UnitCount > 1 ) + flag = 1; - PartTextStruct * TextField = &Cmp->m_Field[VALUE]; + PartTextStruct* TextField = &Cmp->m_Field[VALUE]; - msg = TextField->m_Text; - Get_Message(_("Value") , msg, this); + msg = TextField->m_Text; + Get_Message( _( "Value" ), msg, this ); - if ( ! msg.IsEmpty() ) - { - /* save old cmp in undo list if not already in edit, or moving ... */ - if ( Cmp->m_Flags == 0 ) SaveCopyInUndoList(Cmp, IS_CHANGED); + if( !msg.IsEmpty() ) + { + /* save old cmp in undo list if not already in edit, or moving ... */ + if( Cmp->m_Flags == 0 ) + SaveCopyInUndoList( Cmp, IS_CHANGED ); - DrawTextField(DrawPanel, DC, &Cmp->m_Field[VALUE], flag, g_XorMode); - TextField->m_Text = msg; - DrawTextField(DrawPanel, DC, &Cmp->m_Field[VALUE], flag, - Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE); - m_CurrentScreen->SetModify(); - } + DrawTextField( DrawPanel, DC, &Cmp->m_Field[VALUE], flag, g_XorMode ); + TextField->m_Text = msg; + DrawTextField( DrawPanel, DC, &Cmp->m_Field[VALUE], flag, + Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE ); + m_CurrentScreen->SetModify(); + } - Cmp->Display_Infos(this); + Cmp->Display_Infos( this ); } + /*****************************************************************************/ void WinEDA_ComponentPropertiesFrame::SetInitCmp( wxCommandEvent& event ) /*****************************************************************************/ + /* Replace le composant en position normale, dimensions et positions - fields comme definies en librairie -*/ + * fields comme definies en librairie + */ { -EDA_LibComponentStruct *Entry; + EDA_LibComponentStruct* Entry; - if ( m_Cmp == NULL ) return; + if( m_Cmp == NULL ) + return; - Entry = FindLibPart(m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + Entry = FindLibPart( m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); - if( Entry == NULL) return; + if( Entry == NULL ) + return; -wxClientDC dc(m_Parent->DrawPanel); - m_Parent->DrawPanel->PrepareGraphicContext(&dc); + wxClientDC dc( m_Parent->DrawPanel ); + m_Parent->DrawPanel->PrepareGraphicContext( &dc ); - RedrawOneStruct(m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode); + RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode ); - /* Mise aux valeurs par defaut des champs et orientation */ - m_Cmp->m_Field[REFERENCE].m_Pos.x = - Entry->m_Prefix.m_Pos.x + m_Cmp->m_Pos.x; - m_Cmp->m_Field[REFERENCE].m_Pos.y = - Entry->m_Prefix.m_Pos.y + m_Cmp->m_Pos.y; - m_Cmp->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient; - m_Cmp->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size; - m_Cmp->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify; - m_Cmp->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify; + /* Mise aux valeurs par defaut des champs et orientation */ + m_Cmp->m_Field[REFERENCE].m_Pos.x = + Entry->m_Prefix.m_Pos.x + m_Cmp->m_Pos.x; + m_Cmp->m_Field[REFERENCE].m_Pos.y = + Entry->m_Prefix.m_Pos.y + m_Cmp->m_Pos.y; + m_Cmp->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient; + m_Cmp->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size; + m_Cmp->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify; + m_Cmp->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify; - m_Cmp->m_Field[VALUE].m_Pos.x = - Entry->m_Name.m_Pos.x + m_Cmp->m_Pos.x; - m_Cmp->m_Field[VALUE].m_Pos.y = - Entry->m_Name.m_Pos.y + m_Cmp->m_Pos.y; - m_Cmp->m_Field[VALUE].m_Orient = Entry->m_Name.m_Orient; - m_Cmp->m_Field[VALUE].m_Size = Entry->m_Name.m_Size; - m_Cmp->m_Field[VALUE].m_HJustify = Entry->m_Name.m_HJustify; - m_Cmp->m_Field[VALUE].m_VJustify = Entry->m_Name.m_VJustify; + m_Cmp->m_Field[VALUE].m_Pos.x = + Entry->m_Name.m_Pos.x + m_Cmp->m_Pos.x; + m_Cmp->m_Field[VALUE].m_Pos.y = + Entry->m_Name.m_Pos.y + m_Cmp->m_Pos.y; + m_Cmp->m_Field[VALUE].m_Orient = Entry->m_Name.m_Orient; + m_Cmp->m_Field[VALUE].m_Size = Entry->m_Name.m_Size; + m_Cmp->m_Field[VALUE].m_HJustify = Entry->m_Name.m_HJustify; + m_Cmp->m_Field[VALUE].m_VJustify = Entry->m_Name.m_VJustify; - m_Cmp->SetRotationMiroir(CMP_NORMAL); + m_Cmp->SetRotationMiroir( CMP_NORMAL ); - m_Parent->m_CurrentScreen->SetModify(); + m_Parent->m_CurrentScreen->SetModify(); - RedrawOneStruct(m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE); - Close(); + RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE ); + Close(); } - - diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 10180e0ef5..2b6b10cc64 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -14,339 +14,351 @@ #include "protos.h" /* Fonctions locales */ -static void ShowWhileMoving(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); -static void ExitMoveTexte(WinEDA_DrawPanel * panel, wxDC *DC); +static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); +static void ExitMoveTexte( WinEDA_DrawPanel* panel, wxDC* DC ); /* Variables locales */ static wxPoint ItemInitialPosition; -static int OldOrient; -static wxSize OldSize; -static int s_DefaultShapeGLabel = (int) NET_INPUT; -static int s_DefaultOrientGLabel = 0; +static int OldOrient; +static wxSize OldSize; +static int s_DefaultShapeGLabel = (int) NET_INPUT; +static int s_DefaultOrientGLabel = 0; - /************************************/ - /* class WinEDA_LabelPropertiesFrame */ - /************************************/ +/************************************/ +/* class WinEDA_LabelPropertiesFrame */ +/************************************/ #include "dialog_edit_label.cpp" /****************************************************************************/ -void WinEDA_LabelPropertiesFrame::TextPropertiesAccept(wxCommandEvent& event) +void WinEDA_LabelPropertiesFrame::TextPropertiesAccept( wxCommandEvent& event ) /****************************************************************************/ { -wxString text; -int value; - - /* save old text in undo list if not already in edit */ - if ( m_CurrentText->m_Flags == 0 ) - m_Parent->SaveCopyInUndoList(m_CurrentText, IS_CHANGED); + wxString text; + int value; - text = m_TextLabel->GetValue(); - if ( ! text.IsEmpty() ) m_CurrentText->m_Text = text; - else if ( (m_CurrentText->m_Flags & IS_NEW) == 0 ) - DisplayError(this, _("Empty Text!") ); + /* save old text in undo list if not already in edit */ + if( m_CurrentText->m_Flags == 0 ) + m_Parent->SaveCopyInUndoList( m_CurrentText, IS_CHANGED ); - m_CurrentText->m_Orient = m_TextOrient->GetSelection(); - text = m_TextSize->GetValue(); - value = ReturnValueFromString(g_UnitMetric, text, m_Parent->m_InternalUnits); - m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value; - if ( m_TextShape ) m_CurrentText->m_Shape = m_TextShape->GetSelection(); + text = m_TextLabel->GetValue(); + if( !text.IsEmpty() ) + m_CurrentText->m_Text = text; + else if( (m_CurrentText->m_Flags & IS_NEW) == 0 ) + DisplayError( this, _( "Empty Text!" ) ); - m_Parent->GetScreen()->SetModify(); + m_CurrentText->m_Orient = m_TextOrient->GetSelection(); + text = m_TextSize->GetValue(); + value = ReturnValueFromString( g_UnitMetric, text, m_Parent->m_InternalUnits ); + m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value; + if( m_TextShape ) + m_CurrentText->m_Shape = m_TextShape->GetSelection(); - /* Make the text size as new default size if it is a new text */ - if ( (m_CurrentText->m_Flags & IS_NEW) != 0 ) - g_DefaultTextLabelSize = m_CurrentText->m_Size.x; + m_Parent->GetScreen()->SetModify(); - Close(TRUE); + /* Make the text size as new default size if it is a new text */ + if( (m_CurrentText->m_Flags & IS_NEW) != 0 ) + g_DefaultTextLabelSize = m_CurrentText->m_Size.x; + + Close( TRUE ); } - /********************************************************************************/ -void WinEDA_SchematicFrame::StartMoveTexte(DrawTextStruct * TextStruct, wxDC *DC) +void WinEDA_SchematicFrame::StartMoveTexte( DrawTextStruct* TextStruct, wxDC* DC ) /********************************************************************************/ { - if(TextStruct == NULL) return; + if( TextStruct == NULL ) + return; - g_ItemToRepeat = NULL; - - if ( (TextStruct->m_Flags & IS_NEW) == 0 ) - { - delete g_ItemToUndoCopy; - g_ItemToUndoCopy = TextStruct->GenCopy(); - } + g_ItemToRepeat = NULL; - TextStruct->m_Flags |= IS_MOVED; + if( (TextStruct->m_Flags & IS_NEW) == 0 ) + { + delete g_ItemToUndoCopy; + g_ItemToUndoCopy = TextStruct->GenCopy(); + } - switch( TextStruct->m_StructType ) - { - case DRAW_LABEL_STRUCT_TYPE: - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - case DRAW_TEXT_STRUCT_TYPE: - ItemInitialPosition = TextStruct->m_Pos; - OldSize = TextStruct->m_Size; - OldOrient = TextStruct->m_Orient; - break; + TextStruct->m_Flags |= IS_MOVED; - default: break; - } + switch( TextStruct->m_StructType ) + { + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + ItemInitialPosition = TextStruct->m_Pos; + OldSize = TextStruct->m_Size; + OldOrient = TextStruct->m_Orient; + break; - DrawPanel->CursorOff(DC); - m_CurrentScreen->m_Curseur = ItemInitialPosition; - DrawPanel->MouseToCursorSchema(); - - GetScreen()->SetModify(); - DrawPanel->ManageCurseur = ShowWhileMoving; - DrawPanel->ForceCloseManageCurseur = ExitMoveTexte; - DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); - - DrawPanel->CursorOn(DC); + default: + break; + } + + DrawPanel->CursorOff( DC ); + m_CurrentScreen->m_Curseur = ItemInitialPosition; + DrawPanel->MouseToCursorSchema(); + + GetScreen()->SetModify(); + DrawPanel->ManageCurseur = ShowWhileMoving; + DrawPanel->ForceCloseManageCurseur = ExitMoveTexte; + DrawPanel->ManageCurseur( DrawPanel, DC, TRUE ); + + DrawPanel->CursorOn( DC ); } /*************************************************************************/ -void WinEDA_SchematicFrame::EditSchematicText(DrawTextStruct * TextStruct, - wxDC * DC) +void WinEDA_SchematicFrame::EditSchematicText( DrawTextStruct* TextStruct, + wxDC* DC ) /*************************************************************************/ + /* Edit the properties of the text (Label, Gloab label, graphic text).. ) - pointed by "TextStruct" -*/ + * pointed by "TextStruct" + */ { - if(TextStruct == NULL) return; + if( TextStruct == NULL ) + return; - DrawPanel->CursorOff(DC); - RedrawOneStruct(DrawPanel, DC, TextStruct, g_XorMode); + DrawPanel->CursorOff( DC ); + RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode ); -WinEDA_LabelPropertiesFrame * frame = new WinEDA_LabelPropertiesFrame(this, - TextStruct, wxPoint(30,30)); - frame->ShowModal(); frame->Destroy(); + WinEDA_LabelPropertiesFrame* frame = new WinEDA_LabelPropertiesFrame( this, + TextStruct, + wxPoint( 30, 30 ) ); + frame->ShowModal(); frame->Destroy(); - RedrawOneStruct(DrawPanel, DC, TextStruct, GR_DEFAULT_DRAWMODE); - DrawPanel->CursorOn(DC); + RedrawOneStruct( DrawPanel, DC, TextStruct, GR_DEFAULT_DRAWMODE ); + DrawPanel->CursorOn( DC ); } /***********************************************************************************/ -void WinEDA_SchematicFrame::ChangeTextOrient(DrawTextStruct * TextStruct, wxDC * DC) +void WinEDA_SchematicFrame::ChangeTextOrient( DrawTextStruct* TextStruct, wxDC* DC ) /***********************************************************************************/ { - if( TextStruct == NULL ) - TextStruct = (DrawTextStruct *) PickStruct(GetScreen()->m_Curseur, - GetScreen()->EEDrawList, TEXTITEM|LABELITEM); - if( TextStruct == NULL ) return; + if( TextStruct == NULL ) + TextStruct = (DrawTextStruct*) PickStruct( GetScreen()->m_Curseur, + GetScreen()->EEDrawList, TEXTITEM | LABELITEM ); + if( TextStruct == NULL ) + return; - /* save old text in undo list if is not already in edit */ - if ( TextStruct->m_Flags == 0 ) - SaveCopyInUndoList(TextStruct, IS_CHANGED); + /* save old text in undo list if is not already in edit */ + if( TextStruct->m_Flags == 0 ) + SaveCopyInUndoList( TextStruct, IS_CHANGED ); - /* Effacement du texte en cours */ - DrawPanel->CursorOff(DC); - RedrawOneStruct(DrawPanel, DC, TextStruct, g_XorMode); + /* Effacement du texte en cours */ + DrawPanel->CursorOff( DC ); + RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode ); - /* Rotation du texte */ - switch( TextStruct->m_StructType ) - { - case DRAW_LABEL_STRUCT_TYPE: - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - case DRAW_TEXT_STRUCT_TYPE: - ((DrawTextStruct*)TextStruct)->m_Orient++; - ((DrawTextStruct*)TextStruct)->m_Orient &= 3; - break; + /* Rotation du texte */ + switch( TextStruct->m_StructType ) + { + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + ( (DrawTextStruct*) TextStruct )->m_Orient++; + ( (DrawTextStruct*) TextStruct )->m_Orient &= 3; + break; - default: break; - } + default: + break; + } - GetScreen()->SetModify(); + GetScreen()->SetModify(); - /* Reaffichage */ - RedrawOneStruct(DrawPanel, DC, TextStruct, g_XorMode); - DrawPanel->CursorOn(DC); + /* Reaffichage */ + RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode ); + DrawPanel->CursorOn( DC ); } + /*************************************************************************/ -EDA_BaseStruct * WinEDA_SchematicFrame::CreateNewText(wxDC * DC, int type) +EDA_BaseStruct* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type ) /*************************************************************************/ + /* Routine to create new text struct (GraphicText, label or Glabel). -*/ + */ { -DrawTextStruct * NewText = NULL; + DrawTextStruct* NewText = NULL; - g_ItemToRepeat = NULL; + g_ItemToRepeat = NULL; - switch( type ) - { - case LAYER_NOTES: - NewText = new DrawTextStruct(m_CurrentScreen->m_Curseur); - NewText->m_Size.x = NewText->m_Size.y = g_DefaultTextLabelSize; - break; + switch( type ) + { + case LAYER_NOTES: + NewText = new DrawTextStruct( m_CurrentScreen->m_Curseur ); + NewText->m_Size.x = NewText->m_Size.y = g_DefaultTextLabelSize; + break; - case LAYER_LOCLABEL: - { - NewText = new DrawLabelStruct(m_CurrentScreen->m_Curseur); - NewText->m_Size.x = NewText->m_Size.y = g_DefaultTextLabelSize; - } - break; + case LAYER_LOCLABEL: + { + NewText = new DrawLabelStruct( m_CurrentScreen->m_Curseur ); + NewText->m_Size.x = NewText->m_Size.y = g_DefaultTextLabelSize; + } + break; - case LAYER_GLOBLABEL: - NewText = new DrawGlobalLabelStruct(m_CurrentScreen->m_Curseur); - NewText->m_Size.x = NewText->m_Size.y = g_DefaultTextLabelSize; - ((DrawGlobalLabelStruct*)NewText)->m_Shape = s_DefaultShapeGLabel; - ((DrawGlobalLabelStruct*)NewText)->m_Orient = s_DefaultOrientGLabel; - break; + case LAYER_GLOBLABEL: + NewText = new DrawGlobalLabelStruct( m_CurrentScreen->m_Curseur ); + NewText->m_Size.x = NewText->m_Size.y = g_DefaultTextLabelSize; + ( (DrawGlobalLabelStruct*) NewText )->m_Shape = s_DefaultShapeGLabel; + ( (DrawGlobalLabelStruct*) NewText )->m_Orient = s_DefaultOrientGLabel; + break; - default: - DisplayError(this, wxT("Editexte: Internal error") ); - break; - } + default: + DisplayError( this, wxT( "Editexte: Internal error" ) ); + break; + } - NewText->m_Flags = IS_NEW | IS_MOVED; + NewText->m_Flags = IS_NEW | IS_MOVED; - RedrawOneStruct(DrawPanel, DC, NewText, g_XorMode); - EditSchematicText(NewText, DC); + RedrawOneStruct( DrawPanel, DC, NewText, g_XorMode ); + EditSchematicText( NewText, DC ); - if ( NewText->m_Text.IsEmpty() ) - { - delete NewText; - return NULL; - } + if( NewText->m_Text.IsEmpty() ) + { + delete NewText; + return NULL; + } - if ( type == LAYER_GLOBLABEL ) - { - s_DefaultShapeGLabel = ((DrawGlobalLabelStruct*)NewText)->m_Shape; - s_DefaultOrientGLabel = ((DrawGlobalLabelStruct*)NewText)->m_Orient; - } + if( type == LAYER_GLOBLABEL ) + { + s_DefaultShapeGLabel = ( (DrawGlobalLabelStruct*) NewText )->m_Shape; + s_DefaultOrientGLabel = ( (DrawGlobalLabelStruct*) NewText )->m_Orient; + } - RedrawOneStruct(DrawPanel, DC, NewText, GR_DEFAULT_DRAWMODE); - DrawPanel->ManageCurseur = ShowWhileMoving; - DrawPanel->ForceCloseManageCurseur = ExitMoveTexte; + RedrawOneStruct( DrawPanel, DC, NewText, GR_DEFAULT_DRAWMODE ); + DrawPanel->ManageCurseur = ShowWhileMoving; + DrawPanel->ForceCloseManageCurseur = ExitMoveTexte; - m_CurrentScreen->m_CurrentItem = NewText; + m_CurrentScreen->SetCurItem( NewText ); - return NewText; + return NewText; } - - /****************************************/ - /* Dessin du Texte en deplacement */ - /****************************************/ -static void ShowWhileMoving(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/****************************************/ +/* Dessin du Texte en deplacement */ +/****************************************/ +static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) { -EDA_BaseStruct * TextStruct = panel->GetScreen()->m_CurrentItem; + EDA_BaseStruct* TextStruct = panel->GetScreen()->GetCurItem(); - /* effacement ancienne position */ - if( erase ) - RedrawOneStruct(panel, DC, TextStruct, g_XorMode); + /* effacement ancienne position */ + if( erase ) + RedrawOneStruct( panel, DC, TextStruct, g_XorMode ); - /* Redessin du texte */ - switch( TextStruct->m_StructType ) - { - case DRAW_LABEL_STRUCT_TYPE: - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - case DRAW_TEXT_STRUCT_TYPE: - ((DrawTextStruct*)TextStruct)->m_Pos = panel->GetScreen()->m_Curseur; - break; + /* Redessin du texte */ + switch( TextStruct->m_StructType ) + { + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + ( (DrawTextStruct*) TextStruct )->m_Pos = panel->GetScreen()->m_Curseur; + break; - default: break; - } + default: + break; + } - RedrawOneStruct(panel, DC, TextStruct, g_XorMode); + RedrawOneStruct( panel, DC, TextStruct, g_XorMode ); } /*************************************************************/ -static void ExitMoveTexte(WinEDA_DrawPanel * Panel, wxDC *DC) +static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC ) /*************************************************************/ /* Routine de sortie des menus de Texte */ { -SCH_SCREEN * screen = (SCH_SCREEN *) Panel->m_Parent->m_CurrentScreen; -EDA_BaseStruct * Struct = screen->m_CurrentItem; + SCH_SCREEN* screen = (SCH_SCREEN*) Panel->m_Parent->m_CurrentScreen; + EDA_BaseStruct* Struct = screen->GetCurItem(); - g_ItemToRepeat = NULL; - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; + g_ItemToRepeat = NULL; + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; - if( Struct == NULL) /* Pas de trace en cours */ - { - return; - } + if( Struct == NULL ) /* Pas de trace en cours */ + { + return; + } - /* ici : trace en cours */ + /* ici : trace en cours */ - /* Effacement du trace en cours et suppression eventuelle de la structure */ - RedrawOneStruct(Panel, DC, Struct, g_XorMode); + /* Effacement du trace en cours et suppression eventuelle de la structure */ + RedrawOneStruct( Panel, DC, Struct, g_XorMode ); - if( Struct->m_Flags & IS_NEW ) /* Suppression du nouveau texte en cours de placement */ - { - delete Struct; - screen->m_CurrentItem = NULL; - } + if( Struct->m_Flags & IS_NEW ) /* Suppression du nouveau texte en cours de placement */ + { + delete Struct; + screen->SetCurItem( NULL ); + } + else /* Remise a jour des anciens parametres du texte */ + { + switch( Struct->m_StructType ) + { + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + { + DrawTextStruct* Text = (DrawTextStruct*) Struct; + Text->m_Pos = ItemInitialPosition; + Text->m_Size = OldSize; + Text->m_Orient = OldOrient; + } + break; - else /* Remise a jour des anciens parametres du texte */ - { - switch( Struct->m_StructType ) - { - case DRAW_LABEL_STRUCT_TYPE: - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - case DRAW_TEXT_STRUCT_TYPE: - { - DrawTextStruct * Text = (DrawTextStruct *) Struct; - Text->m_Pos = ItemInitialPosition; - Text->m_Size = OldSize; - Text->m_Orient = OldOrient; - } - break; + default: + break; + } - default: break; - } - - RedrawOneStruct(Panel, DC, Struct, GR_DEFAULT_DRAWMODE); - Struct->m_Flags = 0; - } + RedrawOneStruct( Panel, DC, Struct, GR_DEFAULT_DRAWMODE ); + Struct->m_Flags = 0; + } } + /*****************************************************************************/ -void WinEDA_SchematicFrame::ConvertTextType(DrawTextStruct * Text, - wxDC * DC, int newtype) +void WinEDA_SchematicFrame::ConvertTextType( DrawTextStruct* Text, + wxDC* DC, int newtype ) /*****************************************************************************/ /* Routine to change a text type to an other one (GraphicText, label or Glabel). -*/ + */ { - if ( Text == NULL ) return; + if( Text == NULL ) + return; - /* save Text in undo list if not already in edit, or moving ... */ - if ( Text->m_Flags == 0 ) - SaveCopyInUndoList(Text, IS_CHANGED); + /* save Text in undo list if not already in edit, or moving ... */ + if( Text->m_Flags == 0 ) + SaveCopyInUndoList( Text, IS_CHANGED ); - DrawPanel->CursorOff(DC); // Erase schematic cursor - RedrawOneStruct(DrawPanel, DC, Text, g_XorMode); // erase drawing - switch( newtype ) - { - case DRAW_LABEL_STRUCT_TYPE: - Text->m_StructType = DRAW_LABEL_STRUCT_TYPE; - Text->m_Layer = LAYER_LOCLABEL; - break; + DrawPanel->CursorOff( DC ); // Erase schematic cursor + RedrawOneStruct( DrawPanel, DC, Text, g_XorMode ); - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - Text->m_StructType = DRAW_GLOBAL_LABEL_STRUCT_TYPE; - Text->m_Layer = LAYER_GLOBLABEL; - break; + // erase drawing + switch( newtype ) + { + case DRAW_LABEL_STRUCT_TYPE: + Text->m_StructType = DRAW_LABEL_STRUCT_TYPE; + Text->m_Layer = LAYER_LOCLABEL; + break; - case DRAW_TEXT_STRUCT_TYPE: - Text->m_StructType = DRAW_TEXT_STRUCT_TYPE; - Text->m_Layer = LAYER_NOTES; - break; + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + Text->m_StructType = DRAW_GLOBAL_LABEL_STRUCT_TYPE; + Text->m_Layer = LAYER_GLOBLABEL; + break; - default: - DisplayError(this, wxT("ConvertTextType: Internal error") ); - break; - } + case DRAW_TEXT_STRUCT_TYPE: + Text->m_StructType = DRAW_TEXT_STRUCT_TYPE; + Text->m_Layer = LAYER_NOTES; + break; - RedrawOneStruct(DrawPanel, DC, Text, GR_DEFAULT_DRAWMODE); - DrawPanel->CursorOn(DC); // redraw schematic cursor + default: + DisplayError( this, wxT( "ConvertTextType: Internal error" ) ); + break; + } + + RedrawOneStruct( DrawPanel, DC, Text, GR_DEFAULT_DRAWMODE ); + DrawPanel->CursorOn( DC ); // redraw schematic cursor } - - diff --git a/eeschema/editpart.cpp b/eeschema/editpart.cpp index 92e9459e32..0e0bce060d 100644 --- a/eeschema/editpart.cpp +++ b/eeschema/editpart.cpp @@ -1,7 +1,7 @@ - /***************************************************/ - /* EESchema: */ - /* Edition des textes sur Composants en Schematique */ - /****************************************************/ +/***************************************************/ +/* EESchema: */ +/* Edition des textes sur Composants en Schematique */ +/****************************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -19,777 +19,821 @@ /* Fonctions exportees */ /* Fonctions locales */ -static void AbortMoveCmpField(WinEDA_DrawFrame * frame, wxDC * DC); -static void MoveCmpField(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void AbortMoveCmpField( WinEDA_DrawFrame* frame, wxDC* DC ); +static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); /* variables locales */ -static PartTextStruct * CurrentField; -static int Multiflag; -static int TextFieldSize = DEFAULT_SIZE_TEXT; -static wxPoint OldPos; +static PartTextStruct* CurrentField; +static int Multiflag; +static int TextFieldSize = DEFAULT_SIZE_TEXT; +static wxPoint OldPos; /* Classe de la frame des propri�t�s d'un composant en librairie */ enum id_cmpedit { - ID_SCHEDIT_NOTEBOOK = 3200, - ID_PANEL_BASIC, - ID_PANEL_REFERENCE, - ID_PANEL_VALUE, - ID_PANEL_FIELD1, - ID_PANEL_FIELD2, - ID_PANEL_FIELD3, - ID_PANEL_FIELD4, - ID_PANEL_FIELD5, - ID_PANEL_FIELD6, - ID_PANEL_FIELD7, - ID_PANEL_FIELD8, - ID_PANEL_MODULEPCB, - ID_PANEL_SUBSCHEMATIC, - ID_CLOSE_CMP_PROPERTIES, - ID_ACCEPT_CMP_PROPERTIES, - ID_RESTORE_CMP_DEFAULTS + ID_SCHEDIT_NOTEBOOK = 3200, + ID_PANEL_BASIC, + ID_PANEL_REFERENCE, + ID_PANEL_VALUE, + ID_PANEL_FIELD1, + ID_PANEL_FIELD2, + ID_PANEL_FIELD3, + ID_PANEL_FIELD4, + ID_PANEL_FIELD5, + ID_PANEL_FIELD6, + ID_PANEL_FIELD7, + ID_PANEL_FIELD8, + ID_PANEL_MODULEPCB, + ID_PANEL_SUBSCHEMATIC, + ID_CLOSE_CMP_PROPERTIES, + ID_ACCEPT_CMP_PROPERTIES, + ID_RESTORE_CMP_DEFAULTS }; - /************************************/ - /* class WinEDA_PartPropertiesFrame */ - /************************************/ +/************************************/ +/* class WinEDA_PartPropertiesFrame */ +/************************************/ -class WinEDA_ComponentPropertiesFrame: public wxDialog +class WinEDA_ComponentPropertiesFrame : public wxDialog { private: - WinEDA_SchematicFrame * m_Parent; - EDA_SchComponentStruct * m_Cmp; - EDA_LibComponentStruct * m_LibEntry; + WinEDA_SchematicFrame* m_Parent; + EDA_SchComponentStruct* m_Cmp; + EDA_LibComponentStruct* m_LibEntry; - wxCheckBox * m_ConvertButt; - wxRadioBox * m_SelectUnit; - wxRadioBox * m_MirrorUnit; - wxRadioBox * m_OrientUnit; - wxNotebook* m_NoteBook; - WinEDA_EnterText * m_RefInLib; - wxPanel * m_PanelBasic; + wxCheckBox* m_ConvertButt; + wxRadioBox* m_SelectUnit; + wxRadioBox* m_MirrorUnit; + wxRadioBox* m_OrientUnit; + wxNotebook* m_NoteBook; + WinEDA_EnterText* m_RefInLib; + wxPanel* m_PanelBasic; - wxPanel * m_PanelField[NUMBER_OF_FIELDS]; + wxPanel* m_PanelField[NUMBER_OF_FIELDS]; - wxCheckBox * ShowFieldText[NUMBER_OF_FIELDS]; - wxCheckBox * VorientFieldText[NUMBER_OF_FIELDS]; + wxCheckBox* ShowFieldText[NUMBER_OF_FIELDS]; + wxCheckBox* VorientFieldText[NUMBER_OF_FIELDS]; - WinEDA_GraphicTextCtrl * FieldTextCtrl[NUMBER_OF_FIELDS]; - WinEDA_PositionCtrl * FieldPosition[NUMBER_OF_FIELDS]; - int FieldFlags[NUMBER_OF_FIELDS]; - int FieldOrient[NUMBER_OF_FIELDS]; + WinEDA_GraphicTextCtrl* FieldTextCtrl[NUMBER_OF_FIELDS]; + WinEDA_PositionCtrl* FieldPosition[NUMBER_OF_FIELDS]; + int FieldFlags[NUMBER_OF_FIELDS]; + int FieldOrient[NUMBER_OF_FIELDS]; public: - // Constructor and destructor - WinEDA_ComponentPropertiesFrame(WinEDA_SchematicFrame *parent, wxPoint& pos, - EDA_SchComponentStruct * cmp); - ~WinEDA_ComponentPropertiesFrame(void) - { - } + + // Constructor and destructor + WinEDA_ComponentPropertiesFrame( WinEDA_SchematicFrame* parent, wxPoint& pos, + EDA_SchComponentStruct* cmp ); + ~WinEDA_ComponentPropertiesFrame( void ) + { + } + private: - void BuildPanelBasic(void); - void ComponentPropertiesAccept(wxCommandEvent& event); - void SetInitCmp( wxCommandEvent& event ); - void OnQuit(wxCommandEvent& event); + void BuildPanelBasic( void ); + void ComponentPropertiesAccept( wxCommandEvent& event ); + void SetInitCmp( wxCommandEvent& event ); + void OnQuit( wxCommandEvent& event ); - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() }; -BEGIN_EVENT_TABLE(WinEDA_ComponentPropertiesFrame, wxDialog) - EVT_BUTTON(ID_ACCEPT_CMP_PROPERTIES, WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept) - EVT_BUTTON(ID_CLOSE_CMP_PROPERTIES, WinEDA_ComponentPropertiesFrame::OnQuit) - EVT_BUTTON(ID_RESTORE_CMP_DEFAULTS, WinEDA_ComponentPropertiesFrame::SetInitCmp) +BEGIN_EVENT_TABLE( WinEDA_ComponentPropertiesFrame, wxDialog ) +EVT_BUTTON( ID_ACCEPT_CMP_PROPERTIES, WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept ) +EVT_BUTTON( ID_CLOSE_CMP_PROPERTIES, WinEDA_ComponentPropertiesFrame::OnQuit ) +EVT_BUTTON( ID_RESTORE_CMP_DEFAULTS, WinEDA_ComponentPropertiesFrame::SetInitCmp ) END_EVENT_TABLE() /**********************************************************************/ -void InstallCmpeditFrame(WinEDA_SchematicFrame * parent, wxPoint & pos, - EDA_SchComponentStruct * cmp) +void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos, + EDA_SchComponentStruct* cmp ) /*********************************************************************/ -/* Create the dialog box for the current component edition -*/ -{ - parent->DrawPanel->m_IgnoreMouseEvents = TRUE; - if ( cmp->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) - { - DisplayError( parent, wxT("InstallCmpeditFrame() error: This struct is not a component") ); - } - else - { - WinEDA_ComponentPropertiesFrame * frame = - new WinEDA_ComponentPropertiesFrame(parent, pos, cmp); - frame->ShowModal(); frame->Destroy(); - } - parent->DrawPanel->m_IgnoreMouseEvents = FALSE; -} +/* Create the dialog box for the current component edition + */ +{ + parent->DrawPanel->m_IgnoreMouseEvents = TRUE; + if( cmp->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + { + DisplayError( parent, + wxT( "InstallCmpeditFrame() error: This struct is not a component" ) ); + } + else + { + WinEDA_ComponentPropertiesFrame* frame = + new WinEDA_ComponentPropertiesFrame( parent, pos, cmp ); + frame->ShowModal(); frame->Destroy(); + } + parent->DrawPanel->m_IgnoreMouseEvents = FALSE; +} #define XSIZE 370 #define YSIZE 300 /***********************************************************************************/ WinEDA_ComponentPropertiesFrame::WinEDA_ComponentPropertiesFrame( - WinEDA_SchematicFrame *parent, wxPoint& framepos, EDA_SchComponentStruct * cmp) - : wxDialog(parent, -1, _("Component properties"), framepos, - wxSize(XSIZE, YSIZE), DIALOG_STYLE ) + WinEDA_SchematicFrame* parent, wxPoint& framepos, EDA_SchComponentStruct* cmp ) : + wxDialog( parent, -1, _( "Component properties" ), framepos, + wxSize( XSIZE, YSIZE ), DIALOG_STYLE ) /***********************************************************************************/ { -wxPoint pos, postmp; -wxLayoutConstraints* c; -wxPoint cmp_pos; -int ii; + wxPoint pos, postmp; + wxLayoutConstraints* c; + wxPoint cmp_pos; + int ii; - Centre(); - m_Parent = parent; - m_Cmp = cmp; - cmp_pos = m_Cmp->m_Pos; - m_LibEntry = FindLibPart(m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + Centre(); + m_Parent = parent; + m_Cmp = cmp; + cmp_pos = m_Cmp->m_Pos; + m_LibEntry = FindLibPart( m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); - if ( m_LibEntry == NULL ) - { - SetTitle(_("Component properties (Not found in lib)")); - } + if( m_LibEntry == NULL ) + { + SetTitle( _( "Component properties (Not found in lib)" ) ); + } - SetAutoLayout(TRUE); + SetAutoLayout( TRUE ); - m_NoteBook = new wxNotebook(this, ID_SCHEDIT_NOTEBOOK, - wxDefaultPosition,wxSize(XSIZE-6, YSIZE - 70) ); - c = new wxLayoutConstraints; - c->left.SameAs(this, wxLeft, 4); - c->right.SameAs(this, wxRight, 4); - c->top.SameAs(this, wxTop, 4); - c->bottom.SameAs(this, wxBottom, 40); - m_NoteBook->SetConstraints(c); - m_NoteBook->SetAutoLayout(TRUE); + m_NoteBook = new wxNotebook( this, ID_SCHEDIT_NOTEBOOK, + wxDefaultPosition, wxSize( XSIZE - 6, YSIZE - 70 ) ); + c = new wxLayoutConstraints; + c->left.SameAs( this, wxLeft, 4 ); + c->right.SameAs( this, wxRight, 4 ); + c->top.SameAs( this, wxTop, 4 ); + c->bottom.SameAs( this, wxBottom, 40 ); + m_NoteBook->SetConstraints( c ); + m_NoteBook->SetAutoLayout( TRUE ); - /* Creation des boutons de commande */ - pos.x = 40; pos.y = YSIZE - 60; - wxButton * GButton = new wxButton(this, ID_CLOSE_CMP_PROPERTIES, - _("Close"), pos); - GButton->SetForegroundColour(*wxBLUE); - c = new wxLayoutConstraints; - c->left.SameAs(this, wxLeft, 20); - c->height.AsIs(); - c->width.AsIs(); - c->bottom.SameAs(this, wxBottom, 5); - GButton->SetConstraints(c); + /* Creation des boutons de commande */ + pos.x = 40; pos.y = YSIZE - 60; + wxButton* GButton = new wxButton( this, ID_CLOSE_CMP_PROPERTIES, + _( "Close" ), pos ); + GButton->SetForegroundColour( *wxBLUE ); + c = new wxLayoutConstraints; + c->left.SameAs( this, wxLeft, 20 ); + c->height.AsIs(); + c->width.AsIs(); + c->bottom.SameAs( this, wxBottom, 5 ); + GButton->SetConstraints( c ); - pos.x += GButton->GetDefaultSize().x + 10; - wxButton * MButton = new wxButton(this, ID_RESTORE_CMP_DEFAULTS, - _("Defaults"), pos); - MButton->SetForegroundColour(*wxRED); - c = new wxLayoutConstraints; - c->left.SameAs(GButton, wxRight, 20); - c->height.AsIs(); - c->width.AsIs(); - c->bottom.SameAs(this, wxBottom, 5); - MButton->SetConstraints(c); + pos.x += GButton->GetDefaultSize().x + 10; + wxButton* MButton = new wxButton( this, ID_RESTORE_CMP_DEFAULTS, + _( "Defaults" ), pos ); + MButton->SetForegroundColour( *wxRED ); + c = new wxLayoutConstraints; + c->left.SameAs( GButton, wxRight, 20 ); + c->height.AsIs(); + c->width.AsIs(); + c->bottom.SameAs( this, wxBottom, 5 ); + MButton->SetConstraints( c ); - pos.x += MButton->GetDefaultSize().x + 10; - wxButton * Button = new wxButton(this, ID_ACCEPT_CMP_PROPERTIES, - _("Ok"), pos); - Button->SetForegroundColour(*wxBLUE); - c = new wxLayoutConstraints; - c->left.SameAs(MButton, wxRight, 20); - c->height.AsIs(); - c->width.AsIs(); - c->bottom.SameAs(this, wxBottom, 5); - Button->SetConstraints(c); + pos.x += MButton->GetDefaultSize().x + 10; + wxButton* Button = new wxButton( this, ID_ACCEPT_CMP_PROPERTIES, + _( "Ok" ), pos ); + Button->SetForegroundColour( *wxBLUE ); + c = new wxLayoutConstraints; + c->left.SameAs( MButton, wxRight, 20 ); + c->height.AsIs(); + c->width.AsIs(); + c->bottom.SameAs( this, wxBottom, 5 ); + Button->SetConstraints( c ); - // Add panel Basic - BuildPanelBasic(); - m_NoteBook->AddPage(m_PanelBasic, _("Options"), TRUE); + // Add panel Basic + BuildPanelBasic(); + m_NoteBook->AddPage( m_PanelBasic, _( "Options" ), TRUE ); - // Add panel Fields - for ( ii = 0; ii < NUMBER_OF_FIELDS; ii++) - { - m_PanelField[ii] = new wxPanel(m_NoteBook, ID_PANEL_REFERENCE + ii); - c = new wxLayoutConstraints; - c->left.SameAs(m_NoteBook, wxLeft); - c->right.SameAs(m_NoteBook, wxRight); - c->bottom.SameAs(m_NoteBook, wxBottom); - m_PanelField[ii]->SetConstraints(c); - m_NoteBook->AddPage(m_PanelField[ii], - DrawPartStruct::ReturnFieldName(ii), FALSE); + // Add panel Fields + for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) + { + m_PanelField[ii] = new wxPanel( m_NoteBook, ID_PANEL_REFERENCE + ii ); + c = new wxLayoutConstraints; + c->left.SameAs( m_NoteBook, wxLeft ); + c->right.SameAs( m_NoteBook, wxRight ); + c->bottom.SameAs( m_NoteBook, wxBottom ); + m_PanelField[ii]->SetConstraints( c ); + m_NoteBook->AddPage( m_PanelField[ii], + DrawPartStruct::ReturnFieldName( ii ), FALSE ); - pos.x = 10; pos.y = 20; - ShowFieldText[ii] = new wxCheckBox(m_PanelField[ii],-1, - _("Show Text"), pos); - if ( (m_Cmp->m_Field[ii].m_Attributs & TEXT_NO_VISIBLE ) == 0 ) - ShowFieldText[ii]->SetValue(TRUE); + pos.x = 10; pos.y = 20; + ShowFieldText[ii] = new wxCheckBox( m_PanelField[ii], -1, + _( "Show Text" ), pos ); + if( (m_Cmp->m_Field[ii].m_Attributs & TEXT_NO_VISIBLE ) == 0 ) + ShowFieldText[ii]->SetValue( TRUE ); - pos.x += 150; - VorientFieldText[ii] = new wxCheckBox(m_PanelField[ii],-1, - _("Vertical"), pos); - if ( m_Cmp->m_Field[ii].m_Orient ) VorientFieldText[ii]->SetValue(TRUE); + pos.x += 150; + VorientFieldText[ii] = new wxCheckBox( m_PanelField[ii], -1, + _( "Vertical" ), pos ); + if( m_Cmp->m_Field[ii].m_Orient ) + VorientFieldText[ii]->SetValue( TRUE ); - pos.x = 10; pos.y += 50; + pos.x = 10; pos.y += 50; - wxPoint field_pos; - FieldTextCtrl[ii] = new WinEDA_GraphicTextCtrl( m_PanelField[ii], - DrawPartStruct::ReturnFieldName(ii), - m_Cmp->m_Field[ii].m_Text, - m_Cmp->m_Field[ii].m_Size.x, - g_UnitMetric , - pos, 200, TRUE); - field_pos.x = m_Cmp->m_Field[ii].m_Pos.x - cmp_pos.x; - field_pos.y = m_Cmp->m_Field[ii].m_Pos.y - cmp_pos.y; - if ( m_Cmp->m_Field[ii].m_Text == wxEmptyString ) // Field non initialis�, set pos a 0,0) - field_pos = wxPoint(0,0); - FieldPosition[ii] = new WinEDA_PositionCtrl( m_PanelField[ii], _("Pos"), - field_pos, - g_UnitMetric , - wxPoint (pos.x + 150, pos.y + 32), - m_Parent->m_InternalUnits ); - } - - if ( m_LibEntry && m_LibEntry->m_Options == ENTRY_POWER ) - FieldTextCtrl[VALUE]->Enable(FALSE); + wxPoint field_pos; + FieldTextCtrl[ii] = new WinEDA_GraphicTextCtrl( m_PanelField[ii], + DrawPartStruct::ReturnFieldName( ii ), + m_Cmp->m_Field[ii].m_Text, + m_Cmp->m_Field[ii].m_Size.x, + g_UnitMetric, + pos, 200, TRUE ); + field_pos.x = m_Cmp->m_Field[ii].m_Pos.x - cmp_pos.x; + field_pos.y = m_Cmp->m_Field[ii].m_Pos.y - cmp_pos.y; + if( m_Cmp->m_Field[ii].m_Text == wxEmptyString ) // Field non initialis�, set pos a 0,0) + field_pos = wxPoint( 0, 0 ); + FieldPosition[ii] = new WinEDA_PositionCtrl( m_PanelField[ii], _( "Pos" ), + field_pos, + g_UnitMetric, + wxPoint( pos.x + 150, pos.y + 32 ), + m_Parent->m_InternalUnits ); + } + if( m_LibEntry && m_LibEntry->m_Options == ENTRY_POWER ) + FieldTextCtrl[VALUE]->Enable( FALSE ); } + /************************************************************************/ -void WinEDA_ComponentPropertiesFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +void WinEDA_ComponentPropertiesFrame::OnQuit( wxCommandEvent& WXUNUSED (event) ) /************************************************************************/ { // true is to force the frame to close - Close(true); + Close( true ); } /**********************************************************/ -void WinEDA_ComponentPropertiesFrame::BuildPanelBasic(void) +void WinEDA_ComponentPropertiesFrame::BuildPanelBasic( void ) /**********************************************************/ + /* create the basic panel for component properties editing -*/ + */ { -wxPoint pos, postmp; -int ii, jj; + wxPoint pos, postmp; + int ii, jj; - m_PanelBasic = new wxPanel(m_NoteBook, ID_PANEL_BASIC); - wxLayoutConstraints * c = new wxLayoutConstraints; - c->left.SameAs(m_NoteBook, wxLeft); - c->right.SameAs(m_NoteBook, wxRight); - c->bottom.SameAs(m_NoteBook, wxBottom); - m_PanelBasic->SetConstraints(c); + m_PanelBasic = new wxPanel( m_NoteBook, ID_PANEL_BASIC ); + wxLayoutConstraints* c = new wxLayoutConstraints; + c->left.SameAs( m_NoteBook, wxLeft ); + c->right.SameAs( m_NoteBook, wxRight ); + c->bottom.SameAs( m_NoteBook, wxBottom ); + m_PanelBasic->SetConstraints( c ); - pos.x = 5; pos.y = 15; + pos.x = 5; pos.y = 15; #define NB_MAX_UNIT 16 -int nb_units = m_LibEntry ? MAX(m_LibEntry->m_UnitCount, 1) : 0; -wxString list_units[NB_MAX_UNIT]; + int nb_units = m_LibEntry ? MAX( m_LibEntry->m_UnitCount, 1 ) : 0; + wxString list_units[NB_MAX_UNIT]; - if ( nb_units > 16 ) nb_units = 16; - for ( ii = 0; ii < NB_MAX_UNIT; ii++ ) - list_units[ii] << _("Unit") << (ii+1); - m_SelectUnit = new wxRadioBox(m_PanelBasic, -1, _("Unit:"), - pos, wxSize(-1,-1), - (nb_units < 8 ) ? 8 : nb_units, list_units, 1); - for ( ii = nb_units; ii < 8; ii++ ) - { - m_SelectUnit->Enable(ii, FALSE); // Disable non existant units - } - m_SelectUnit->SetSelection(m_Cmp->m_Multi -1); + if( nb_units > 16 ) + nb_units = 16; + for( ii = 0; ii < NB_MAX_UNIT; ii++ ) + list_units[ii] << _( "Unit" ) << (ii + 1); - m_SelectUnit->GetSize(&ii, &jj); - pos.x += ii + 5; postmp = pos; + m_SelectUnit = new wxRadioBox( m_PanelBasic, -1, _( "Unit:" ), + pos, wxSize( -1, -1 ), + (nb_units < 8 ) ? 8 : nb_units, list_units, 1 ); + for( ii = nb_units; ii < 8; ii++ ) + { + m_SelectUnit->Enable( ii, FALSE ); // Disable non existant units + } -wxString list_orient[4] = { wxT("0"), wxT("+90"), wxT("180"), wxT("-90") }; - pos.x += 45; pos.y = 15; - m_OrientUnit = new wxRadioBox(m_PanelBasic, -1, _("Orient:"), - pos, wxSize(-1,-1), 4, list_orient, 1); - ii = m_Cmp->GetRotationMiroir() & ~(CMP_MIROIR_X|CMP_MIROIR_Y); + m_SelectUnit->SetSelection( m_Cmp->m_Multi - 1 ); - if ( ii == CMP_ORIENT_90) m_OrientUnit->SetSelection(1); - else if ( ii == CMP_ORIENT_180) m_OrientUnit->SetSelection(2); - else if ( ii == CMP_ORIENT_270) m_OrientUnit->SetSelection(3); + m_SelectUnit->GetSize( &ii, &jj ); + pos.x += ii + 5; postmp = pos; - m_OrientUnit->GetSize(&ii, &jj); - pos.x += ii + 30; -wxString list_mirror[3] = { _("Normal"), _("Mirror --"), _("Mirror |")}; - m_MirrorUnit = new wxRadioBox(m_PanelBasic, -1, _("Mirror:"), - pos, wxSize(-1,-1), 3, list_mirror, 1); - ii = m_Cmp->GetRotationMiroir() & (CMP_MIROIR_X|CMP_MIROIR_Y) ; - if ( ii == CMP_MIROIR_X ) m_MirrorUnit->SetSelection(1); - else if ( ii == CMP_MIROIR_Y ) m_MirrorUnit->SetSelection(2); + wxString list_orient[4] = { wxT( "0" ), wxT( "+90" ), wxT( "180" ), wxT( "-90" ) }; + pos.x += 45; pos.y = 15; + m_OrientUnit = new wxRadioBox( m_PanelBasic, -1, _( "Orient:" ), + pos, wxSize( -1, -1 ), 4, list_orient, 1 ); + ii = m_Cmp->GetRotationMiroir() & ~(CMP_MIROIR_X | CMP_MIROIR_Y); - // Positionnement de la selection normal/convert - m_OrientUnit->GetSize(&ii, &jj); - pos = postmp; - pos.y += jj + 10; - m_ConvertButt = new wxCheckBox(m_PanelBasic,-1, _("Convert"), pos); - if ( m_Cmp->m_Convert > 1 ) m_ConvertButt->SetValue(TRUE); + if( ii == CMP_ORIENT_90 ) + m_OrientUnit->SetSelection( 1 ); + else if( ii == CMP_ORIENT_180 ) + m_OrientUnit->SetSelection( 2 ); + else if( ii == CMP_ORIENT_270 ) + m_OrientUnit->SetSelection( 3 ); - if ( (m_LibEntry == NULL) || LookForConvertPart(m_LibEntry) <= 1) - { - m_ConvertButt->Enable(FALSE); - } + m_OrientUnit->GetSize( &ii, &jj ); + pos.x += ii + 30; + wxString list_mirror[3] = { _( "Normal" ), _( "Mirror --" ), _( "Mirror |" ) }; + m_MirrorUnit = new wxRadioBox( m_PanelBasic, -1, _( "Mirror:" ), + pos, wxSize( -1, -1 ), 3, list_mirror, 1 ); + ii = m_Cmp->GetRotationMiroir() & (CMP_MIROIR_X | CMP_MIROIR_Y); + if( ii == CMP_MIROIR_X ) + m_MirrorUnit->SetSelection( 1 ); + else if( ii == CMP_MIROIR_Y ) + m_MirrorUnit->SetSelection( 2 ); - // Show the "Parts Locked" option: - if ( m_LibEntry && m_LibEntry->m_UnitSelectionLocked ) - { - new wxStaticText(m_PanelBasic, -1, _("Parts are locked"), - wxPoint(m_MirrorUnit->GetRect().x, pos.y) ); - } + // Positionnement de la selection normal/convert + m_OrientUnit->GetSize( &ii, &jj ); + pos = postmp; + pos.y += jj + 10; + m_ConvertButt = new wxCheckBox( m_PanelBasic, -1, _( "Convert" ), pos ); + if( m_Cmp->m_Convert > 1 ) + m_ConvertButt->SetValue( TRUE ); - // Positionnement de la reference en librairie - m_ConvertButt->GetSize(&ii, &jj); - pos.y += jj + 20; - m_RefInLib = new WinEDA_EnterText(m_PanelBasic, _("Chip Name:"), - m_Cmp->m_ChipName, - pos, wxSize(XSIZE - pos.x - 30, -1) ); + if( (m_LibEntry == NULL) || LookForConvertPart( m_LibEntry ) <= 1 ) + { + m_ConvertButt->Enable( FALSE ); + } + // Show the "Parts Locked" option: + if( m_LibEntry && m_LibEntry->m_UnitSelectionLocked ) + { + new wxStaticText( m_PanelBasic, -1, _( "Parts are locked" ), + wxPoint( m_MirrorUnit->GetRect().x, pos.y ) ); + } + + // Positionnement de la reference en librairie + m_ConvertButt->GetSize( &ii, &jj ); + pos.y += jj + 20; + m_RefInLib = new WinEDA_EnterText( m_PanelBasic, _( "Chip Name:" ), + m_Cmp->m_ChipName, + pos, wxSize( XSIZE - pos.x - 30, -1 ) ); } /***********************************************************************************/ -void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept(wxCommandEvent& event) +void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept( wxCommandEvent& event ) /***********************************************************************************/ + /* Update the new parameters for the current edited component -*/ + */ { -wxPoint cmp_pos = m_Cmp->m_Pos; -wxClientDC dc(m_Parent->DrawPanel); -wxString newname; + wxPoint cmp_pos = m_Cmp->m_Pos; + wxClientDC dc( m_Parent->DrawPanel ); + wxString newname; - m_Parent->DrawPanel->PrepareGraphicContext(&dc); + m_Parent->DrawPanel->PrepareGraphicContext( &dc ); - RedrawOneStruct(m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode); + RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode ); - newname = m_RefInLib->GetValue(); - newname.MakeUpper(); - newname.Replace(wxT(" "), wxT("_")); + newname = m_RefInLib->GetValue(); + newname.MakeUpper(); + newname.Replace( wxT( " " ), wxT( "_" ) ); - if ( newname.IsEmpty() ) DisplayError(this, _("No Component Name!")); - else if ( newname.CmpNoCase(m_Cmp->m_ChipName) ) - { - if ( FindLibPart(newname.GetData(), wxEmptyString, FIND_ALIAS) == NULL ) - { - wxString msg; - msg.Printf( _("Component [%s] not found!"), newname.GetData() ); - DisplayError(this, msg); - } - else // Changement de composant! - { - m_Cmp->m_ChipName = newname; - } - } + if( newname.IsEmpty() ) + DisplayError( this, _( "No Component Name!" ) ); + else if( newname.CmpNoCase( m_Cmp->m_ChipName ) ) + { + if( FindLibPart( newname.GetData(), wxEmptyString, FIND_ALIAS ) == NULL ) + { + wxString msg; + msg.Printf( _( "Component [%s] not found!" ), newname.GetData() ); + DisplayError( this, msg ); + } + else // Changement de composant! + { + m_Cmp->m_ChipName = newname; + } + } - // Mise a jour de la representation: - if ( m_ConvertButt->IsEnabled() ) - (m_ConvertButt->GetValue() == TRUE) ? - m_Cmp->m_Convert = 2 : m_Cmp->m_Convert = 1; + // Mise a jour de la representation: + if( m_ConvertButt->IsEnabled() ) + (m_ConvertButt->GetValue() == TRUE) ? + m_Cmp->m_Convert = 2 : m_Cmp->m_Convert = 1; - //Mise a jour de la selection de l'�l�ment dans le boitier - if ( m_Cmp->m_Multi ) m_Cmp->m_Multi = m_SelectUnit->GetSelection() + 1; + //Mise a jour de la selection de l'�l�ment dans le boitier + if( m_Cmp->m_Multi ) + m_Cmp->m_Multi = m_SelectUnit->GetSelection() + 1; - //Mise a jour de l'orientation: - switch (m_OrientUnit->GetSelection() ) - { - case 0: - m_Cmp->SetRotationMiroir(CMP_ORIENT_0); - break; - case 1: - m_Cmp->SetRotationMiroir(CMP_ORIENT_90); - break; - case 2: - m_Cmp->SetRotationMiroir(CMP_ORIENT_180); - break; - case 3: - m_Cmp->SetRotationMiroir(CMP_ORIENT_270); - break; - } + //Mise a jour de l'orientation: + switch( m_OrientUnit->GetSelection() ) + { + case 0: + m_Cmp->SetRotationMiroir( CMP_ORIENT_0 ); + break; - switch (m_MirrorUnit->GetSelection() ) - { - case 0: - break; - case 1: - m_Cmp->SetRotationMiroir(CMP_MIROIR_X); - break; - case 2: - m_Cmp->SetRotationMiroir(CMP_MIROIR_Y); - break; - } + case 1: + m_Cmp->SetRotationMiroir( CMP_ORIENT_90 ); + break; + + case 2: + m_Cmp->SetRotationMiroir( CMP_ORIENT_180 ); + break; + + case 3: + m_Cmp->SetRotationMiroir( CMP_ORIENT_270 ); + break; + } + + switch( m_MirrorUnit->GetSelection() ) + { + case 0: + break; + + case 1: + m_Cmp->SetRotationMiroir( CMP_MIROIR_X ); + break; + + case 2: + m_Cmp->SetRotationMiroir( CMP_MIROIR_Y ); + break; + } - // Mise a jour des textes - for ( int ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ ) - { - if( ii == REFERENCE ) // la reference ne peut etre vide - { - if ( ! FieldTextCtrl[ii]->GetText().IsEmpty() ) - m_Cmp->m_Field[ii].m_Text = FieldTextCtrl[ii]->GetText(); - } - else if( ii == VALUE ) // la valeur ne peut etre vide et ne peut etre change sur un POWER - { - EDA_LibComponentStruct *Entry = FindLibPart(m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); - if( Entry && (Entry->m_Options == ENTRY_POWER) ) - m_Cmp->m_Field[ii].m_Text = m_Cmp->m_ChipName; - else if ( ! FieldTextCtrl[ii]->GetText().IsEmpty() ) - { - m_Cmp->m_Field[ii].m_Text = FieldTextCtrl[ii]->GetText(); - } - } - else - m_Cmp->m_Field[ii].m_Text = FieldTextCtrl[ii]->GetText(); + // Mise a jour des textes + for( int ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ ) + { + if( ii == REFERENCE ) // la reference ne peut etre vide + { + if( !FieldTextCtrl[ii]->GetText().IsEmpty() ) + m_Cmp->m_Field[ii].m_Text = FieldTextCtrl[ii]->GetText(); + } + else if( ii == VALUE ) // la valeur ne peut etre vide et ne peut etre change sur un POWER + { + EDA_LibComponentStruct* Entry = FindLibPart( m_Cmp->m_ChipName.GetData( + ), wxEmptyString, FIND_ROOT ); + if( Entry && (Entry->m_Options == ENTRY_POWER) ) + m_Cmp->m_Field[ii].m_Text = m_Cmp->m_ChipName; + else if( !FieldTextCtrl[ii]->GetText().IsEmpty() ) + { + m_Cmp->m_Field[ii].m_Text = FieldTextCtrl[ii]->GetText(); + } + } + else + m_Cmp->m_Field[ii].m_Text = FieldTextCtrl[ii]->GetText(); - m_Cmp->m_Field[ii].m_Size.x = - m_Cmp->m_Field[ii].m_Size.y = FieldTextCtrl[ii]->GetTextSize(); - if ( ShowFieldText[ii]->GetValue() ) - m_Cmp->m_Field[ii].m_Attributs &= ~TEXT_NO_VISIBLE; - else - m_Cmp->m_Field[ii].m_Attributs |= TEXT_NO_VISIBLE; - m_Cmp->m_Field[ii].m_Orient = VorientFieldText[ii]->GetValue() ? 1 : 0; - m_Cmp->m_Field[ii].m_Pos = FieldPosition[ii]->GetValue(); - m_Cmp->m_Field[ii].m_Pos.x += cmp_pos.x; - m_Cmp->m_Field[ii].m_Pos.y += cmp_pos.y; - } - m_Parent->m_CurrentScreen->SetModify(); + m_Cmp->m_Field[ii].m_Size.x = + m_Cmp->m_Field[ii].m_Size.y = FieldTextCtrl[ii]->GetTextSize(); + if( ShowFieldText[ii]->GetValue() ) + m_Cmp->m_Field[ii].m_Attributs &= ~TEXT_NO_VISIBLE; + else + m_Cmp->m_Field[ii].m_Attributs |= TEXT_NO_VISIBLE; + m_Cmp->m_Field[ii].m_Orient = VorientFieldText[ii]->GetValue() ? 1 : 0; + m_Cmp->m_Field[ii].m_Pos = FieldPosition[ii]->GetValue(); + m_Cmp->m_Field[ii].m_Pos.x += cmp_pos.x; + m_Cmp->m_Field[ii].m_Pos.y += cmp_pos.y; + } - RedrawOneStruct(m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE); - m_Parent->TestDanglingEnds(m_Parent->m_CurrentScreen->EEDrawList, &dc); + m_Parent->m_CurrentScreen->SetModify(); - Close(); + RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE ); + m_Parent->TestDanglingEnds( m_Parent->m_CurrentScreen->EEDrawList, &dc ); + + Close(); } +/************************************************************************************/ +void WinEDA_SchematicFrame::StartMoveCmpField( PartTextStruct* Field, wxDC* DC ) +/************************************************************************************/ -/************************************************************************************/ -void WinEDA_SchematicFrame::StartMoveCmpField(PartTextStruct * Field, wxDC * DC) -/************************************************************************************/ /* Prepare le deplacement du texte en cours d'edition -*/ + */ { -EDA_LibComponentStruct *Entry; + EDA_LibComponentStruct* Entry; - CurrentField = Field; - if ( Field == NULL ) return; + CurrentField = Field; + if( Field == NULL ) + return; - if(Field->m_Text == wxEmptyString) - { - DisplayError(this, _("No Field to move"), 10); - return; - } + if( Field->m_Text == wxEmptyString ) + { + DisplayError( this, _( "No Field to move" ), 10 ); + return; + } - OldPos = Field->m_Pos; - Multiflag = 0; - if( Field->m_FieldId == REFERENCE ) - { - Entry = FindLibPart( ((EDA_SchComponentStruct*)Field->m_Parent)->m_ChipName.GetData(), - wxEmptyString, FIND_ROOT); - if( Entry != NULL ) - { - if ( Entry->m_UnitCount > 1 ) Multiflag = 1; - } - } + OldPos = Field->m_Pos; + Multiflag = 0; + if( Field->m_FieldId == REFERENCE ) + { + Entry = FindLibPart( ( (EDA_SchComponentStruct*) Field->m_Parent )->m_ChipName.GetData(), + wxEmptyString, FIND_ROOT ); + if( Entry != NULL ) + { + if( Entry->m_UnitCount > 1 ) + Multiflag = 1; + } + } - DrawPanel->ForceCloseManageCurseur = AbortMoveCmpField; - DrawPanel->ManageCurseur = MoveCmpField; - Field->m_Flags = IS_MOVED; + DrawPanel->ForceCloseManageCurseur = AbortMoveCmpField; + DrawPanel->ManageCurseur = MoveCmpField; + Field->m_Flags = IS_MOVED; } /**********************************************************************************/ -void WinEDA_SchematicFrame::EditCmpFieldText(PartTextStruct * Field, wxDC *DC) +void WinEDA_SchematicFrame::EditCmpFieldText( PartTextStruct* Field, wxDC* DC ) /**********************************************************************************/ /* Routine de changement du texte selectionne */ { -int FieldNumber, flag; -EDA_LibComponentStruct *Entry; + int FieldNumber, flag; + EDA_LibComponentStruct* Entry; - if( Field == NULL ) - { - DisplayError(this, _("No Field To Edit"), 10); - return; - } + if( Field == NULL ) + { + DisplayError( this, _( "No Field To Edit" ), 10 ); + return; + } - FieldNumber = Field->m_FieldId; - if( FieldNumber == VALUE ) - { - Entry = FindLibPart( ((EDA_SchComponentStruct*)Field->m_Parent)->m_ChipName.GetData(), - wxEmptyString, FIND_ROOT); - if( Entry && (Entry->m_Options == ENTRY_POWER) ) - { - DisplayInfo(this, - _("Part is a POWER, value cannot be modified!\nYou must create a new power") ); - return; - } - } + FieldNumber = Field->m_FieldId; + if( FieldNumber == VALUE ) + { + Entry = FindLibPart( ( (EDA_SchComponentStruct*) Field->m_Parent )->m_ChipName.GetData(), + wxEmptyString, FIND_ROOT ); + if( Entry && (Entry->m_Options == ENTRY_POWER) ) + { + DisplayInfo( this, + _( + "Part is a POWER, value cannot be modified!\nYou must create a new power" ) + ); + return; + } + } - flag = 0; - if( FieldNumber == REFERENCE ) - { - Entry = FindLibPart( ((EDA_SchComponentStruct*)Field->m_Parent)->m_ChipName.GetData(), - wxEmptyString, FIND_ROOT); - if( Entry != NULL ) - { - if ( Entry->m_UnitCount > 1 ) flag = 1; - } - } + flag = 0; + if( FieldNumber == REFERENCE ) + { + Entry = FindLibPart( ( (EDA_SchComponentStruct*) Field->m_Parent )->m_ChipName.GetData(), + wxEmptyString, FIND_ROOT ); + if( Entry != NULL ) + { + if( Entry->m_UnitCount > 1 ) + flag = 1; + } + } - wxString newtext = Field->m_Text; - Get_Message(DrawPartStruct::ReturnFieldName(FieldNumber), newtext, this); + wxString newtext = Field->m_Text; + Get_Message( DrawPartStruct::ReturnFieldName( FieldNumber ), newtext, this ); - DrawTextField(DrawPanel, DC, Field, flag, g_XorMode); + DrawTextField( DrawPanel, DC, Field, flag, g_XorMode ); - if ( ! newtext.IsEmpty() ) - { - if (Field->m_Text.IsEmpty()) - { - Field->m_Pos = ((EDA_SchComponentStruct*)Field->m_Parent)->m_Pos; - Field->m_Size.x = Field->m_Size.y = TextFieldSize; - } - Field->m_Text = newtext; - } + if( !newtext.IsEmpty() ) + { + if( Field->m_Text.IsEmpty() ) + { + Field->m_Pos = ( (EDA_SchComponentStruct*) Field->m_Parent )->m_Pos; + Field->m_Size.x = Field->m_Size.y = TextFieldSize; + } + Field->m_Text = newtext; + } + else /* Nouveau texte NULL */ + { + if( FieldNumber == REFERENCE ) + { + DisplayError( this, _( "Reference needed !, No change" ) ); + } + else if( FieldNumber == VALUE ) + { + DisplayError( this, _( "Value needed !, No change" ) ); + } + else + { + Field->m_Text = wxT( "~" ); + } + } - else /* Nouveau texte NULL */ - { - if( FieldNumber == REFERENCE ) - { - DisplayError(this, _("Reference needed !, No change")); - } - else if( FieldNumber == VALUE ) - { - DisplayError(this, _("Value needed !, No change")); - } - else - { - Field->m_Text = wxT("~"); - } - } - - DrawTextField(DrawPanel, DC, Field, flag, g_XorMode); - ((EDA_SchComponentStruct*)Field->m_Parent)->Display_Infos(this); - m_CurrentScreen->SetModify(); + DrawTextField( DrawPanel, DC, Field, flag, g_XorMode ); + ( (EDA_SchComponentStruct*) Field->m_Parent )->Display_Infos( this ); + m_CurrentScreen->SetModify(); } /************************************************************************/ -static void MoveCmpField(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /************************************************************************/ + /* Routine de deplacement d'un texte type Field. - Celle routine est normalement attachee au deplacement du curseur -*/ + * Celle routine est normalement attachee au deplacement du curseur + */ { -#define TRF ((EDA_SchComponentStruct*)CurrentField->m_Parent)->m_Transform -wxPoint pos; -int x1, y1; -int FieldNumber; +#define TRF ( (EDA_SchComponentStruct*) CurrentField->m_Parent )->m_Transform + wxPoint pos; + int x1, y1; + int FieldNumber; - if( CurrentField == NULL) return; + if( CurrentField == NULL ) + return; - FieldNumber = CurrentField->m_FieldId; + FieldNumber = CurrentField->m_FieldId; - /* Effacement: */ - if( erase ) - DrawTextField(panel, DC, CurrentField, Multiflag, g_XorMode); + /* Effacement: */ + if( erase ) + DrawTextField( panel, DC, CurrentField, Multiflag, g_XorMode ); - pos = ((EDA_SchComponentStruct*)CurrentField->m_Parent)->m_Pos; + pos = ( (EDA_SchComponentStruct*) CurrentField->m_Parent )->m_Pos; - /* Les positions sont caculees par la matrice TRANSPOSEE de la matrice - de rotation-miroir */ - x1 = panel->GetScreen()->m_Curseur.x - pos.x; - y1 = panel->GetScreen()->m_Curseur.y - pos.y; - CurrentField->m_Pos.x = pos.x + TRF[0][0] * x1 + TRF[1][0] * y1; - CurrentField->m_Pos.y = pos.y + TRF[0][1] * x1 + TRF[1][1] * y1; + /* Les positions sont caculees par la matrice TRANSPOSEE de la matrice + * de rotation-miroir */ + x1 = panel->GetScreen()->m_Curseur.x - pos.x; + y1 = panel->GetScreen()->m_Curseur.y - pos.y; + CurrentField->m_Pos.x = pos.x + TRF[0][0] * x1 + TRF[1][0] * y1; + CurrentField->m_Pos.y = pos.y + TRF[0][1] * x1 + TRF[1][1] * y1; - DrawTextField(panel, DC, CurrentField, Multiflag, g_XorMode); + DrawTextField( panel, DC, CurrentField, Multiflag, g_XorMode ); } /******************************************************************/ -static void AbortMoveCmpField(WinEDA_DrawFrame * frame, wxDC * DC) +static void AbortMoveCmpField( WinEDA_DrawFrame* frame, wxDC* DC ) /******************************************************************/ { - frame->DrawPanel->ForceCloseManageCurseur = NULL; - frame->DrawPanel->ManageCurseur = NULL; - if ( CurrentField ) - { - DrawTextField(frame->DrawPanel, DC, CurrentField,Multiflag, g_XorMode); - CurrentField->m_Flags = 0; - CurrentField->m_Pos = OldPos; - DrawTextField(frame->DrawPanel, DC, CurrentField,Multiflag, GR_DEFAULT_DRAWMODE); - } - CurrentField = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; + frame->DrawPanel->ManageCurseur = NULL; + if( CurrentField ) + { + DrawTextField( frame->DrawPanel, DC, CurrentField, Multiflag, g_XorMode ); + CurrentField->m_Flags = 0; + CurrentField->m_Pos = OldPos; + DrawTextField( frame->DrawPanel, DC, CurrentField, Multiflag, GR_DEFAULT_DRAWMODE ); + } + CurrentField = NULL; } + /*********************************************************************************/ -void WinEDA_SchematicFrame::RotateCmpField(PartTextStruct * Field, wxDC * DC) +void WinEDA_SchematicFrame::RotateCmpField( PartTextStruct* Field, wxDC* DC ) /*********************************************************************************/ { -int FieldNumber, flag; -EDA_LibComponentStruct *Entry; + int FieldNumber, flag; + EDA_LibComponentStruct* Entry; - if (Field == NULL ) return; - if (Field->m_Text == wxEmptyString ) return; + if( Field == NULL ) + return; + if( Field->m_Text == wxEmptyString ) + return; - FieldNumber = Field->m_FieldId; - flag = 0; - if( FieldNumber == REFERENCE ) - { - Entry = FindLibPart( ((EDA_SchComponentStruct*)Field->m_Parent)->m_ChipName.GetData(), - wxEmptyString, FIND_ROOT); - if( Entry != NULL ) - { - if ( Entry->m_UnitCount > 1 ) flag = 1; - } - } + FieldNumber = Field->m_FieldId; + flag = 0; + if( FieldNumber == REFERENCE ) + { + Entry = FindLibPart( ( (EDA_SchComponentStruct*) Field->m_Parent )->m_ChipName.GetData(), + wxEmptyString, FIND_ROOT ); + if( Entry != NULL ) + { + if( Entry->m_UnitCount > 1 ) + flag = 1; + } + } - DrawTextField(DrawPanel, DC, Field, flag, g_XorMode); + DrawTextField( DrawPanel, DC, Field, flag, g_XorMode ); - if( Field->m_Orient == TEXT_ORIENT_HORIZ ) Field->m_Orient = TEXT_ORIENT_VERT; - else Field->m_Orient = TEXT_ORIENT_HORIZ; - DrawTextField(DrawPanel, DC, Field,flag, g_XorMode); + if( Field->m_Orient == TEXT_ORIENT_HORIZ ) + Field->m_Orient = TEXT_ORIENT_VERT; + else + Field->m_Orient = TEXT_ORIENT_HORIZ; + DrawTextField( DrawPanel, DC, Field, flag, g_XorMode ); - GetScreen()->SetModify(); + GetScreen()->SetModify(); } /***************************************************************/ -void PartTextStruct::Place( WinEDA_DrawFrame * frame, wxDC * DC) +void PartTextStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) /***************************************************************/ { -int FieldNumber, flag; -EDA_LibComponentStruct *Entry; + int FieldNumber, flag; + EDA_LibComponentStruct* Entry; - frame->DrawPanel->ManageCurseur = NULL; - frame->DrawPanel->ForceCloseManageCurseur = NULL; + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; - FieldNumber = m_FieldId; - flag = 0; - if( FieldNumber == REFERENCE ) - { - Entry = FindLibPart( ((EDA_SchComponentStruct*)m_Parent)->m_ChipName.GetData(), - wxEmptyString, FIND_ROOT); - if( Entry != NULL ) - { - if ( Entry->m_UnitCount > 1 ) flag = 1; - } - } + FieldNumber = m_FieldId; + flag = 0; + if( FieldNumber == REFERENCE ) + { + Entry = FindLibPart( ( (EDA_SchComponentStruct*) m_Parent )->m_ChipName.GetData(), + wxEmptyString, FIND_ROOT ); + if( Entry != NULL ) + { + if( Entry->m_UnitCount > 1 ) + flag = 1; + } + } - DrawTextField(frame->DrawPanel, DC, this, flag, GR_DEFAULT_DRAWMODE); - m_Flags = 0; - frame->GetScreen()->m_CurrentItem = NULL; - frame->GetScreen()->SetModify(); - CurrentField = NULL; + DrawTextField( frame->DrawPanel, DC, this, flag, GR_DEFAULT_DRAWMODE ); + m_Flags = 0; + frame->GetScreen()->SetCurItem( NULL ); + frame->GetScreen()->SetModify(); + CurrentField = NULL; } - /**************************************************************************************************/ -void WinEDA_SchematicFrame::EditComponentReference(EDA_SchComponentStruct * DrawLibItem, wxDC * DC) +void WinEDA_SchematicFrame::EditComponentReference( EDA_SchComponentStruct* DrawLibItem, wxDC* DC ) /**************************************************************************************************/ /* Edit the component text reference*/ { -wxString msg; -EDA_LibComponentStruct *Entry; -int flag = 0; + wxString msg; + EDA_LibComponentStruct* Entry; + int flag = 0; - if( DrawLibItem == NULL ) return; + if( DrawLibItem == NULL ) + return; - Entry = FindLibPart(DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); - if ( Entry == NULL ) return; + Entry = FindLibPart( DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); + if( Entry == NULL ) + return; - if ( Entry->m_UnitCount > 1 ) flag = 1; + if( Entry->m_UnitCount > 1 ) + flag = 1; - PartTextStruct * TextField = &DrawLibItem->m_Field[REFERENCE]; + PartTextStruct* TextField = &DrawLibItem->m_Field[REFERENCE]; - msg = TextField->m_Text; - Get_Message(_("Reference") , msg, this); + msg = TextField->m_Text; + Get_Message( _( "Reference" ), msg, this ); - if ( ! msg.IsEmpty() ) // New text entered - { - DrawTextField(DrawPanel, DC, &DrawLibItem->m_Field[REFERENCE], flag, g_XorMode); - TextField->m_Text = msg; - DrawTextField(DrawPanel, DC, &DrawLibItem->m_Field[REFERENCE], flag, - DrawLibItem->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE); - GetScreen()->SetModify(); - } - DrawLibItem->Display_Infos(this); + if( !msg.IsEmpty() ) // New text entered + { + DrawTextField( DrawPanel, DC, &DrawLibItem->m_Field[REFERENCE], flag, g_XorMode ); + TextField->m_Text = msg; + DrawTextField( DrawPanel, DC, &DrawLibItem->m_Field[REFERENCE], flag, + DrawLibItem->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE ); + GetScreen()->SetModify(); + } + DrawLibItem->Display_Infos( this ); } + /*****************************************************************************************/ -void WinEDA_SchematicFrame::EditComponentValue(EDA_SchComponentStruct * DrawLibItem, wxDC * DC) +void WinEDA_SchematicFrame::EditComponentValue( EDA_SchComponentStruct* DrawLibItem, wxDC* DC ) /*****************************************************************************************/ /* Routine de changement du texte selectionne */ { -wxString msg; -EDA_LibComponentStruct *Entry; -int flag = 0; + wxString msg; + EDA_LibComponentStruct* Entry; + int flag = 0; - if( DrawLibItem == NULL ) return; + if( DrawLibItem == NULL ) + return; - Entry = FindLibPart(DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); - if ( Entry == NULL ) return; - if ( Entry->m_UnitCount > 1 ) flag = 1; + Entry = FindLibPart( DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); + if( Entry == NULL ) + return; + if( Entry->m_UnitCount > 1 ) + flag = 1; - PartTextStruct * TextField = &DrawLibItem->m_Field[VALUE]; + PartTextStruct* TextField = &DrawLibItem->m_Field[VALUE]; - msg = TextField->m_Text; - Get_Message(_("Value") , msg, this); + msg = TextField->m_Text; + Get_Message( _( "Value" ), msg, this ); - if ( ! msg.IsEmpty() ) - { - DrawTextField(DrawPanel, DC, &DrawLibItem->m_Field[VALUE], flag, g_XorMode); - TextField->m_Text = msg; - DrawTextField(DrawPanel, DC, &DrawLibItem->m_Field[VALUE], flag, - DrawLibItem->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE); - m_CurrentScreen->SetModify(); - } + if( !msg.IsEmpty() ) + { + DrawTextField( DrawPanel, DC, &DrawLibItem->m_Field[VALUE], flag, g_XorMode ); + TextField->m_Text = msg; + DrawTextField( DrawPanel, DC, &DrawLibItem->m_Field[VALUE], flag, + DrawLibItem->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE ); + m_CurrentScreen->SetModify(); + } - DrawLibItem->Display_Infos(this); + DrawLibItem->Display_Infos( this ); } + /*****************************************************************************/ void WinEDA_ComponentPropertiesFrame::SetInitCmp( wxCommandEvent& event ) /*****************************************************************************/ + /* Replace le composant en position normale, dimensions et positions - fields comme definies en librairie -*/ + * fields comme definies en librairie + */ { -EDA_LibComponentStruct *Entry; + EDA_LibComponentStruct* Entry; - if ( m_Cmp == NULL ) return; + if( m_Cmp == NULL ) + return; - Entry = FindLibPart(m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + Entry = FindLibPart( m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); - if( Entry == NULL) return; + if( Entry == NULL ) + return; -wxClientDC dc(m_Parent->DrawPanel); - m_Parent->DrawPanel->PrepareGraphicContext(&dc); + wxClientDC dc( m_Parent->DrawPanel ); + m_Parent->DrawPanel->PrepareGraphicContext( &dc ); - RedrawOneStruct(m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode); + RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode ); - /* Mise aux valeurs par defaut des champs et orientation */ - m_Cmp->m_Field[REFERENCE].m_Pos.x = - Entry->m_Prefix.m_Pos.x + m_Cmp->m_Pos.x; - m_Cmp->m_Field[REFERENCE].m_Pos.y = - Entry->m_Prefix.m_Pos.y + m_Cmp->m_Pos.y; - m_Cmp->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient; - m_Cmp->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size; - m_Cmp->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify; - m_Cmp->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify; + /* Mise aux valeurs par defaut des champs et orientation */ + m_Cmp->m_Field[REFERENCE].m_Pos.x = + Entry->m_Prefix.m_Pos.x + m_Cmp->m_Pos.x; + m_Cmp->m_Field[REFERENCE].m_Pos.y = + Entry->m_Prefix.m_Pos.y + m_Cmp->m_Pos.y; + m_Cmp->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient; + m_Cmp->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size; + m_Cmp->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify; + m_Cmp->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify; - m_Cmp->m_Field[VALUE].m_Pos.x = - Entry->m_Name.m_Pos.x + m_Cmp->m_Pos.x; - m_Cmp->m_Field[VALUE].m_Pos.y = - Entry->m_Name.m_Pos.y + m_Cmp->m_Pos.y; - m_Cmp->m_Field[VALUE].m_Orient = Entry->m_Name.m_Orient; - m_Cmp->m_Field[VALUE].m_Size = Entry->m_Name.m_Size; - m_Cmp->m_Field[VALUE].m_HJustify = Entry->m_Name.m_HJustify; - m_Cmp->m_Field[VALUE].m_VJustify = Entry->m_Name.m_VJustify; + m_Cmp->m_Field[VALUE].m_Pos.x = + Entry->m_Name.m_Pos.x + m_Cmp->m_Pos.x; + m_Cmp->m_Field[VALUE].m_Pos.y = + Entry->m_Name.m_Pos.y + m_Cmp->m_Pos.y; + m_Cmp->m_Field[VALUE].m_Orient = Entry->m_Name.m_Orient; + m_Cmp->m_Field[VALUE].m_Size = Entry->m_Name.m_Size; + m_Cmp->m_Field[VALUE].m_HJustify = Entry->m_Name.m_HJustify; + m_Cmp->m_Field[VALUE].m_VJustify = Entry->m_Name.m_VJustify; - m_Cmp->SetRotationMiroir(CMP_NORMAL); + m_Cmp->SetRotationMiroir( CMP_NORMAL ); - m_Parent->m_CurrentScreen->SetModify(); + m_Parent->m_CurrentScreen->SetModify(); - RedrawOneStruct(m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE); - Close(); + RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE ); + Close(); } - - diff --git a/eeschema/eeclass.cpp b/eeschema/eeclass.cpp index 95ea48b44c..3bce978a29 100644 --- a/eeschema/eeclass.cpp +++ b/eeschema/eeclass.cpp @@ -15,104 +15,107 @@ /************************************************************/ -void SetStructFather(EDA_BaseStruct * Struct, BASE_SCREEN * Screen) +void SetStructFather( EDA_BaseStruct* Struct, BASE_SCREEN* Screen ) /************************************************************/ { - switch( Struct->m_StructType ) - { - case DRAW_POLYLINE_STRUCT_TYPE: - case DRAW_JUNCTION_STRUCT_TYPE: - case DRAW_TEXT_STRUCT_TYPE: - case DRAW_LABEL_STRUCT_TYPE: - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - case DRAW_LIB_ITEM_STRUCT_TYPE: - case DRAW_SEGMENT_STRUCT_TYPE: - case DRAW_BUSENTRY_STRUCT_TYPE: - case DRAW_SHEET_STRUCT_TYPE: - case DRAW_MARKER_STRUCT_TYPE: - case DRAW_NOCONNECT_STRUCT_TYPE: - Struct->m_Parent = Screen; - break; + switch( Struct->m_StructType ) + { + case DRAW_POLYLINE_STRUCT_TYPE: + case DRAW_JUNCTION_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_LIB_ITEM_STRUCT_TYPE: + case DRAW_SEGMENT_STRUCT_TYPE: + case DRAW_BUSENTRY_STRUCT_TYPE: + case DRAW_SHEET_STRUCT_TYPE: + case DRAW_MARKER_STRUCT_TYPE: + case DRAW_NOCONNECT_STRUCT_TYPE: + Struct->m_Parent = Screen; + break; - case DRAW_SHEETLABEL_STRUCT_TYPE: - case DRAW_PICK_ITEM_STRUCT_TYPE: - break; + case DRAW_SHEETLABEL_STRUCT_TYPE: + case DRAW_PICK_ITEM_STRUCT_TYPE: + break; - default: - break; - } + default: + break; + } } + /*************************************************************/ -void EDA_BaseStruct::Place(WinEDA_DrawFrame * frame, wxDC * DC) +void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) /*************************************************************/ { - if( m_Flags & IS_NEW) - { - Pnext = frame->m_CurrentScreen->EEDrawList; - frame->m_CurrentScreen->EEDrawList = this; - g_ItemToRepeat = this; - } + if( m_Flags & IS_NEW ) + { + Pnext = frame->m_CurrentScreen->EEDrawList; + frame->m_CurrentScreen->EEDrawList = this; + g_ItemToRepeat = this; + } - m_Flags = 0; - SetFlagModify(frame->GetScreen()); - frame->GetScreen()->m_CurrentItem = NULL; - frame->DrawPanel->ManageCurseur = NULL; - frame->DrawPanel->ForceCloseManageCurseur = NULL; + m_Flags = 0; + SetFlagModify( frame->GetScreen() ); + frame->GetScreen()->SetCurItem( NULL ); + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; - frame->DrawPanel->CursorOff(DC); // Erase schematic cursor - RedrawOneStruct(frame->DrawPanel, DC, this, GR_DEFAULT_DRAWMODE); - frame->DrawPanel->CursorOn(DC); // Display schematic cursor + frame->DrawPanel->CursorOff( DC ); // Erase schematic cursor + RedrawOneStruct( frame->DrawPanel, DC, this, GR_DEFAULT_DRAWMODE ); + frame->DrawPanel->CursorOn( DC ); // Display schematic cursor } - /**************************************************/ - /* Class SCH_SCREEN: classe de gestion d'un affichage pour schematique */ - /***************************************************/ -static int table_zoom[] = {1,2,4,8,16,32,64,128, 0}; /* Valeurs standards du zoom */ +/**************************************************/ +/* Class SCH_SCREEN: classe de gestion d'un affichage pour schematique */ +/***************************************************/ +static int table_zoom[] = { 1, 2, 4, 8, 16, 32, 64, 128, 0 }; /* Valeurs standards du zoom */ /* Constructeur de SCREEN */ -SCH_SCREEN::SCH_SCREEN(EDA_BaseStruct * parent, WinEDA_DrawFrame * frame_source, int idtype): - BASE_SCREEN(parent, frame_source, idtype) +SCH_SCREEN::SCH_SCREEN( EDA_BaseStruct* parent, WinEDA_DrawFrame* frame_source, int idtype ) : + BASE_SCREEN( parent, frame_source, idtype ) { - EEDrawList = NULL; /* Schematic items list */ - m_Zoom = 32; - m_Grid = wxSize(50,50); /* pas de la grille */ - SetZoomList(table_zoom); - SetGridList(g_GridList); - m_UndoRedoCountMax = 10; - + EEDrawList = NULL; /* Schematic items list */ + m_Zoom = 32; + m_Grid = wxSize( 50, 50 ); /* pas de la grille */ + SetZoomList( table_zoom ); + SetGridList( g_GridList ); + m_UndoRedoCountMax = 10; } + /****************************/ -SCH_SCREEN::~SCH_SCREEN(void) +SCH_SCREEN::~SCH_SCREEN( void ) /****************************/ { - ClearUndoRedoList(); - FreeDrawList(); + ClearUndoRedoList(); + FreeDrawList(); } + /*************************************/ -SCH_SCREEN * SCH_SCREEN::GenCopy(void) +SCH_SCREEN* SCH_SCREEN::GenCopy( void ) /*************************************/ { // TODO - return NULL; + return NULL; } + /***********************************/ -void SCH_SCREEN::FreeDrawList(void) +void SCH_SCREEN::FreeDrawList( void ) /***********************************/ + /* Routine to clear EESchema drawing list of a screen. -*/ + */ { -EDA_BaseStruct *DrawStruct; + EDA_BaseStruct* DrawStruct; - while (EEDrawList != NULL) - { - DrawStruct = EEDrawList; - EEDrawList = EEDrawList->Pnext; - delete DrawStruct; - } + while( EEDrawList != NULL ) + { + DrawStruct = EEDrawList; + EEDrawList = EEDrawList->Pnext; + delete DrawStruct; + } } - diff --git a/eeschema/eecreate.cpp b/eeschema/eecreate.cpp index 6d34332e05..4d884d8da4 100644 --- a/eeschema/eecreate.cpp +++ b/eeschema/eecreate.cpp @@ -14,518 +14,544 @@ /* Routines Locales */ -static void Polyline_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); -static void Segment_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); -static void ExitTrace(WinEDA_DrawFrame * frame, wxDC * DC); -static bool IsTerminalPoint(SCH_SCREEN * screen, const wxPoint & pos, int layer ); +static void Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); +static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); +static void ExitTrace( WinEDA_DrawFrame* frame, wxDC* DC ); +static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ); /*************************************************************/ -void WinEDA_SchematicFrame::BeginSegment(wxDC * DC, int type) +void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) /*************************************************************/ + /* Routine de Trace de segments ( WIRES, BUS ) pour lesquels chaque segment -est une structure. -*/ + * est une structure. + */ { -DrawSegmentStruct * oldsegment, * newsegment; -wxPoint pos = GetScreen()->m_Curseur; + DrawSegmentStruct* oldsegment, * newsegment; + wxPoint pos = GetScreen()->m_Curseur; - if ( GetScreen()->m_CurrentItem && - (GetScreen()->m_CurrentItem->m_Flags == 0) ) - GetScreen()->m_CurrentItem = NULL; + if( GetScreen()->GetCurItem() + && (GetScreen()->GetCurItem()->m_Flags == 0) ) + GetScreen()->SetCurItem( NULL ); - if ( GetScreen()->m_CurrentItem ) - { - switch (GetScreen()->m_CurrentItem->m_StructType ) - { - case DRAW_SEGMENT_STRUCT_TYPE: - case DRAW_POLYLINE_STRUCT_TYPE: - break; + if( GetScreen()->GetCurItem() ) + { + switch( GetScreen()->GetCurItem()->m_StructType ) + { + case DRAW_SEGMENT_STRUCT_TYPE: + case DRAW_POLYLINE_STRUCT_TYPE: + break; - default: - return; - } - } + default: + return; + } + } - oldsegment = newsegment = - (DrawSegmentStruct *) GetScreen()->m_CurrentItem; + oldsegment = newsegment = + (DrawSegmentStruct*) GetScreen()->GetCurItem(); - if (!newsegment) /* 1er point : creation de la 1ere structure */ - { + if( !newsegment ) /* 1er point : creation de la 1ere structure */ + { + switch( type ) + { + default: + newsegment = new DrawSegmentStruct( pos, LAYER_NOTES ); + break; - switch(type) - { - default: - newsegment = new DrawSegmentStruct(pos, LAYER_NOTES); - break; - case LAYER_WIRE: - newsegment = new DrawSegmentStruct(pos, LAYER_WIRE); - if ( LocatePinEnd(GetScreen()->EEDrawList, pos) ) - newsegment->m_StartIsDangling = FALSE; - break; - case LAYER_BUS: - newsegment = new DrawSegmentStruct(pos, LAYER_BUS); - break; - } + case LAYER_WIRE: + newsegment = new DrawSegmentStruct( pos, LAYER_WIRE ); + if( LocatePinEnd( GetScreen()->EEDrawList, pos ) ) + newsegment->m_StartIsDangling = FALSE; + break; - newsegment->m_Flags = IS_NEW; - GetScreen()->m_CurrentItem = newsegment; - GetScreen()->ManageCurseur = Segment_in_Ghost; - GetScreen()->ForceCloseManageCurseur = ExitTrace; - g_ItemToRepeat = NULL; - } + case LAYER_BUS: + newsegment = new DrawSegmentStruct( pos, LAYER_BUS ); + break; + } - else /* Trace en cours: Placement d'un point supplementaire */ - { - if( (oldsegment->m_Start.x == oldsegment->m_End.x) && - (oldsegment->m_Start.y == oldsegment->m_End.y) ) /* Structure inutile */ - return; - GetScreen()->ManageCurseur(DrawPanel, DC, FALSE); - oldsegment->m_EndIsDangling = FALSE; + newsegment->m_Flags = IS_NEW; + GetScreen()->SetCurItem( newsegment ); + GetScreen()->ManageCurseur = Segment_in_Ghost; + GetScreen()->ForceCloseManageCurseur = ExitTrace; + g_ItemToRepeat = NULL; + } + else /* Trace en cours: Placement d'un point supplementaire */ + { + if( (oldsegment->m_Start.x == oldsegment->m_End.x) + && (oldsegment->m_Start.y == oldsegment->m_End.y) ) /* Structure inutile */ + return; + GetScreen()->ManageCurseur( DrawPanel, DC, FALSE ); + oldsegment->m_EndIsDangling = FALSE; - /* Creation du segment suivant ou fin de trac� si point sur pin, jonction ...*/ - if ( IsTerminalPoint(GetScreen(), oldsegment->m_End, oldsegment->m_Layer) ) - { - EndSegment(DC); return; - } + /* Creation du segment suivant ou fin de trac� si point sur pin, jonction ...*/ + if( IsTerminalPoint( GetScreen(), oldsegment->m_End, oldsegment->m_Layer ) ) + { + EndSegment( DC ); return; + } - /* Placement en liste generale */ - oldsegment->Pnext = GetScreen()->EEDrawList; - g_ItemToRepeat = GetScreen()->EEDrawList = oldsegment; - GetScreen()->CursorOff(DrawPanel, DC); // Erase schematic cursor - RedrawOneStruct(DrawPanel,DC, oldsegment, GR_DEFAULT_DRAWMODE); - GetScreen()->CursorOn(DrawPanel, DC); // Display schematic cursor + /* Placement en liste generale */ + oldsegment->Pnext = GetScreen()->EEDrawList; + g_ItemToRepeat = GetScreen()->EEDrawList = oldsegment; + GetScreen()->CursorOff( DrawPanel, DC ); // Erase schematic cursor + RedrawOneStruct( DrawPanel, DC, oldsegment, GR_DEFAULT_DRAWMODE ); + GetScreen()->CursorOn( DrawPanel, DC ); // Display schematic cursor - /* Creation du segment suivant */ - newsegment = oldsegment->GenCopy(); - newsegment->m_Start = oldsegment->m_End; - newsegment->m_End = pos; - oldsegment->m_Flags = 0; - newsegment->m_Flags = IS_NEW; - GetScreen()->m_CurrentItem = newsegment; - GetScreen()->ManageCurseur(DrawPanel, DC, FALSE); - newsegment->m_StartIsDangling = FALSE; - newsegment->m_EndIsDangling = TRUE; - } + /* Creation du segment suivant */ + newsegment = oldsegment->GenCopy(); + newsegment->m_Start = oldsegment->m_End; + newsegment->m_End = pos; + oldsegment->m_Flags = 0; + newsegment->m_Flags = IS_NEW; + GetScreen()->SetCurItem( newsegment ); + GetScreen()->ManageCurseur( DrawPanel, DC, FALSE ); + newsegment->m_StartIsDangling = FALSE; + newsegment->m_EndIsDangling = TRUE; + } } /*************************************************************/ /* Routine de fin de trace d'une struct segment (Wire, Bus */ /*************************************************************/ -void WinEDA_SchematicFrame::EndSegment(wxDC *DC) +void WinEDA_SchematicFrame::EndSegment( wxDC* DC ) { -DrawSegmentStruct * segment = (DrawSegmentStruct *)GetScreen()->m_CurrentItem; + DrawSegmentStruct* segment = (DrawSegmentStruct*) GetScreen()->GetCurItem(); - if ( GetScreen()->ManageCurseur == NULL ) return; - if ( segment == NULL ) return; - if ( (segment->m_Flags & IS_NEW) == 0) return; + if( GetScreen()->ManageCurseur == NULL ) + return; + if( segment == NULL ) + return; + if( (segment->m_Flags & IS_NEW) == 0 ) + return; - if( (segment->m_Start.x == segment->m_End.x) && - (segment->m_Start.y == segment->m_End.y) ) /* Structure inutile */ - { - EraseStruct(segment, (SCH_SCREEN*)GetScreen()); - segment = NULL; - } + if( (segment->m_Start.x == segment->m_End.x) + && (segment->m_Start.y == segment->m_End.y) )/* Structure inutile */ + { + EraseStruct( segment, (SCH_SCREEN*) GetScreen() ); + segment = NULL; + } + else + { + /* Placement en liste generale */ + GetScreen()->ManageCurseur( DrawPanel, DC, FALSE ); + segment->Pnext = GetScreen()->EEDrawList; + g_ItemToRepeat = GetScreen()->EEDrawList = segment; + segment->m_Flags = 0; + } - else - { /* Placement en liste generale */ - GetScreen()->ManageCurseur(DrawPanel, DC, FALSE); - segment->Pnext = GetScreen()->EEDrawList; - g_ItemToRepeat = GetScreen()->EEDrawList = segment; - segment->m_Flags = 0; - } + /* Fin de trace */ + GetScreen()->ManageCurseur = NULL; + GetScreen()->ForceCloseManageCurseur = NULL; + GetScreen()->SetCurItem( NULL ); - /* Fin de trace */ - GetScreen()->ManageCurseur = NULL; - GetScreen()->ForceCloseManageCurseur = NULL; - GetScreen()->m_CurrentItem = NULL; - - TestDanglingEnds(GetScreen()->EEDrawList, DC); - SetFlagModify(GetScreen()); - if( segment ) - { - GetScreen()->CursorOff(DrawPanel, DC); // Erase schematic cursor - RedrawOneStruct(DrawPanel,DC, segment, GR_DEFAULT_DRAWMODE); - GetScreen()->CursorOn(DrawPanel, DC); // Display schematic cursor - } + TestDanglingEnds( GetScreen()->EEDrawList, DC ); + SetFlagModify( GetScreen() ); + if( segment ) + { + GetScreen()->CursorOff( DrawPanel, DC ); // Erase schematic cursor + RedrawOneStruct( DrawPanel, DC, segment, GR_DEFAULT_DRAWMODE ); + GetScreen()->CursorOn( DrawPanel, DC ); // Display schematic cursor + } } + /****************************************************************************/ -static void Segment_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /****************************************************************************/ + /* Dessin du Segment Fantome lors des deplacements du curseur -*/ + */ { -DrawSegmentStruct * segment = - (DrawSegmentStruct *) panel->m_Parent->GetScreen()->m_CurrentItem; -wxPoint endpos; -int color; + DrawSegmentStruct* segment = + (DrawSegmentStruct*) panel->m_Parent->GetScreen()->GetCurItem(); + wxPoint endpos; + int color; - if ( segment == NULL ) return; + if( segment == NULL ) + return; - color = ReturnLayerColor(segment->m_Layer) ^ HIGHT_LIGHT_FLAG; + color = ReturnLayerColor( segment->m_Layer ) ^ HIGHT_LIGHT_FLAG; - endpos = panel->m_Parent->GetScreen()->m_Curseur; + endpos = panel->m_Parent->GetScreen()->m_Curseur; - if( g_HVLines ) /* Coerce the line to vertical or horizontal one: */ - { - if (ABS(endpos.x - segment->m_Start.x) < ABS(endpos.y - segment->m_Start.y)) - endpos.x = segment->m_Start.x; - else - endpos.y = segment->m_Start.y; - } + if( g_HVLines ) /* Coerce the line to vertical or horizontal one: */ + { + if( ABS( endpos.x - segment->m_Start.x ) < ABS( endpos.y - segment->m_Start.y ) ) + endpos.x = segment->m_Start.x; + else + endpos.y = segment->m_Start.y; + } - if( erase ) // Redraw if segment lengtht != 0 - { - if ( (segment->m_Start.x != segment->m_End.x) || - (segment->m_Start.y != segment->m_End.y) ) - RedrawOneStruct(panel,DC, segment, XOR_MODE, color); - } - segment->m_End = endpos; - // Redraw if segment lengtht != 0 + if( erase ) // Redraw if segment lengtht != 0 + { + if( (segment->m_Start.x != segment->m_End.x) + || (segment->m_Start.y != segment->m_End.y) ) + RedrawOneStruct( panel, DC, segment, XOR_MODE, color ); + } + segment->m_End = endpos; - if ( (segment->m_Start.x != segment->m_End.x) || - (segment->m_Start.y != segment->m_End.y) ) - RedrawOneStruct(panel,DC, segment, XOR_MODE,color); + // Redraw if segment lengtht != 0 + + if( (segment->m_Start.x != segment->m_End.x) + || (segment->m_Start.y != segment->m_End.y) ) + RedrawOneStruct( panel, DC, segment, XOR_MODE, color ); } + /*****************************************************************************/ -static void Polyline_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +static void Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /*****************************************************************************/ + /* Dessin du du Polyline Fantome lors des deplacements du curseur -*/ + */ { -DrawPolylineStruct * NewPoly = - (DrawPolylineStruct *)panel->m_Parent->GetScreen()->m_CurrentItem; -int color; -wxPoint endpos; + DrawPolylineStruct* NewPoly = + (DrawPolylineStruct*) panel->m_Parent->GetScreen()->GetCurItem(); + int color; + wxPoint endpos; - endpos = panel->m_Parent->GetScreen()->m_Curseur; - color = ReturnLayerColor(NewPoly->m_Layer); + endpos = panel->m_Parent->GetScreen()->m_Curseur; + color = ReturnLayerColor( NewPoly->m_Layer ); - GRSetDrawMode(DC, XOR_MODE); + GRSetDrawMode( DC, XOR_MODE ); - if( g_HVLines ) - { - /* Coerce the line to vertical or horizontal one: */ - if (ABS(endpos.x - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2]) < - ABS(endpos.y - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1])) - endpos.x = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2]; - else - endpos.y = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1]; - } + if( g_HVLines ) + { + /* Coerce the line to vertical or horizontal one: */ + if( ABS( endpos.x - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2] ) < + ABS( endpos.y - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1] ) ) + endpos.x = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2]; + else + endpos.y = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1]; + } - NewPoly->m_NumOfPoints++; - if( erase ) - RedrawOneStruct(panel,DC, NewPoly, XOR_MODE, color); + NewPoly->m_NumOfPoints++; + if( erase ) + RedrawOneStruct( panel, DC, NewPoly, XOR_MODE, color ); - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2] = endpos.x; - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1] = endpos.y; - RedrawOneStruct(panel,DC, NewPoly, XOR_MODE, color); - NewPoly->m_NumOfPoints--; + NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2] = endpos.x; + NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1] = endpos.y; + RedrawOneStruct( panel, DC, NewPoly, XOR_MODE, color ); + NewPoly->m_NumOfPoints--; } + /**********************************************************/ -void WinEDA_SchematicFrame::DeleteCurrentSegment(wxDC * DC) +void WinEDA_SchematicFrame::DeleteCurrentSegment( wxDC* DC ) /**********************************************************/ + /* -Routine effacant le dernier trait trace, ou l'element pointe par la souris -*/ + * Routine effacant le dernier trait trace, ou l'element pointe par la souris + */ { + g_ItemToRepeat = NULL; - g_ItemToRepeat = NULL; + if( (GetScreen()->GetCurItem() == NULL) + || ( (GetScreen()->GetCurItem()->m_Flags & IS_NEW) == 0 ) ) + { + return; + } - if( (GetScreen()->m_CurrentItem == NULL) || - ((GetScreen()->m_CurrentItem->m_Flags & IS_NEW) == 0) ) - { - return; - } + /* Trace en cours: annulation */ + if( GetScreen()->GetCurItem()->m_StructType == DRAW_POLYLINE_STRUCT_TYPE ) + { + Polyline_in_Ghost( DrawPanel, DC, FALSE ); /* Effacement du trace en cours */ + } + else + { + Segment_in_Ghost( DrawPanel, DC, FALSE ); /* Effacement du trace en cours */ + } - /* Trace en cours: annulation */ - if (GetScreen()->m_CurrentItem->m_StructType == DRAW_POLYLINE_STRUCT_TYPE) - { - Polyline_in_Ghost(DrawPanel, DC, FALSE); /* Effacement du trace en cours */ - } - - else - { - Segment_in_Ghost(DrawPanel, DC, FALSE); /* Effacement du trace en cours */ - } - - EraseStruct(GetScreen()->m_CurrentItem, GetScreen()); - GetScreen()->ManageCurseur = NULL; - GetScreen()->m_CurrentItem = NULL; + EraseStruct( GetScreen()->GetCurItem(), GetScreen() ); + GetScreen()->ManageCurseur = NULL; + GetScreen()->SetCurItem( NULL ); } /***************************************************************************/ -EDA_BaseStruct * WinEDA_SchematicFrame::CreateNewJunctionStruct(wxDC * DC) +EDA_BaseStruct* WinEDA_SchematicFrame::CreateNewJunctionStruct( wxDC* DC ) /***************************************************************************/ + /* Routine to create new connection struct. -*/ + */ { -DrawJunctionStruct *NewConnect; + DrawJunctionStruct* NewConnect; - NewConnect = new DrawJunctionStruct(GetScreen()->m_Curseur); + NewConnect = new DrawJunctionStruct( GetScreen()->m_Curseur ); - g_ItemToRepeat = NewConnect; + g_ItemToRepeat = NewConnect; - GetScreen()->CursorOff(DrawPanel, DC); // Erase schematic cursor - RedrawOneStruct(DrawPanel,DC, NewConnect, GR_DEFAULT_DRAWMODE); - GetScreen()->CursorOn(DrawPanel, DC); // Display schematic cursor + GetScreen()->CursorOff( DrawPanel, DC ); // Erase schematic cursor + RedrawOneStruct( DrawPanel, DC, NewConnect, GR_DEFAULT_DRAWMODE ); + GetScreen()->CursorOn( DrawPanel, DC ); // Display schematic cursor - NewConnect->Pnext = GetScreen()->EEDrawList; - GetScreen()->EEDrawList = NewConnect; - SetFlagModify(GetScreen()); - return(NewConnect); + NewConnect->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = NewConnect; + SetFlagModify( GetScreen() ); + return NewConnect; } + /*************************************************************************/ -EDA_BaseStruct *WinEDA_SchematicFrame::CreateNewNoConnectStruct(wxDC * DC) +EDA_BaseStruct* WinEDA_SchematicFrame::CreateNewNoConnectStruct( wxDC* DC ) /*************************************************************************/ + /*Routine to create new NoConnect struct. ( Symbole de Non Connexion) -*/ + */ { -DrawNoConnectStruct *NewNoConnect; + DrawNoConnectStruct* NewNoConnect; - NewNoConnect = new DrawNoConnectStruct(GetScreen()->m_Curseur); - g_ItemToRepeat = NewNoConnect; + NewNoConnect = new DrawNoConnectStruct( GetScreen()->m_Curseur ); + g_ItemToRepeat = NewNoConnect; - GetScreen()->CursorOff(DrawPanel, DC); // Erase schematic cursor - RedrawOneStruct(DrawPanel,DC, NewNoConnect, GR_DEFAULT_DRAWMODE); - GetScreen()->CursorOn(DrawPanel, DC); // Display schematic cursor + GetScreen()->CursorOff( DrawPanel, DC ); // Erase schematic cursor + RedrawOneStruct( DrawPanel, DC, NewNoConnect, GR_DEFAULT_DRAWMODE ); + GetScreen()->CursorOn( DrawPanel, DC ); // Display schematic cursor - NewNoConnect->Pnext = GetScreen()->EEDrawList; - GetScreen()->EEDrawList = NewNoConnect; - SetFlagModify(GetScreen()); - return(NewNoConnect); + NewNoConnect->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = NewNoConnect; + SetFlagModify( GetScreen() ); + return NewNoConnect; } /**********************************************************/ -static void ExitTrace(WinEDA_DrawFrame * frame, wxDC * DC) +static void ExitTrace( WinEDA_DrawFrame* frame, wxDC* DC ) /**********************************************************/ /* Routine de sortie des menus de trace */ { -BASE_SCREEN * Screen = frame->GetScreen(); + BASE_SCREEN* Screen = frame->GetScreen(); - if( Screen->m_CurrentItem) /* trace en cours */ - { - Screen->ManageCurseur(frame->DrawPanel, DC, FALSE); - Screen->ManageCurseur = NULL; - Screen->ForceCloseManageCurseur = NULL; - EraseStruct(Screen->m_CurrentItem,(SCH_SCREEN*) Screen); - Screen->m_CurrentItem = NULL; - return; - } - - else g_ItemToRepeat = NULL; // Fin de commande generale + if( Screen->GetCurItem() ) /* trace en cours */ + { + Screen->ManageCurseur( frame->DrawPanel, DC, FALSE ); + Screen->ManageCurseur = NULL; + Screen->ForceCloseManageCurseur = NULL; + EraseStruct( Screen->GetCurItem(), (SCH_SCREEN*) Screen ); + Screen->SetCurItem( NULL ); + return; + } + else + g_ItemToRepeat = NULL; // Fin de commande generale } /***************************************************/ -void WinEDA_SchematicFrame::RepeatDrawItem(wxDC *DC) +void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) /***************************************************/ + /* Routine de recopie du dernier element dessine - Les elements duplicables sont - fils, bus, traits, textes, labels - Les labels termines par un nombre seront incrementes -*/ + * Les elements duplicables sont + * fils, bus, traits, textes, labels + * Les labels termines par un nombre seront incrementes + */ { -char Line[256]; -int ox = 0, oy = 0; + char Line[256]; + int ox = 0, oy = 0; - if( g_ItemToRepeat == NULL ) return; + if( g_ItemToRepeat == NULL ) + return; - switch( g_ItemToRepeat->m_StructType ) - { - case DRAW_JUNCTION_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawJunctionStruct*) g_ItemToRepeat) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; - STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; - break; + switch( g_ItemToRepeat->m_StructType ) + { + case DRAW_JUNCTION_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawJunctionStruct*) g_ItemToRepeat ) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; + STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; + break; - case DRAW_NOCONNECT_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawNoConnectStruct*) g_ItemToRepeat) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; - STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; - break; + case DRAW_NOCONNECT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawNoConnectStruct*) g_ItemToRepeat ) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; + STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; + break; - case DRAW_TEXT_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawTextStruct*) g_ItemToRepeat) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; - STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; - /*** Increment du numero de label ***/ - strcpy(Line,STRUCT->GetText()); - IncrementLabelMember(Line); - STRUCT->m_Text = Line; - break; - - - case DRAW_LABEL_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawLabelStruct*) g_ItemToRepeat) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; - STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; - /*** Increment du numero de label ***/ - strcpy(Line,STRUCT->GetText()); - IncrementLabelMember(Line); - STRUCT->m_Text = Line; - break; + case DRAW_TEXT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawTextStruct*) g_ItemToRepeat ) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; + STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; + /*** Increment du numero de label ***/ + strcpy( Line, STRUCT->GetText() ); + IncrementLabelMember( Line ); + STRUCT->m_Text = Line; + break; - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawGlobalLabelStruct*) g_ItemToRepeat) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; - STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; - /*** Increment du numero de label ***/ - strcpy(Line,STRUCT->GetText()); - IncrementLabelMember(Line); - STRUCT->m_Text = Line; - break; + case DRAW_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawLabelStruct*) g_ItemToRepeat ) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; + STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; + /*** Increment du numero de label ***/ + strcpy( Line, STRUCT->GetText() ); + IncrementLabelMember( Line ); + STRUCT->m_Text = Line; + break; - case DRAW_SEGMENT_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawSegmentStruct*) g_ItemToRepeat) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Start.x += g_RepeatStep.x; ox = STRUCT->m_Start.x; - STRUCT->m_Start.y += g_RepeatStep.y; oy = STRUCT->m_Start.y; - STRUCT->m_End.x += g_RepeatStep.x; - STRUCT->m_End.y += g_RepeatStep.y; - break; - case DRAW_RACCORD_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ((DrawRaccordStruct*) g_ItemToRepeat) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; - STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; - break; + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawGlobalLabelStruct*) g_ItemToRepeat ) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; + STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; + /*** Increment du numero de label ***/ + strcpy( Line, STRUCT->GetText() ); + IncrementLabelMember( Line ); + STRUCT->m_Text = Line; + break; - default: - g_ItemToRepeat = NULL; - DisplayError(this, "Repeat Type Error", 10); - break; - } + case DRAW_SEGMENT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawSegmentStruct*) g_ItemToRepeat ) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Start.x += g_RepeatStep.x; ox = STRUCT->m_Start.x; + STRUCT->m_Start.y += g_RepeatStep.y; oy = STRUCT->m_Start.y; + STRUCT->m_End.x += g_RepeatStep.x; + STRUCT->m_End.y += g_RepeatStep.y; + break; - if ( g_ItemToRepeat ) - { - g_ItemToRepeat->Pnext = GetScreen()->EEDrawList; - GetScreen()->EEDrawList = g_ItemToRepeat; - TestDanglingEnds(GetScreen()->EEDrawList, NULL); - RedrawOneStruct(DrawPanel,DC, g_ItemToRepeat, GR_DEFAULT_DRAWMODE); -// GetScreen()->Curseur.x = ox; GetScreen()->Curseur.x = oy; + case DRAW_RACCORD_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ( (DrawRaccordStruct*) g_ItemToRepeat ) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; + STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; + break; + + default: + g_ItemToRepeat = NULL; + DisplayError( this, "Repeat Type Error", 10 ); + break; + } + + if( g_ItemToRepeat ) + { + g_ItemToRepeat->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = g_ItemToRepeat; + TestDanglingEnds( GetScreen()->EEDrawList, NULL ); + RedrawOneStruct( DrawPanel, DC, g_ItemToRepeat, GR_DEFAULT_DRAWMODE ); + +// GetScreen()->Curseur.x = ox; GetScreen()->Curseur.x = oy; // GRMouseWarp(DrawPanel, DrawPanel->CursorScreenPosition() ); - } + } } /******************************************/ -void IncrementLabelMember(char * Line) +void IncrementLabelMember( char* Line ) /******************************************/ + /* Routine incrementant les labels, c'est a dire pour les textes finissant -par un nombre, ajoutant <RepeatDeltaLabel> a ce nombre -*/ + * par un nombre, ajoutant <RepeatDeltaLabel> a ce nombre + */ { -char * strnum; -int ii; + char* strnum; + int ii; - strnum = Line + strlen(Line) - 1; - if( !isdigit(*strnum) ) return; + strnum = Line + strlen( Line ) - 1; + if( !isdigit( *strnum ) ) + return; - while( (strnum >= Line) && isdigit(*strnum) ) strnum--; - strnum++; /* pointe le debut de la chaine des digits */ - ii = atoi(strnum) + g_RepeatDeltaLabel; - sprintf(strnum, "%d", ii); + while( (strnum >= Line) && isdigit( *strnum ) ) + strnum--; + + strnum++; /* pointe le debut de la chaine des digits */ + ii = atoi( strnum ) + g_RepeatDeltaLabel; + sprintf( strnum, "%d", ii ); } + /***************************************************************************/ -static bool IsTerminalPoint(SCH_SCREEN * screen, const wxPoint & pos, int layer) +static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ) /***************************************************************************/ + /* Returne TRUE si pos est un point possible pour terminer automatiquement un -segment, c'est a dire pour - - type WIRE, si il y a - - une jonction - - ou une pin - - ou une extr�mit� unique de fil - - - type BUS, si il y a - - ou une extr�mit� unique de BUS -*/ + * segment, c'est a dire pour + * - type WIRE, si il y a + * - une jonction + * - ou une pin + * - ou une extr�mit� unique de fil + * + * - type BUS, si il y a + * - ou une extr�mit� unique de BUS + */ { -EDA_BaseStruct * item; -LibDrawPin * pin; -DrawLibItemStruct * LibItem = NULL; -DrawSheetLabelStruct * pinsheet; -wxPoint itempos; + EDA_BaseStruct* item; + LibDrawPin* pin; + DrawLibItemStruct* LibItem = NULL; + DrawSheetLabelStruct* pinsheet; + wxPoint itempos; - switch ( layer ) - { - case LAYER_BUS: - item = PickStruct(screen, BUSITEM); - if ( item ) return TRUE; - pinsheet = LocateAnyPinSheet(pos, screen->EEDrawList ); - if ( pinsheet && IsBusLabel(pinsheet->GetText()) ) - { - itempos = pinsheet->m_Pos; - if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE; - } - break; + switch( layer ) + { + case LAYER_BUS: + item = PickStruct( screen, BUSITEM ); + if( item ) + return TRUE; + pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList ); + if( pinsheet && IsBusLabel( pinsheet->GetText() ) ) + { + itempos = pinsheet->m_Pos; + if( (itempos.x == pos.x) && (itempos.y == pos.y) ) + return TRUE; + } + break; - case LAYER_NOTES: - item = PickStruct(screen, DRAWITEM); - if ( item ) - return TRUE; - break; + case LAYER_NOTES: + item = PickStruct( screen, DRAWITEM ); + if( item ) + return TRUE; + break; - case LAYER_WIRE: - item = PickStruct(screen, RACCORDITEM |JUNCTIONITEM); - if ( item ) return TRUE; + case LAYER_WIRE: + item = PickStruct( screen, RACCORDITEM | JUNCTIONITEM ); + if( item ) + return TRUE; - pin = LocateAnyPin( screen->EEDrawList, pos, &LibItem ); - if ( pin && LibItem ) - { - // calcul de la position exacte du point de connexion de la pin, - // selon orientation du composant: - itempos = LibItem->GetScreenCoord(pin->m_Pos); - itempos.x += LibItem->m_Pos.x; - itempos.y += LibItem->m_Pos.y; - if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE; - } + pin = LocateAnyPin( screen->EEDrawList, pos, &LibItem ); + if( pin && LibItem ) + { + // calcul de la position exacte du point de connexion de la pin, + // selon orientation du composant: + itempos = LibItem->GetScreenCoord( pin->m_Pos ); + itempos.x += LibItem->m_Pos.x; + itempos.y += LibItem->m_Pos.y; + if( (itempos.x == pos.x) && (itempos.y == pos.y) ) + return TRUE; + } - item = PickStruct(screen, WIREITEM); - if ( item ) return TRUE; + item = PickStruct( screen, WIREITEM ); + if( item ) + return TRUE; - item = PickStruct(screen, LABELITEM); - if ( item && (item->m_StructType != DRAW_TEXT_STRUCT_TYPE) && - ( ((DrawGlobalLabelStruct*)item)->m_Pos.x == pos.x) && - ( ((DrawGlobalLabelStruct*)item)->m_Pos.y == pos.y) ) - return TRUE; + item = PickStruct( screen, LABELITEM ); + if( item && (item->m_StructType != DRAW_TEXT_STRUCT_TYPE) + && ( ( (DrawGlobalLabelStruct*) item )->m_Pos.x == pos.x ) + && ( ( (DrawGlobalLabelStruct*) item )->m_Pos.y == pos.y ) ) + return TRUE; - pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList ); - if ( pinsheet && ! IsBusLabel(pinsheet->GetText()) ) - { - itempos = pinsheet->m_Pos; - if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE; - } + pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList ); + if( pinsheet && !IsBusLabel( pinsheet->GetText() ) ) + { + itempos = pinsheet->m_Pos; + if( (itempos.x == pos.x) && (itempos.y == pos.y) ) + return TRUE; + } - break; + break; - default: - break; - } + default: + break; + } - return FALSE; + return FALSE; } - - diff --git a/eeschema/eeload.cpp b/eeschema/eeload.cpp index ab7818e6fc..aa263b4944 100644 --- a/eeschema/eeload.cpp +++ b/eeschema/eeload.cpp @@ -1,6 +1,6 @@ - /****************************************/ - /* Module to load/save EESchema files. */ - /****************************************/ +/****************************************/ +/* Module to load/save EESchema files. */ +/****************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -15,184 +15,193 @@ #include "id.h" -static void LoadSubHierarchy(WinEDA_SchematicFrame * frame, EDA_BaseStruct *DrawList); +static void LoadSubHierarchy( WinEDA_SchematicFrame* frame, EDA_BaseStruct* DrawList ); /* Variables locales */ /************************************************************************************/ -int WinEDA_SchematicFrame::LoadOneEEProject(const wxString & FileName, bool IsNew) +int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNew ) /************************************************************************************/ + /* - Load an entire project ( shcematic root file and its subhierarchies, the configuration and the libs - which are not already loaded) -*/ + * Load an entire project ( shcematic root file and its subhierarchies, the configuration and the libs + * which are not already loaded) + */ { -SCH_SCREEN *screen; -wxString FullFileName, msg; -bool LibCacheExist = FALSE; - - EDA_ScreenList ScreenList(NULL); - for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) - { - if(screen->IsModify()) - break; - } - - if ( screen ) - { - if( ! IsOK(this, _("Clear Schematic Hierarchy (modified!)?")) ) return FALSE; - if ( ScreenSch->m_FileName != g_DefaultSchematicFileName ) - SetLastProject(ScreenSch->m_FileName); - } + SCH_SCREEN* screen; + wxString FullFileName, msg; + bool LibCacheExist = FALSE; + + EDA_ScreenList ScreenList( NULL ); + + for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + if( screen->IsModify() ) + break; + } + + if( screen ) + { + if( !IsOK( this, _( "Clear Schematic Hierarchy (modified!)?" ) ) ) + return FALSE; + if( ScreenSch->m_FileName != g_DefaultSchematicFileName ) + SetLastProject( ScreenSch->m_FileName ); + } - screen = ScreenSch ; + screen = ScreenSch; - FullFileName = FileName; - if( (FullFileName.IsEmpty() ) && !IsNew ) - { - wxString mask = wxT("*") + g_SchExtBuffer; - FullFileName = EDA_FileSelector( _("Schematic files:"), - wxEmptyString, /* Chemin par defaut */ - wxEmptyString, /* nom fichier par defaut */ - g_SchExtBuffer, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_OPEN, - TRUE - ); - if ( FullFileName.IsEmpty() ) return ( FALSE ); - } + FullFileName = FileName; + if( ( FullFileName.IsEmpty() ) && !IsNew ) + { + wxString mask = wxT( "*" ) + g_SchExtBuffer; + FullFileName = EDA_FileSelector( _( "Schematic files:" ), + wxEmptyString, /* Chemin par defaut */ + wxEmptyString, /* nom fichier par defaut */ + g_SchExtBuffer, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_OPEN, + TRUE + ); + if( FullFileName.IsEmpty() ) + return FALSE; + } - if( ClearProjectDrawList(screen, TRUE) == FALSE ) return(1); + if( ClearProjectDrawList( screen, TRUE ) == FALSE ) + return 1; - ActiveScreen = m_CurrentScreen = screen = ScreenSch; - ScreenSch->ClearUndoRedoList(); - screen->m_CurrentItem = NULL; - wxSetWorkingDirectory(wxPathOnly(FullFileName) ); - m_CurrentScreen->m_FileName = FullFileName; - Affiche_Message(wxEmptyString); - MsgPanel->EraseMsgBox(); + ActiveScreen = m_CurrentScreen = screen = ScreenSch; + ScreenSch->ClearUndoRedoList(); + screen->SetCurItem( NULL ); + wxSetWorkingDirectory( wxPathOnly( FullFileName ) ); + m_CurrentScreen->m_FileName = FullFileName; + Affiche_Message( wxEmptyString ); + MsgPanel->EraseMsgBox(); - memset( &g_EESchemaVar,0, sizeof(g_EESchemaVar) ); + memset( &g_EESchemaVar, 0, sizeof(g_EESchemaVar) ); - m_CurrentScreen->ClrModify(); - m_CurrentScreen->Pnext = NULL; + m_CurrentScreen->ClrModify(); + m_CurrentScreen->Pnext = NULL; - if( IsNew ) - { - screen->m_CurrentSheet = &g_Sheet_A4; - screen->SetZoom(32); - screen->m_SheetNumber = screen->m_NumberOfSheet = 1; - screen->m_Title = wxT("noname.sch"); - m_CurrentScreen->m_FileName = screen->m_Title; - screen->m_Company.Empty(); - screen->m_Commentaire1.Empty(); - screen->m_Commentaire2.Empty(); - screen->m_Commentaire3.Empty(); - screen->m_Commentaire4.Empty(); - Read_Config(wxEmptyString, TRUE); - Zoom_Automatique(TRUE); - ReDrawPanel(); - return (1); - } - // Rechargement de la configuration: - msg = _("Ready\nWorking dir: \n") + wxGetCwd(); - PrintMsg(msg); + if( IsNew ) + { + screen->m_CurrentSheet = &g_Sheet_A4; + screen->SetZoom( 32 ); + screen->m_SheetNumber = screen->m_NumberOfSheet = 1; + screen->m_Title = wxT( "noname.sch" ); + m_CurrentScreen->m_FileName = screen->m_Title; + screen->m_Company.Empty(); + screen->m_Commentaire1.Empty(); + screen->m_Commentaire2.Empty(); + screen->m_Commentaire3.Empty(); + screen->m_Commentaire4.Empty(); + Read_Config( wxEmptyString, TRUE ); + Zoom_Automatique( TRUE ); + ReDrawPanel(); + return 1; + } - Read_Config(wxEmptyString, FALSE); + // Rechargement de la configuration: + msg = _( "Ready\nWorking dir: \n" ) + wxGetCwd(); + PrintMsg( msg ); - // Delete old caches. -LibraryStruct *nextlib, *lib = g_LibraryList; - for (; lib != NULL; lib = nextlib ) - { - nextlib = lib->m_Pnext; - if ( lib->m_IsLibCache ) - FreeCmpLibrary(this, lib->m_Name); - } + Read_Config( wxEmptyString, FALSE ); - if( IsNew ) - { - ReDrawPanel(); - return (1); - } + // Delete old caches. + LibraryStruct* nextlib, * lib = g_LibraryList; + for( ; lib != NULL; lib = nextlib ) + { + nextlib = lib->m_Pnext; + if( lib->m_IsLibCache ) + FreeCmpLibrary( this, lib->m_Name ); + } - // Loading the project library cache - wxString FullLibName; - wxString shortfilename; - wxSplitPath(ScreenSch->m_FileName, NULL, &shortfilename, NULL); - FullLibName << wxT(".") << STRING_DIR_SEP << shortfilename << wxT(".cache") << g_LibExtBuffer; - if ( wxFileExists(FullLibName) ) - { - wxString libname; - libname = FullLibName; - ChangeFileNameExt(libname,wxEmptyString); - msg = wxT("Load ") + FullLibName; - LibraryStruct *LibCache = LoadLibraryName(this, FullLibName, libname); - if ( LibCache ) - { - LibCache->m_IsLibCache = TRUE; - msg += wxT(" OK"); - } - else msg += wxT(" ->Error"); - PrintMsg( msg ); - LibCacheExist = TRUE; - } + if( IsNew ) + { + ReDrawPanel(); + return 1; + } - if ( ! wxFileExists(ScreenSch->m_FileName) && !LibCacheExist) // Nouveau projet prpbablement - { - msg.Printf( _("File %s not found (new project ?)"), - ScreenSch->m_FileName.GetData() ); - DisplayInfo(this, msg, 20); - return (-1); - } - - if( LoadOneEEFile(ScreenSch, ScreenSch->m_FileName) == FALSE) return (0); + // Loading the project library cache + wxString FullLibName; + wxString shortfilename; + wxSplitPath( ScreenSch->m_FileName, NULL, &shortfilename, NULL ); + FullLibName << wxT( "." ) << STRING_DIR_SEP << shortfilename << wxT( ".cache" ) << + g_LibExtBuffer; + if( wxFileExists( FullLibName ) ) + { + wxString libname; + libname = FullLibName; + ChangeFileNameExt( libname, wxEmptyString ); + msg = wxT( "Load " ) + FullLibName; + LibraryStruct* LibCache = LoadLibraryName( this, FullLibName, libname ); + if( LibCache ) + { + LibCache->m_IsLibCache = TRUE; + msg += wxT( " OK" ); + } + else + msg += wxT( " ->Error" ); + PrintMsg( msg ); + LibCacheExist = TRUE; + } - /* load all subhierarchies fond in current list and new loaded list */ - LoadSubHierarchy(this, ScreenSch->EEDrawList); + if( !wxFileExists( ScreenSch->m_FileName ) && !LibCacheExist ) // Nouveau projet prpbablement + { + msg.Printf( _( "File %s not found (new project ?)" ), + ScreenSch->m_FileName.GetData() ); + DisplayInfo( this, msg, 20 ); + return -1; + } - /* Reaffichage ecran de base (ROOT) si necessaire */ - ActiveScreen = ScreenSch; - Zoom_Automatique(FALSE); + if( LoadOneEEFile( ScreenSch, ScreenSch->m_FileName ) == FALSE ) + return 0; - return (1); + /* load all subhierarchies fond in current list and new loaded list */ + LoadSubHierarchy( this, ScreenSch->EEDrawList ); + + /* Reaffichage ecran de base (ROOT) si necessaire */ + ActiveScreen = ScreenSch; + Zoom_Automatique( FALSE ); + + return 1; } /*******************************************************************************/ -void LoadSubHierarchy(WinEDA_SchematicFrame * frame, EDA_BaseStruct *DrawList) +void LoadSubHierarchy( WinEDA_SchematicFrame* frame, EDA_BaseStruct* DrawList ) /*******************************************************************************/ + /* load subhierarcy when sheets are found in DrawList - recursive function. -*/ + * recursive function. + */ { -EDA_BaseStruct * EEDrawList = DrawList; - - while(EEDrawList) - { - if( EEDrawList->m_StructType == DRAW_SHEET_STRUCT_TYPE) - { - #undef STRUCT - #define STRUCT ((DrawSheetStruct*)EEDrawList) - int timestamp = STRUCT->m_TimeStamp; - if(timestamp == 0 ) - { - timestamp = GetTimeStamp(); - STRUCT->m_TimeStamp = timestamp; - } - if( ! STRUCT->m_FileName.IsEmpty() ) - { - if( frame->LoadOneEEFile(STRUCT, STRUCT->m_FileName) == TRUE ) - { - LoadSubHierarchy(frame, STRUCT->EEDrawList); - } - } - else DisplayError(frame, _("No FileName in SubSheet")); - } - EEDrawList = EEDrawList->Pnext; - } + EDA_BaseStruct* EEDrawList = DrawList; + + while( EEDrawList ) + { + if( EEDrawList->m_StructType == DRAW_SHEET_STRUCT_TYPE ) + { + #undef STRUCT + #define STRUCT ( (DrawSheetStruct*) EEDrawList ) + int timestamp = STRUCT->m_TimeStamp; + if( timestamp == 0 ) + { + timestamp = GetTimeStamp(); + STRUCT->m_TimeStamp = timestamp; + } + if( !STRUCT->m_FileName.IsEmpty() ) + { + if( frame->LoadOneEEFile( STRUCT, STRUCT->m_FileName ) == TRUE ) + { + LoadSubHierarchy( frame, STRUCT->EEDrawList ); + } + } + else + DisplayError( frame, _( "No FileName in SubSheet" ) ); + } + EEDrawList = EEDrawList->Pnext; + } } - - diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index dcc5ff259c..6d7dfa051b 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -15,453 +15,481 @@ /* Routines Locales */ -static void ShowWhileMoving(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); -static void ExitPlaceCmp(WinEDA_DrawPanel * Panel, wxDC * DC ); +static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); +static void ExitPlaceCmp( WinEDA_DrawPanel* Panel, wxDC* DC ); /* Variables locales */ -static int OldTransMat[2][2]; +static int OldTransMat[2][2]; static wxPoint OldPos; - /*******************************************************/ -wxString SelectFromLibBrowser(WinEDA_DrawFrame *parent) +wxString SelectFromLibBrowser( WinEDA_DrawFrame* parent ) /*******************************************************/ { -wxString name; -WinEDA_ViewlibFrame * Viewer; -wxSemaphore semaphore(0,1); - - Viewer = parent->m_Parent->ViewlibFrame; - /* Close the current Lib browser, if open, and open a new one, in "modal" mode */ - if ( Viewer ) Viewer->Destroy(); - - Viewer = parent->m_Parent->ViewlibFrame = new - WinEDA_ViewlibFrame(parent->m_Parent->SchematicFrame, - parent->m_Parent, NULL, & semaphore ); - Viewer->AdjustScrollBars(); + wxString name; + WinEDA_ViewlibFrame* Viewer; + wxSemaphore semaphore( 0, 1 ); - // Show the library viewer frame until it is closed - while ( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event - { - wxYield(); - wxMilliSleep(50); - } - name = g_CurrentViewComponentName; - return name; + Viewer = parent->m_Parent->ViewlibFrame; + /* Close the current Lib browser, if open, and open a new one, in "modal" mode */ + if( Viewer ) + Viewer->Destroy(); + + Viewer = parent->m_Parent->ViewlibFrame = new + WinEDA_ViewlibFrame( + parent->m_Parent->SchematicFrame, + parent->m_Parent, + NULL, + &semaphore ); + Viewer->AdjustScrollBars(); + + // Show the library viewer frame until it is closed + while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event + { + wxYield(); + wxMilliSleep( 50 ); + } + + name = g_CurrentViewComponentName; + return name; } +/**************************************************************************/ +EDA_SchComponentStruct* WinEDA_SchematicFrame::Load_Component( wxDC* DC, + const wxString& libname, + wxArrayString& HistoryList, + bool UseLibBrowser ) +/**************************************************************************/ -/**************************************************************************/ -EDA_SchComponentStruct * WinEDA_SchematicFrame::Load_Component(wxDC * DC, - const wxString & libname, wxArrayString & HistoryList, - bool UseLibBrowser) -/**************************************************************************/ /* load from a library and place a component - if libname != "", search in lib "libname" - else search in all loaded libs -*/ + * if libname != "", search in lib "libname" + * else search in all loaded libs + */ { -int ii, CmpCount = 0; -LibDrawField * Field; -EDA_LibComponentStruct *Entry = NULL; -EDA_SchComponentStruct * DrawLibItem = NULL; -LibraryStruct *Library = NULL; -wxString Name, keys, msg; -bool AllowWildSeach = TRUE; - - g_ItemToRepeat = NULL; - DrawPanel->m_IgnoreMouseEvents = TRUE; - - if ( ! libname.IsEmpty() ) - { - Library = g_LibraryList; - while (Library) - { - if( Library->m_Name == libname ) - { - CmpCount = Library->m_NumOfParts; - break; - } - Library = Library->m_Pnext; - } - } - else - { - LibraryStruct * lib = g_LibraryList; - while (lib) - { - CmpCount += lib->m_NumOfParts; - lib = lib->m_Pnext; - } - } + int ii, CmpCount = 0; + LibDrawField* Field; + EDA_LibComponentStruct* Entry = NULL; + EDA_SchComponentStruct* DrawLibItem = NULL; + LibraryStruct* Library = NULL; + wxString Name, keys, msg; + bool AllowWildSeach = TRUE; - /* Ask for a component name or key words */ - msg.Printf (_("component selection (%d items loaded):"), CmpCount); - - Name = GetComponentName(this, HistoryList, msg, - UseLibBrowser ? SelectFromLibBrowser : NULL); - Name.MakeUpper(); - if( Name.IsEmpty() ) - { - DrawPanel->m_IgnoreMouseEvents = FALSE; - DrawPanel->MouseToCursorSchema(); - return NULL; /* annulation de commande */ - } - - if( Name.GetChar(0) == '=' ) - { - AllowWildSeach = FALSE; - keys = Name.AfterFirst('='); - if( DataBaseGetName(this, keys, Name) == 0 ) - { - DrawPanel->m_IgnoreMouseEvents = FALSE; - DrawPanel->MouseToCursorSchema(); - return NULL; - } - } + g_ItemToRepeat = NULL; + DrawPanel->m_IgnoreMouseEvents = TRUE; - else if( Name == wxT("*") ) - { - AllowWildSeach = FALSE; - if( GetNameOfPartToLoad(this, Library, Name) == 0 ) - { - DrawPanel->m_IgnoreMouseEvents = FALSE; - DrawPanel->MouseToCursorSchema(); - return NULL; - } - } + if( !libname.IsEmpty() ) + { + Library = g_LibraryList; + while( Library ) + { + if( Library->m_Name == libname ) + { + CmpCount = Library->m_NumOfParts; + break; + } + Library = Library->m_Pnext; + } + } + else + { + LibraryStruct* lib = g_LibraryList; + while( lib ) + { + CmpCount += lib->m_NumOfParts; + lib = lib->m_Pnext; + } + } - else if( Name.Contains( wxT("?")) || Name.Contains( wxT("*")) ) - { - AllowWildSeach = FALSE; - if( DataBaseGetName(this, keys, Name) == 0 ) - { - DrawPanel->m_IgnoreMouseEvents = FALSE; - DrawPanel->MouseToCursorSchema(); - return NULL; - } - } + /* Ask for a component name or key words */ + msg.Printf( _( "component selection (%d items loaded):" ), CmpCount ); - Entry = FindLibPart(Name.GetData(), libname, FIND_ROOT); - if( (Entry == NULL) && AllowWildSeach ) /* Attemp to search with wildcard */ - { - AllowWildSeach = FALSE; - wxString wildname = wxChar('*') + Name + wxChar('*'); - Name = wildname; - if( DataBaseGetName(this, keys, Name) ) - Entry = FindLibPart(Name.GetData(), libname, FIND_ROOT); - if( Entry == NULL) - { - DrawPanel->m_IgnoreMouseEvents = FALSE; - DrawPanel->MouseToCursorSchema(); - return NULL; - } - } + Name = GetComponentName( this, HistoryList, msg, + UseLibBrowser ? SelectFromLibBrowser : NULL ); + Name.MakeUpper(); + if( Name.IsEmpty() ) + { + DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->MouseToCursorSchema(); + return NULL; /* annulation de commande */ + } + + if( Name.GetChar( 0 ) == '=' ) + { + AllowWildSeach = FALSE; + keys = Name.AfterFirst( '=' ); + if( DataBaseGetName( this, keys, Name ) == 0 ) + { + DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->MouseToCursorSchema(); + return NULL; + } + } + else if( Name == wxT( "*" ) ) + { + AllowWildSeach = FALSE; + if( GetNameOfPartToLoad( this, Library, Name ) == 0 ) + { + DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->MouseToCursorSchema(); + return NULL; + } + } + else if( Name.Contains( wxT( "?" ) ) || Name.Contains( wxT( "*" ) ) ) + { + AllowWildSeach = FALSE; + if( DataBaseGetName( this, keys, Name ) == 0 ) + { + DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->MouseToCursorSchema(); + return NULL; + } + } + + Entry = FindLibPart( Name.GetData(), libname, FIND_ROOT ); + if( (Entry == NULL) && AllowWildSeach ) /* Attemp to search with wildcard */ + { + AllowWildSeach = FALSE; + wxString wildname = wxChar( '*' ) + Name + wxChar( '*' ); + Name = wildname; + if( DataBaseGetName( this, keys, Name ) ) + Entry = FindLibPart( Name.GetData(), libname, FIND_ROOT ); + if( Entry == NULL ) + { + DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->MouseToCursorSchema(); + return NULL; + } + } - DrawPanel->m_IgnoreMouseEvents = FALSE; - DrawPanel->MouseToCursorSchema(); - if( Entry == NULL) - { - msg = _("Failed to find part ") + Name + _(" in library"); - DisplayError(this, msg, 10); - return NULL; - } + DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->MouseToCursorSchema(); + if( Entry == NULL ) + { + msg = _( "Failed to find part " ) + Name + _( " in library" ); + DisplayError( this, msg, 10 ); + return NULL; + } - AddHistoryComponentName(HistoryList, Name); + AddHistoryComponentName( HistoryList, Name ); - DrawPanel->ManageCurseur = ShowWhileMoving ; - DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp; + DrawPanel->ManageCurseur = ShowWhileMoving; + DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp; - DrawLibItem = new EDA_SchComponentStruct(m_CurrentScreen->m_Curseur); - DrawLibItem->m_Multi = 1; /* Selection de l'unite 1 dans le boitier */ - DrawLibItem->m_Convert = 1; - DrawLibItem->m_ChipName = Name; - DrawLibItem->m_TimeStamp = GetTimeStamp(); - DrawLibItem->m_Flags = IS_NEW | IS_MOVED; + DrawLibItem = new EDA_SchComponentStruct( m_CurrentScreen->m_Curseur ); + DrawLibItem->m_Multi = 1;/* Selection de l'unite 1 dans le boitier */ + DrawLibItem->m_Convert = 1; + DrawLibItem->m_ChipName = Name; + DrawLibItem->m_TimeStamp = GetTimeStamp(); + DrawLibItem->m_Flags = IS_NEW | IS_MOVED; - /* Init champ Valeur */ - DrawLibItem->m_Field[VALUE].m_Pos.x = - Entry->m_Name.m_Pos.x + DrawLibItem->m_Pos.x; - DrawLibItem->m_Field[VALUE].m_Pos.y = - Entry->m_Name.m_Pos.y + DrawLibItem->m_Pos.y; - DrawLibItem->m_Field[VALUE].m_Orient = Entry->m_Name.m_Orient; - DrawLibItem->m_Field[VALUE].m_Size = Entry->m_Name.m_Size; - DrawLibItem->m_Field[VALUE].m_Text = DrawLibItem->m_ChipName; - DrawLibItem->m_Field[VALUE].m_Attributs = Entry->m_Name.m_Attributs; - DrawLibItem->m_Field[VALUE].m_HJustify = Entry->m_Name.m_HJustify; - DrawLibItem->m_Field[VALUE].m_VJustify = Entry->m_Name.m_VJustify; + /* Init champ Valeur */ + DrawLibItem->m_Field[VALUE].m_Pos.x = + Entry->m_Name.m_Pos.x + DrawLibItem->m_Pos.x; + DrawLibItem->m_Field[VALUE].m_Pos.y = + Entry->m_Name.m_Pos.y + DrawLibItem->m_Pos.y; + DrawLibItem->m_Field[VALUE].m_Orient = Entry->m_Name.m_Orient; + DrawLibItem->m_Field[VALUE].m_Size = Entry->m_Name.m_Size; + DrawLibItem->m_Field[VALUE].m_Text = DrawLibItem->m_ChipName; + DrawLibItem->m_Field[VALUE].m_Attributs = Entry->m_Name.m_Attributs; + DrawLibItem->m_Field[VALUE].m_HJustify = Entry->m_Name.m_HJustify; + DrawLibItem->m_Field[VALUE].m_VJustify = Entry->m_Name.m_VJustify; - msg = Entry->m_Prefix.m_Text; - if ( msg.IsEmpty() ) msg = wxT("U"); - msg += wxT("?"); + msg = Entry->m_Prefix.m_Text; + if( msg.IsEmpty() ) + msg = wxT( "U" ); + msg += wxT( "?" ); - /* Init champ Reference */ - DrawLibItem->m_Field[REFERENCE].m_Pos.x = - Entry->m_Prefix.m_Pos.x + DrawLibItem->m_Pos.x; - DrawLibItem->m_Field[REFERENCE].m_Pos.y = - Entry->m_Prefix.m_Pos.y + DrawLibItem->m_Pos.y; - DrawLibItem->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient; - DrawLibItem->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size; - DrawLibItem->m_Field[REFERENCE].m_Text = msg; - DrawLibItem->m_Field[REFERENCE].m_Attributs = Entry->m_Prefix.m_Attributs; - DrawLibItem->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify; - DrawLibItem->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify; + /* Init champ Reference */ + DrawLibItem->m_Field[REFERENCE].m_Pos.x = + Entry->m_Prefix.m_Pos.x + DrawLibItem->m_Pos.x; + DrawLibItem->m_Field[REFERENCE].m_Pos.y = + Entry->m_Prefix.m_Pos.y + DrawLibItem->m_Pos.y; + DrawLibItem->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient; + DrawLibItem->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size; + DrawLibItem->m_Field[REFERENCE].m_Text = msg; + DrawLibItem->m_Field[REFERENCE].m_Attributs = Entry->m_Prefix.m_Attributs; + DrawLibItem->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify; + DrawLibItem->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify; - /* Init des autres champs si predefinis dans la librairie */ - for( Field = Entry->Fields; Field != NULL; Field = (LibDrawField*)Field->Pnext ) - { - if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() ) continue; - ii = Field->m_FieldId; - if( ii < 2 ) continue; - if( ii >= NUMBER_OF_FIELDS ) continue; - DrawLibItem->m_Field[ii].m_Pos.x += Field->m_Pos.x; - DrawLibItem->m_Field[ii].m_Pos.y += Field->m_Pos.y; - DrawLibItem->m_Field[ii].m_Size = Field->m_Size; - DrawLibItem->m_Field[ii].m_Attributs = Field->m_Attributs; - DrawLibItem->m_Field[ii].m_Orient = Field->m_Orient; - DrawLibItem->m_Field[ii].m_Text = Field->m_Text; - DrawLibItem->m_Field[ii].m_Name = Field->m_Name; - DrawLibItem->m_Field[ii].m_HJustify = Field->m_HJustify; - DrawLibItem->m_Field[ii].m_VJustify = Field->m_VJustify; - } + /* Init des autres champs si predefinis dans la librairie */ + for( Field = Entry->Fields; Field != NULL; Field = (LibDrawField*) Field->Pnext ) + { + if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() ) + continue; + ii = Field->m_FieldId; + if( ii < 2 ) + continue; + if( ii >= NUMBER_OF_FIELDS ) + continue; + DrawLibItem->m_Field[ii].m_Pos.x += Field->m_Pos.x; + DrawLibItem->m_Field[ii].m_Pos.y += Field->m_Pos.y; + DrawLibItem->m_Field[ii].m_Size = Field->m_Size; + DrawLibItem->m_Field[ii].m_Attributs = Field->m_Attributs; + DrawLibItem->m_Field[ii].m_Orient = Field->m_Orient; + DrawLibItem->m_Field[ii].m_Text = Field->m_Text; + DrawLibItem->m_Field[ii].m_Name = Field->m_Name; + DrawLibItem->m_Field[ii].m_HJustify = Field->m_HJustify; + DrawLibItem->m_Field[ii].m_VJustify = Field->m_VJustify; + } - /* Trace du composant */ - DrawStructsInGhost(DrawPanel, DC, DrawLibItem, 0, 0 ); - MsgPanel->EraseMsgBox(); - DrawLibItem->Display_Infos(this); + /* Trace du composant */ + DrawStructsInGhost( DrawPanel, DC, DrawLibItem, 0, 0 ); + MsgPanel->EraseMsgBox(); + DrawLibItem->Display_Infos( this ); - return DrawLibItem; + return DrawLibItem; } + /**************************************************************************/ /*** Routine de deplacement du composant. ***/ /*** Appele par GeneralControle grace a ActiveScreen->ManageCurseur. ***/ /**************************************************************************/ -static void ShowWhileMoving(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) { -wxPoint move_vector; + wxPoint move_vector; -EDA_SchComponentStruct * DrawLibItem = (EDA_SchComponentStruct * ) - panel->m_Parent->m_CurrentScreen->m_CurrentItem; + EDA_SchComponentStruct* DrawLibItem = (EDA_SchComponentStruct*) + panel->m_Parent->m_CurrentScreen->GetCurItem(); - /* Effacement du composant */ - if( erase ) - DrawStructsInGhost(panel, DC, DrawLibItem, 0, 0 ); + /* Effacement du composant */ + if( erase ) + DrawStructsInGhost( panel, DC, DrawLibItem, 0, 0 ); - move_vector.x = panel->m_Parent->m_CurrentScreen->m_Curseur.x - DrawLibItem->m_Pos.x; - move_vector.y = panel->m_Parent->m_CurrentScreen->m_Curseur.y - DrawLibItem->m_Pos.y; - MoveOneStruct(DrawLibItem, move_vector); + move_vector.x = panel->m_Parent->m_CurrentScreen->m_Curseur.x - DrawLibItem->m_Pos.x; + move_vector.y = panel->m_Parent->m_CurrentScreen->m_Curseur.y - DrawLibItem->m_Pos.y; + MoveOneStruct( DrawLibItem, move_vector ); - DrawStructsInGhost(panel, DC, DrawLibItem, 0, 0 ); + DrawStructsInGhost( panel, DC, DrawLibItem, 0, 0 ); } + /**************************************************************************/ void WinEDA_SchematicFrame::CmpRotationMiroir( - EDA_SchComponentStruct * DrawComponent, wxDC * DC, int type_rotate ) + EDA_SchComponentStruct* DrawComponent, wxDC* DC, int type_rotate ) /**************************************************************************/ + /* Routine permettant les rotations et les miroirs d'un composant - Si DC = NULL : pas de redessin -*/ + * Si DC = NULL : pas de redessin + */ { - if ( DrawComponent == NULL ) return; + if( DrawComponent == NULL ) + return; - /* Efface le trace precedent */ - if ( DC ) - { - DrawPanel->CursorOff(DC); - if ( DrawComponent->m_Flags ) - DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 ); - else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), g_XorMode); - } + /* Efface le trace precedent */ + if( DC ) + { + DrawPanel->CursorOff( DC ); + if( DrawComponent->m_Flags ) + DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 ); + else + DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode ); + } - DrawComponent->SetRotationMiroir(type_rotate); + DrawComponent->SetRotationMiroir( type_rotate ); - /* Redessine le composant dans la nouvelle position */ - if ( DC ) - { - if( DrawComponent->m_Flags ) - DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 ); - else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), GR_DEFAULT_DRAWMODE); - DrawPanel->CursorOn(DC); - } + /* Redessine le composant dans la nouvelle position */ + if( DC ) + { + if( DrawComponent->m_Flags ) + DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 ); + else + DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); + DrawPanel->CursorOn( DC ); + } - TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); - GetScreen()->SetModify(); + TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + GetScreen()->SetModify(); } + /************************************************************/ -static void ExitPlaceCmp(WinEDA_DrawPanel * Panel, wxDC * DC ) +static void ExitPlaceCmp( WinEDA_DrawPanel* Panel, wxDC* DC ) /************************************************************/ + /* Routine de sortie de la fonction de placement de composant -*/ + */ { + EDA_SchComponentStruct* DrawLibItem = (EDA_SchComponentStruct*) + Panel->m_Parent->m_CurrentScreen->GetCurItem(); -EDA_SchComponentStruct * DrawLibItem = (EDA_SchComponentStruct * ) - Panel->m_Parent->m_CurrentScreen->m_CurrentItem; + if( DrawLibItem->m_Flags & IS_NEW ) /* Nouveau Placement en cours, on l'efface */ + { + DrawStructsInGhost( Panel, DC, DrawLibItem, 0, 0 ); + delete DrawLibItem; + } + else if( DrawLibItem ) /* Deplacement ancien composant en cours */ + { + wxPoint move_vector; + DrawStructsInGhost( Panel, DC, DrawLibItem, 0, 0 ); - if ( DrawLibItem->m_Flags & IS_NEW ) /* Nouveau Placement en cours, on l'efface */ - { - DrawStructsInGhost(Panel, DC, DrawLibItem, 0, 0 ); - delete DrawLibItem; - } + move_vector.x = OldPos.x - DrawLibItem->m_Pos.x; + move_vector.y = OldPos.y - DrawLibItem->m_Pos.y; - else if ( DrawLibItem ) /* Deplacement ancien composant en cours */ - { - wxPoint move_vector; - DrawStructsInGhost(Panel, DC, DrawLibItem, 0, 0 ); + MoveOneStruct( DrawLibItem, move_vector ); - move_vector.x = OldPos.x - DrawLibItem->m_Pos.x; - move_vector.y = OldPos.y - DrawLibItem->m_Pos.y; + memcpy( DrawLibItem->m_Transform, OldTransMat, sizeof(OldTransMat) ); + DrawLibItem->Draw( Panel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); + } - MoveOneStruct(DrawLibItem, move_vector); - - memcpy(DrawLibItem->m_Transform, OldTransMat, sizeof(OldTransMat) ); - DrawLibItem->Draw(Panel, DC, wxPoint(0,0), GR_DEFAULT_DRAWMODE); - } - - DrawLibItem->m_Flags = 0; - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; - Panel->m_Parent->m_CurrentScreen->m_CurrentItem = NULL; + DrawLibItem->m_Flags = 0; + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + Panel->m_Parent->m_CurrentScreen->SetCurItem( NULL ); } - /************************************************************************/ -void WinEDA_SchematicFrame::SelPartUnit(EDA_SchComponentStruct *DrawComponent, - int unit, wxDC * DC) +void WinEDA_SchematicFrame::SelPartUnit( EDA_SchComponentStruct* DrawComponent, + int unit, wxDC* DC ) /************************************************************************/ /* Selection de l'unite dans les boitiers a multiples Parts */ { -int m_UnitCount; -EDA_LibComponentStruct * LibEntry; + int m_UnitCount; + EDA_LibComponentStruct* LibEntry; - if (DrawComponent == NULL) return; + if( DrawComponent == NULL ) + return; - LibEntry = FindLibPart(DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); - if( LibEntry == NULL ) return; + LibEntry = FindLibPart( DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); + if( LibEntry == NULL ) + return; - m_UnitCount = LibEntry->m_UnitCount; + m_UnitCount = LibEntry->m_UnitCount; - if( m_UnitCount <= 1 ) return; + if( m_UnitCount <= 1 ) + return; - if( DrawComponent->m_Multi == unit ) return; - if ( unit < 1 ) unit = 1; - if ( unit > m_UnitCount ) unit = m_UnitCount; + if( DrawComponent->m_Multi == unit ) + return; + if( unit < 1 ) + unit = 1; + if( unit > m_UnitCount ) + unit = m_UnitCount; - /* Efface le trace precedent */ - if ( DrawComponent->m_Flags ) - DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 ); - else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), g_XorMode); + /* Efface le trace precedent */ + if( DrawComponent->m_Flags ) + DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 ); + else + DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode ); - /* Mise a jour du numero d'unite */ - DrawComponent->m_Multi = unit; + /* Mise a jour du numero d'unite */ + DrawComponent->m_Multi = unit; - /* Redessine le composant dans la nouvelle position */ - if( DrawComponent->m_Flags ) - DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 ); - else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), GR_DEFAULT_DRAWMODE); + /* Redessine le composant dans la nouvelle position */ + if( DrawComponent->m_Flags ) + DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 ); + else + DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); - GetScreen()->SetModify(); + TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + GetScreen()->SetModify(); } + /************************************************************************/ -void WinEDA_SchematicFrame::ConvertPart(EDA_SchComponentStruct *DrawComponent, - wxDC * DC) +void WinEDA_SchematicFrame::ConvertPart( EDA_SchComponentStruct* DrawComponent, + wxDC* DC ) /************************************************************************/ { -int ii; -EDA_LibComponentStruct *LibEntry; + int ii; + EDA_LibComponentStruct* LibEntry; - if (DrawComponent == NULL) return; + if( DrawComponent == NULL ) + return; - LibEntry = FindLibPart(DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); - if( LibEntry == NULL ) return; + LibEntry = FindLibPart( DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); + if( LibEntry == NULL ) + return; - if( (ii = LookForConvertPart(LibEntry) ) < 2 ) - { - DisplayError(this, wxT("No Convert found"), 10); return; - } + if( ( ii = LookForConvertPart( LibEntry ) ) < 2 ) + { + DisplayError( this, wxT( "No Convert found" ), 10 ); return; + } - /* Efface le trace precedent */ - if ( DrawComponent->m_Flags ) - DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 ); - else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), g_XorMode); + /* Efface le trace precedent */ + if( DrawComponent->m_Flags ) + DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 ); + else + DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode ); - DrawComponent->m_Convert++; - if( DrawComponent->m_Convert > ii ) DrawComponent->m_Convert = 1; + DrawComponent->m_Convert++; + if( DrawComponent->m_Convert > ii ) + DrawComponent->m_Convert = 1; - /* Redessine le composant dans la nouvelle position */ - if( DrawComponent->m_Flags & IS_MOVED) - DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 ); - else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), GR_DEFAULT_DRAWMODE); + /* Redessine le composant dans la nouvelle position */ + if( DrawComponent->m_Flags & IS_MOVED ) + DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 ); + else + DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); - GetScreen()->SetModify(); + TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + GetScreen()->SetModify(); } /**********************************************************/ -int LookForConvertPart( EDA_LibComponentStruct * LibEntry ) +int LookForConvertPart( EDA_LibComponentStruct* LibEntry ) /**********************************************************/ + /* Retourne la plus grande valeur trouvee dans la liste des elements - "drawings" du composant LibEntry, pour le membre .Convert - Si il n'y a pas de representation type "convert", la valeur - retournee est 0 ou 1 - Si il y a une representation type "convert", - la valeur retournee est > 1 (typiquement 2) + * "drawings" du composant LibEntry, pour le membre .Convert + * Si il n'y a pas de representation type "convert", la valeur + * retournee est 0 ou 1 + * Si il y a une representation type "convert", + * la valeur retournee est > 1 (typiquement 2) */ { -int ii; -LibEDA_BaseStruct *DrawLibEntry; + int ii; + LibEDA_BaseStruct* DrawLibEntry; - DrawLibEntry = LibEntry->m_Drawings; - ii = 0; - while( DrawLibEntry) - { - if (ii < DrawLibEntry->m_Convert ) ii = DrawLibEntry->m_Convert; - DrawLibEntry = DrawLibEntry->Next(); - } + DrawLibEntry = LibEntry->m_Drawings; + ii = 0; + while( DrawLibEntry ) + { + if( ii < DrawLibEntry->m_Convert ) + ii = DrawLibEntry->m_Convert; + DrawLibEntry = DrawLibEntry->Next(); + } - return (ii); + return ii; } /***********************************************************************************/ -void WinEDA_SchematicFrame::StartMovePart(EDA_SchComponentStruct * Component, - wxDC * DC) +void WinEDA_SchematicFrame::StartMovePart( EDA_SchComponentStruct* Component, + wxDC* DC ) /***********************************************************************************/ { - if( Component == NULL) return; - if( Component->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE) - return; + if( Component == NULL ) + return; + if( Component->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + return; - if ( Component->m_Flags == 0 ) - { - if ( g_ItemToUndoCopy ) delete g_ItemToUndoCopy; - g_ItemToUndoCopy = Component->GenCopy(); - } + if( Component->m_Flags == 0 ) + { + if( g_ItemToUndoCopy ) + delete g_ItemToUndoCopy; + g_ItemToUndoCopy = Component->GenCopy(); + } - DrawPanel->CursorOff(DC); - m_CurrentScreen->m_Curseur = Component->m_Pos; - DrawPanel->MouseToCursorSchema(); - - DrawPanel->ManageCurseur = ShowWhileMoving ; - DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp; - m_CurrentScreen->m_CurrentItem = Component; - OldPos = Component->m_Pos; - memcpy(OldTransMat, Component->m_Transform, sizeof(OldTransMat) ); + DrawPanel->CursorOff( DC ); + m_CurrentScreen->m_Curseur = Component->m_Pos; + DrawPanel->MouseToCursorSchema(); - RedrawOneStruct(DrawPanel, DC, Component, g_XorMode); - Component->m_Flags |= IS_MOVED; - DrawPanel->ManageCurseur(DrawPanel, DC,FALSE); - DrawPanel->m_AutoPAN_Request = TRUE; - - DrawPanel->CursorOn(DC); + DrawPanel->ManageCurseur = ShowWhileMoving; + DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp; + m_CurrentScreen->SetCurItem( Component ); + OldPos = Component->m_Pos; + memcpy( OldTransMat, Component->m_Transform, sizeof(OldTransMat) ); + + RedrawOneStruct( DrawPanel, DC, Component, g_XorMode ); + Component->m_Flags |= IS_MOVED; + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + DrawPanel->m_AutoPAN_Request = TRUE; + + DrawPanel->CursorOn( DC ); } - - diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index 4add925e27..8b7f63a4d2 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -1,6 +1,6 @@ - /***************/ - /* hotkeys.cpp */ - /***************/ +/***************/ +/* hotkeys.cpp */ +/***************/ #include "fctsys.h" @@ -16,431 +16,474 @@ #include "protos.h" enum hotkey_id_commnand { - HK_NOT_FOUND = 0, - HK_RESET_LOCAL_COORD, - HK_HELP, - HK_ZOOM_IN, - HK_ZOOM_OUT, - HK_ZOOM_REDRAW, - HK_ZOOM_CENTER, - HK_NEXT_SEARCH, - HK_DELETE, - HK_REPEAT_LAST, - HK_MOVEBLOCK_TO_DRAGBLOCK, - HK_ROTATE_COMPONENT, - HK_MIRROR_X_COMPONENT, - HK_MIRROR_Y_COMPONENT, - HK_ORIENT_NORMAL_COMPONENT, - HK_MOVE_COMPONENT, - HK_ADD_NEW_COMPONENT, - HK_BEGIN_WIRE + HK_NOT_FOUND = 0, + HK_RESET_LOCAL_COORD, + HK_HELP, + HK_ZOOM_IN, + HK_ZOOM_OUT, + HK_ZOOM_REDRAW, + HK_ZOOM_CENTER, + HK_NEXT_SEARCH, + HK_DELETE, + HK_REPEAT_LAST, + HK_MOVEBLOCK_TO_DRAGBLOCK, + HK_ROTATE_COMPONENT, + HK_MIRROR_X_COMPONENT, + HK_MIRROR_Y_COMPONENT, + HK_ORIENT_NORMAL_COMPONENT, + HK_MOVE_COMPONENT, + HK_ADD_NEW_COMPONENT, + HK_BEGIN_WIRE }; /* Class to handle hotkey commnands. hotkeys have a default value -This class allows (for the future..) the real key code changed by user(from a key code list file, TODO) -*/ + * This class allows (for the future..) the real key code changed by user(from a key code list file, TODO) + */ class Ki_HotkeyInfo { public: - int m_KeyCode; // Key code (ascii value for ascii keys or wxWidgets code for function key - wxString m_InfoMsg; // info message. - hotkey_id_commnand m_Idcommand; // internal id for the corresponding command (see hotkey_id_commnand list) + int m_KeyCode; // Key code (ascii value for ascii keys or wxWidgets code for function key + wxString m_InfoMsg; // info message. + hotkey_id_commnand m_Idcommand; // internal id for the corresponding command (see hotkey_id_commnand list) public: - Ki_HotkeyInfo(const wxChar * infomsg, hotkey_id_commnand idcommand, int keycode); + Ki_HotkeyInfo( const wxChar* infomsg, hotkey_id_commnand idcommand, int keycode ); }; -Ki_HotkeyInfo::Ki_HotkeyInfo(const wxChar * infomsg, hotkey_id_commnand idcommand, int keycode) +Ki_HotkeyInfo::Ki_HotkeyInfo( const wxChar* infomsg, hotkey_id_commnand idcommand, int keycode ) { - m_KeyCode = keycode; // Key code (ascii value for ascii keys or wxWidgets code for function key - m_InfoMsg = infomsg; // info message. - m_Idcommand = idcommand; // internal id for the corresponding command (see hotkey_id_commnand list) + m_KeyCode = keycode; // Key code (ascii value for ascii keys or wxWidgets code for function key + m_InfoMsg = infomsg; // info message. + m_Idcommand = idcommand; // internal id for the corresponding command (see hotkey_id_commnand list) } + /* local variables */ /* Hotkey list: */ -static Ki_HotkeyInfo HkBeginWire(wxT("begin Wire"), HK_BEGIN_WIRE, 'W'); -static Ki_HotkeyInfo HkAddComponent(wxT("Add Component"), HK_ADD_NEW_COMPONENT, 'A'); -static Ki_HotkeyInfo HkMirrorYComponent(wxT("Mirror Y Component"), HK_MIRROR_Y_COMPONENT, 'Y'); -static Ki_HotkeyInfo HkMirrorXComponent(wxT("Mirror X Component"), HK_MIRROR_X_COMPONENT, 'X'); -static Ki_HotkeyInfo HkOrientNormalComponent(wxT("Orient Normal Component"), HK_ORIENT_NORMAL_COMPONENT, 'N'); -static Ki_HotkeyInfo HkRotateComponent(wxT("Rotate Component"), HK_ROTATE_COMPONENT, 'R'); -static Ki_HotkeyInfo HkMoveComponent(wxT("Move Component"), HK_MOVE_COMPONENT, 'M'); -static Ki_HotkeyInfo HkMove2Drag(wxT("Switch move block to drag block"), HK_MOVEBLOCK_TO_DRAGBLOCK, '\t'); -static Ki_HotkeyInfo HkInsert(wxT("Repeat Last Item"), HK_REPEAT_LAST, WXK_INSERT); -static Ki_HotkeyInfo HkDelete(wxT("Delete Item"), HK_DELETE, WXK_DELETE); -static Ki_HotkeyInfo HkResetLocalCoord(wxT("Reset local coord."), HK_RESET_LOCAL_COORD, ' '); -static Ki_HotkeyInfo HkNextSearch(wxT("Next Search"), HK_NEXT_SEARCH, WXK_F5); -static Ki_HotkeyInfo HkZoomCenter(wxT("Zoom Center"), HK_ZOOM_CENTER, WXK_F4); -static Ki_HotkeyInfo HkZoomRedraw(wxT("Zoom Redraw"), HK_ZOOM_REDRAW, WXK_F3); -static Ki_HotkeyInfo HkZoomOut(wxT("Zoom Out"), HK_ZOOM_OUT, WXK_F2); -static Ki_HotkeyInfo HkZoomIn(wxT("Zoom In"), HK_ZOOM_IN, WXK_F1); -static Ki_HotkeyInfo HkHelp(wxT("Help: this message"), HK_HELP, '?'); +static Ki_HotkeyInfo HkBeginWire( wxT( "begin Wire" ), HK_BEGIN_WIRE, 'W' ); +static Ki_HotkeyInfo HkAddComponent( wxT( "Add Component" ), HK_ADD_NEW_COMPONENT, 'A' ); +static Ki_HotkeyInfo HkMirrorYComponent( wxT( "Mirror Y Component" ), HK_MIRROR_Y_COMPONENT, + 'Y' ); +static Ki_HotkeyInfo HkMirrorXComponent( wxT( "Mirror X Component" ), HK_MIRROR_X_COMPONENT, + 'X' ); +static Ki_HotkeyInfo HkOrientNormalComponent( wxT( "Orient Normal Component" ), + HK_ORIENT_NORMAL_COMPONENT, 'N' ); +static Ki_HotkeyInfo HkRotateComponent( wxT( "Rotate Component" ), HK_ROTATE_COMPONENT, 'R' ); +static Ki_HotkeyInfo HkMoveComponent( wxT( "Move Component" ), HK_MOVE_COMPONENT, 'M' ); +static Ki_HotkeyInfo HkMove2Drag( wxT( "Switch move block to drag block" ), + HK_MOVEBLOCK_TO_DRAGBLOCK, '\t' ); +static Ki_HotkeyInfo HkInsert( wxT( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSERT ); +static Ki_HotkeyInfo HkDelete( wxT( "Delete Item" ), HK_DELETE, WXK_DELETE ); +static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset local coord." ), HK_RESET_LOCAL_COORD, ' ' ); +static Ki_HotkeyInfo HkNextSearch( wxT( "Next Search" ), HK_NEXT_SEARCH, WXK_F5 ); +static Ki_HotkeyInfo HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 ); +static Ki_HotkeyInfo HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 ); +static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 ); +static Ki_HotkeyInfo HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1 ); +static Ki_HotkeyInfo HkHelp( wxT( "Help: this message" ), HK_HELP, '?' ); // List of hotkey descriptors for schematic -static Ki_HotkeyInfo *s_Schematic_Hotkey_List[] = { - &HkHelp, - &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, - &HkNextSearch, &HkResetLocalCoord, - &HkDelete, &HkInsert, &HkMove2Drag, - &HkMoveComponent, &HkAddComponent, - &HkRotateComponent, &HkMirrorXComponent, &HkMirrorYComponent, & HkOrientNormalComponent, - &HkBeginWire, - NULL +static Ki_HotkeyInfo* s_Schematic_Hotkey_List[] = { + &HkHelp, + &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, + &HkNextSearch, &HkResetLocalCoord, + &HkDelete, &HkInsert, &HkMove2Drag, + &HkMoveComponent, &HkAddComponent, + &HkRotateComponent, &HkMirrorXComponent, &HkMirrorYComponent, &HkOrientNormalComponent, + &HkBeginWire, + NULL }; // Library editor: -static Ki_HotkeyInfo HkInsertPin(wxT("Repeat Pin"), HK_REPEAT_LAST, WXK_INSERT); +static Ki_HotkeyInfo HkInsertPin( wxT( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT ); // List of hotkey descriptors for libray editor -static Ki_HotkeyInfo *s_LibEdit_Hotkey_List[] = +static Ki_HotkeyInfo* s_LibEdit_Hotkey_List[] = { - &HkHelp, - &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, - &HkResetLocalCoord, - &HkInsertPin, - NULL + &HkHelp, + &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, + &HkResetLocalCoord, + &HkInsertPin, + NULL }; /****************************************************/ -static wxString ReturnKeyNameFromKeyCode(int keycode) +static wxString ReturnKeyNameFromKeyCode( int keycode ) /****************************************************/ + /* - * return the key name from the key code - * Only some wxWidgets key values are handled for function key - * @param key = key code (ascii value, or wxWidgets value for function keys) - * @return the key name wxString -*/ + * return the key name from the key code + * Only some wxWidgets key values are handled for function key + * @param key = key code (ascii value, or wxWidgets value for function keys) + * @return the key name wxString + */ { -wxString keyname, modifier, fullkeyname; - - if ( keycode & GR_KB_CTRL) modifier << wxT("Ctrl "); - if ( keycode & GR_KB_ALT) modifier << wxT("Alt "); - if ( keycode & GR_KB_SHIFT) modifier << wxT("Shift "); - keycode &= ~(GR_KB_CTRL|GR_KB_ALT|GR_KB_SHIFT); + wxString keyname, modifier, fullkeyname; - switch ( keycode ) - { - default: - keyname.Printf(wxT("%c"), keycode); - break; - - case WXK_F1: - case WXK_F2: - case WXK_F3: - case WXK_F4: - case WXK_F5: - case WXK_F6: - case WXK_F7: - case WXK_F8: - case WXK_F9: - case WXK_F10: - case WXK_F11: - case WXK_F12: - keyname.Printf(wxT("F%d"), keycode - WXK_F1 + 1); - break; - - case ' ': - keyname = wxT("space"); - break; + if( keycode & GR_KB_CTRL ) + modifier << wxT( "Ctrl " ); + if( keycode & GR_KB_ALT ) + modifier << wxT( "Alt " ); + if( keycode & GR_KB_SHIFT ) + modifier << wxT( "Shift " ); + keycode &= ~(GR_KB_CTRL | GR_KB_ALT | GR_KB_SHIFT); - case '\t': - keyname = wxT("Tab"); - break; + switch( keycode ) + { + default: + keyname.Printf( wxT( "%c" ), keycode ); + break; - case WXK_DELETE: - keyname = wxT("Delete"); - break; + case WXK_F1: + case WXK_F2: + case WXK_F3: + case WXK_F4: + case WXK_F5: + case WXK_F6: + case WXK_F7: + case WXK_F8: + case WXK_F9: + case WXK_F10: + case WXK_F11: + case WXK_F12: + keyname.Printf( wxT( "F%d" ), keycode - WXK_F1 + 1 ); + break; - case WXK_INSERT: - keyname = wxT("Insert"); - break; - } - - fullkeyname = modifier + keyname; - return keyname; + case ' ': + keyname = wxT( "space" ); + break; + + case '\t': + keyname = wxT( "Tab" ); + break; + + case WXK_DELETE: + keyname = wxT( "Delete" ); + break; + + case WXK_INSERT: + keyname = wxT( "Insert" ); + break; + } + + fullkeyname = modifier + keyname; + return keyname; } + /****************************************************************************/ -static void DisplayHotkeyList(WinEDA_DrawFrame * frame, Ki_HotkeyInfo ** List) +static void DisplayHotkeyList( WinEDA_DrawFrame* frame, Ki_HotkeyInfo** List ) /*****************************************************************************/ + /* - * Displays the current hotkey list - * @param frame = current open frame - * @param List = pointer to a Ki_HotkeyInfo list of commands - * @return none -*/ + * Displays the current hotkey list + * @param frame = current open frame + * @param List = pointer to a Ki_HotkeyInfo list of commands + * @return none + */ { -wxString keyname; - - wxString msg = _("Current hotkey list:\n\n"); - for ( ; * List != NULL; List++ ) - { - Ki_HotkeyInfo * hk_decr = * List; - if ( hk_decr->m_InfoMsg.IsEmpty() ) break; - msg += _("key "); - keyname = ReturnKeyNameFromKeyCode(hk_decr->m_KeyCode); - msg += keyname + wxT(": ") + hk_decr->m_InfoMsg + wxT("\n"); - } - DisplayInfo(frame, msg); + wxString keyname; + + wxString msg = _( "Current hotkey list:\n\n" ); + + for( ; *List != NULL; List++ ) + { + Ki_HotkeyInfo* hk_decr = *List; + if( hk_decr->m_InfoMsg.IsEmpty() ) + break; + msg += _( "key " ); + keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); + msg += keyname + wxT( ": " ) + hk_decr->m_InfoMsg + wxT( "\n" ); + } + + DisplayInfo( frame, msg ); } + /******************************************************************/ -static int GetCommandCodeFromHotkey(int key, Ki_HotkeyInfo ** List) +static int GetCommandCodeFromHotkey( int key, Ki_HotkeyInfo** List ) /******************************************************************/ + /* - * Return an id identifier fron a key code for OnHotKey() function - * @param key = key code (ascii value, or wxWidgets value for function keys - * @param List = pointer to a Ki_HotkeyInfo list of commands - * @return the corresponding function identifier from the Ki_HotkeyInfo List -*/ + * Return an id identifier fron a key code for OnHotKey() function + * @param key = key code (ascii value, or wxWidgets value for function keys + * @param List = pointer to a Ki_HotkeyInfo list of commands + * @return the corresponding function identifier from the Ki_HotkeyInfo List + */ { - for ( ; * List != NULL; List++ ) - { - Ki_HotkeyInfo * hk_decr = * List; - if ( hk_decr->m_KeyCode == key ) return hk_decr->m_Idcommand; - } - - return HK_NOT_FOUND; + for( ; *List != NULL; List++ ) + { + Ki_HotkeyInfo* hk_decr = *List; + if( hk_decr->m_KeyCode == key ) + return hk_decr->m_Idcommand; + } + + return HK_NOT_FOUND; } + /***********************************************************/ -void WinEDA_SchematicFrame::OnHotKey(wxDC * DC, int hotkey, - EDA_BaseStruct * DrawStruct) +void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, + EDA_BaseStruct* DrawStruct ) /***********************************************************/ + /* Hot keys. Some commands are relatives to the item under the mouse cursor - Commands are case insensitive - Zoom commands are not managed here -*/ + * Commands are case insensitive + * Zoom commands are not managed here + */ { -bool PopupOn = m_CurrentScreen->m_CurrentItem && - m_CurrentScreen->m_CurrentItem->m_Flags; -bool RefreshToolBar = FALSE; // We must refresh tool bar when the undo/redo tool state is modified - - if ( hotkey == 0 ) return; + bool PopupOn = m_CurrentScreen->GetCurItem() + && m_CurrentScreen->GetCurItem()->m_Flags; + bool RefreshToolBar = FALSE; // We must refresh tool bar when the undo/redo tool state is modified -wxPoint MousePos = m_CurrentScreen->m_MousePosition; + if( hotkey == 0 ) + return; - /* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */ - if( (hotkey >= 'a') && (hotkey <= 'z') ) hotkey += 'A' - 'a'; - - // Search commnd from key : - switch ( GetCommandCodeFromHotkey(hotkey, s_Schematic_Hotkey_List) ) - { - default: - case HK_NOT_FOUND: - return; - break; - - case HK_HELP: // Display Current hotkey list - DisplayHotkeyList(this, s_Schematic_Hotkey_List); - break; + wxPoint MousePos = m_CurrentScreen->m_MousePosition; - case HK_ZOOM_IN: - case HK_ZOOM_OUT: - case HK_ZOOM_REDRAW: - case HK_ZOOM_CENTER: - case HK_RESET_LOCAL_COORD: - break; + /* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */ + if( (hotkey >= 'a') && (hotkey <= 'z') ) + hotkey += 'A' - 'a'; - case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving - HandleBlockEndByPopUp(BLOCK_DRAG, DC); - break; + // Search commnd from key : + switch( GetCommandCodeFromHotkey( hotkey, s_Schematic_Hotkey_List ) ) + { + default: + case HK_NOT_FOUND: + return; + break; - case HK_DELETE: - if ( PopupOn ) break; - RefreshToolBar = LocateAndDeleteItem(this, DC); - m_CurrentScreen->SetModify(); - m_CurrentScreen->m_CurrentItem = NULL; - TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); - break; + case HK_HELP: // Display Current hotkey list + DisplayHotkeyList( this, s_Schematic_Hotkey_List ); + break; - case HK_REPEAT_LAST: - if ( g_ItemToRepeat && (g_ItemToRepeat->m_Flags == 0) ) - { - RepeatDrawItem(DC); - } - else wxBell(); - break; + case HK_ZOOM_IN: + case HK_ZOOM_OUT: + case HK_ZOOM_REDRAW: + case HK_ZOOM_CENTER: + case HK_RESET_LOCAL_COORD: + break; - case HK_NEXT_SEARCH : - if ( g_LastSearchIsMarker ) WinEDA_SchematicFrame::FindMarker(1); - else FindSchematicItem(wxEmptyString, 2); - break; + case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving + HandleBlockEndByPopUp( BLOCK_DRAG, DC ); + break; - case HK_ADD_NEW_COMPONENT: // Add component - if ( DrawStruct && DrawStruct->m_Flags ) break; - // switch to m_ID_current_state = ID_COMPONENT_BUTT; - if ( m_ID_current_state != ID_COMPONENT_BUTT ) SetToolID( ID_COMPONENT_BUTT, wxCURSOR_PENCIL, _("Add Component")); - OnLeftClick(DC, MousePos); - break; + case HK_DELETE: + if( PopupOn ) + break; + RefreshToolBar = LocateAndDeleteItem( this, DC ); + m_CurrentScreen->SetModify(); + m_CurrentScreen->SetCurItem( NULL ); + TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + break; - case HK_BEGIN_WIRE: // Add wire - if ( DrawStruct ) // An item is selected. If edited and not a wire, a new command is not possible - { - if ( DrawStruct->m_Flags ) // Item selected and edition in progress - { - if (DrawStruct->m_StructType == DRAW_SEGMENT_STRUCT_TYPE ) - { - EDA_DrawLineStruct * segment = (EDA_DrawLineStruct *)DrawStruct; - if ( segment->m_Layer != LAYER_WIRE ) break; - } - else break; - } - } - // switch to m_ID_current_state = ID_WIRE_BUTT; - if ( m_ID_current_state != ID_WIRE_BUTT ) SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _("Add Wire")); - OnLeftClick(DC, MousePos); + case HK_REPEAT_LAST: + if( g_ItemToRepeat && (g_ItemToRepeat->m_Flags == 0) ) + { + RepeatDrawItem( DC ); + } + else + wxBell(); + break; + + case HK_NEXT_SEARCH: + if( g_LastSearchIsMarker ) + WinEDA_SchematicFrame::FindMarker( 1 ); + else + FindSchematicItem( wxEmptyString, 2 ); + break; + + case HK_ADD_NEW_COMPONENT: // Add component + if( DrawStruct && DrawStruct->m_Flags ) break; - case HK_ROTATE_COMPONENT: // Component Rotation - if ( DrawStruct == NULL ) - { - DrawStruct = PickStruct( GetScreen()->m_Curseur, - GetScreen()->EEDrawList, LIBITEM|TEXTITEM|LABELITEM ); - if ( DrawStruct == NULL ) break; - if ( DrawStruct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE ) - DrawStruct = LocateSmallestComponent( GetScreen() ); - if ( DrawStruct == NULL ) break; - } - switch (DrawStruct->m_StructType) - { - case DRAW_LIB_ITEM_STRUCT_TYPE: - if ( DrawStruct->m_Flags == 0 ) - { - SaveCopyInUndoList(DrawStruct, IS_CHANGED); - RefreshToolBar = TRUE; - } - - CmpRotationMiroir( - (EDA_SchComponentStruct *) DrawStruct, DC, CMP_ROTATE_COUNTERCLOCKWISE ); - break; + // switch to m_ID_current_state = ID_COMPONENT_BUTT; + if( m_ID_current_state != ID_COMPONENT_BUTT ) + SetToolID( ID_COMPONENT_BUTT, wxCURSOR_PENCIL, _( "Add Component" ) ); + OnLeftClick( DC, MousePos ); + break; - case DRAW_TEXT_STRUCT_TYPE: - case DRAW_LABEL_STRUCT_TYPE: - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - if ( DrawStruct->m_Flags == 0 ) - { - SaveCopyInUndoList(DrawStruct, IS_CHANGED); - RefreshToolBar = TRUE; - } - ChangeTextOrient( (DrawTextStruct*)DrawStruct, DC); - break; - } - break; + case HK_BEGIN_WIRE: // Add wire + if( DrawStruct ) // An item is selected. If edited and not a wire, a new command is not possible + { + if( DrawStruct->m_Flags ) // Item selected and edition in progress + { + if( DrawStruct->m_StructType == DRAW_SEGMENT_STRUCT_TYPE ) + { + EDA_DrawLineStruct* segment = (EDA_DrawLineStruct*) DrawStruct; + if( segment->m_Layer != LAYER_WIRE ) + break; + } + else + break; + } + } - case HK_MIRROR_Y_COMPONENT: // Mirror Y (Component) - if ( DrawStruct == NULL ) - DrawStruct = LocateSmallestComponent( GetScreen() ); - if ( DrawStruct ) - { - if ( DrawStruct->m_Flags == 0 ) - { - SaveCopyInUndoList(DrawStruct, IS_CHANGED); - RefreshToolBar = TRUE; - } - CmpRotationMiroir( - (EDA_SchComponentStruct *) DrawStruct, DC, CMP_MIROIR_Y ); - } - break; + // switch to m_ID_current_state = ID_WIRE_BUTT; + if( m_ID_current_state != ID_WIRE_BUTT ) + SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add Wire" ) ); + OnLeftClick( DC, MousePos ); + break; - case HK_MIRROR_X_COMPONENT: // Mirror X (Component) - if ( DrawStruct == NULL ) - DrawStruct = LocateSmallestComponent( GetScreen() ); - if ( DrawStruct ) - { - if ( DrawStruct->m_Flags == 0 ) - { - SaveCopyInUndoList(DrawStruct, IS_CHANGED); - RefreshToolBar = TRUE; - } - CmpRotationMiroir( - (EDA_SchComponentStruct *) DrawStruct, DC, CMP_MIROIR_X ); - } - break; + case HK_ROTATE_COMPONENT: // Component Rotation + if( DrawStruct == NULL ) + { + DrawStruct = PickStruct( GetScreen()->m_Curseur, + GetScreen()->EEDrawList, LIBITEM | TEXTITEM | LABELITEM ); + if( DrawStruct == NULL ) + break; + if( DrawStruct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE ) + DrawStruct = LocateSmallestComponent( GetScreen() ); + if( DrawStruct == NULL ) + break; + } - case HK_ORIENT_NORMAL_COMPONENT: // Orient 0, no mirror (Component) - if ( DrawStruct == NULL ) - DrawStruct = LocateSmallestComponent( GetScreen() ); - if ( DrawStruct ) - { - if ( DrawStruct->m_Flags == 0 ) - { - SaveCopyInUndoList(DrawStruct, IS_CHANGED); - RefreshToolBar = TRUE; - } - CmpRotationMiroir( - (EDA_SchComponentStruct *) DrawStruct, DC, CMP_NORMAL ); - TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); - } - break; + switch( DrawStruct->m_StructType ) + { + case DRAW_LIB_ITEM_STRUCT_TYPE: + if( DrawStruct->m_Flags == 0 ) + { + SaveCopyInUndoList( DrawStruct, IS_CHANGED ); + RefreshToolBar = TRUE; + } - case HK_MOVE_COMPONENT: // Start move Component - if ( PopupOn ) break; - if ( DrawStruct == NULL ) - DrawStruct = LocateSmallestComponent( GetScreen() ); - if ( DrawStruct && (DrawStruct->m_Flags ==0) ) - { - m_CurrentScreen->m_CurrentItem = DrawStruct; - Process_Move_Item(m_CurrentScreen->m_CurrentItem, DC); - } - break; - } - - if ( RefreshToolBar ) SetToolbars(); + CmpRotationMiroir( + (EDA_SchComponentStruct*) DrawStruct, DC, CMP_ROTATE_COUNTERCLOCKWISE ); + break; + + case DRAW_TEXT_STRUCT_TYPE: + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + if( DrawStruct->m_Flags == 0 ) + { + SaveCopyInUndoList( DrawStruct, IS_CHANGED ); + RefreshToolBar = TRUE; + } + ChangeTextOrient( (DrawTextStruct*) DrawStruct, DC ); + break; + } + + break; + + case HK_MIRROR_Y_COMPONENT: // Mirror Y (Component) + if( DrawStruct == NULL ) + DrawStruct = LocateSmallestComponent( GetScreen() ); + if( DrawStruct ) + { + if( DrawStruct->m_Flags == 0 ) + { + SaveCopyInUndoList( DrawStruct, IS_CHANGED ); + RefreshToolBar = TRUE; + } + CmpRotationMiroir( + (EDA_SchComponentStruct*) DrawStruct, DC, CMP_MIROIR_Y ); + } + break; + + case HK_MIRROR_X_COMPONENT: // Mirror X (Component) + if( DrawStruct == NULL ) + DrawStruct = LocateSmallestComponent( GetScreen() ); + if( DrawStruct ) + { + if( DrawStruct->m_Flags == 0 ) + { + SaveCopyInUndoList( DrawStruct, IS_CHANGED ); + RefreshToolBar = TRUE; + } + CmpRotationMiroir( + (EDA_SchComponentStruct*) DrawStruct, DC, CMP_MIROIR_X ); + } + break; + + case HK_ORIENT_NORMAL_COMPONENT: // Orient 0, no mirror (Component) + if( DrawStruct == NULL ) + DrawStruct = LocateSmallestComponent( GetScreen() ); + if( DrawStruct ) + { + if( DrawStruct->m_Flags == 0 ) + { + SaveCopyInUndoList( DrawStruct, IS_CHANGED ); + RefreshToolBar = TRUE; + } + CmpRotationMiroir( + (EDA_SchComponentStruct*) DrawStruct, DC, CMP_NORMAL ); + TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + } + break; + + case HK_MOVE_COMPONENT: // Start move Component + if( PopupOn ) + break; + if( DrawStruct == NULL ) + DrawStruct = LocateSmallestComponent( GetScreen() ); + if( DrawStruct && (DrawStruct->m_Flags ==0) ) + { + m_CurrentScreen->SetCurItem( DrawStruct ); + Process_Move_Item( m_CurrentScreen->GetCurItem(), DC ); + } + break; + } + + if( RefreshToolBar ) + SetToolbars(); } /***********************************************************/ -void WinEDA_LibeditFrame::OnHotKey(wxDC * DC, int hotkey, - EDA_BaseStruct * DrawStruct) +void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, + EDA_BaseStruct* DrawStruct ) /***********************************************************/ + /* Hot keys for the component editot. Some commands are relatives to the item under the mouse cursor - Commands are case insensitive - Zoom commands are not managed here -*/ + * Commands are case insensitive + * Zoom commands are not managed here + */ { -bool PopupOn = m_CurrentScreen->m_CurrentItem && - m_CurrentScreen->m_CurrentItem->m_Flags; + bool PopupOn = m_CurrentScreen->GetCurItem() + && m_CurrentScreen->GetCurItem()->m_Flags; -bool RefreshToolBar = FALSE; // We must refresh tool bar when the undo/redo tool state is modified - - if ( hotkey == 0 ) return; + bool RefreshToolBar = FALSE; // We must refresh tool bar when the undo/redo tool state is modified -wxPoint MousePos = m_CurrentScreen->m_MousePosition; + if( hotkey == 0 ) + return; - /* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */ - if( (hotkey >= 'a') && (hotkey <= 'z') ) hotkey += 'A' - 'a'; - switch ( GetCommandCodeFromHotkey(hotkey, s_LibEdit_Hotkey_List) ) - { - default: - case HK_NOT_FOUND: - return; - break; - - case HK_HELP: // Display Current hotkey list - DisplayHotkeyList(this, s_LibEdit_Hotkey_List); - break; + wxPoint MousePos = m_CurrentScreen->m_MousePosition; - case HK_ZOOM_IN: - case HK_ZOOM_OUT: - case HK_ZOOM_REDRAW: - case HK_ZOOM_CENTER: - case HK_RESET_LOCAL_COORD: - break; + /* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */ + if( (hotkey >= 'a') && (hotkey <= 'z') ) + hotkey += 'A' - 'a'; - case HK_REPEAT_LAST: - if ( LibItemToRepeat && (LibItemToRepeat->m_Flags == 0) && - (LibItemToRepeat->m_StructType == COMPONENT_PIN_DRAW_TYPE) ) - { - RepeatPinItem(DC, (LibDrawPin*) LibItemToRepeat); - } - else wxBell(); - break; - } + switch( GetCommandCodeFromHotkey( hotkey, s_LibEdit_Hotkey_List ) ) + { + default: + case HK_NOT_FOUND: + return; + break; - if ( RefreshToolBar ) SetToolbars(); + case HK_HELP: // Display Current hotkey list + DisplayHotkeyList( this, s_LibEdit_Hotkey_List ); + break; + + case HK_ZOOM_IN: + case HK_ZOOM_OUT: + case HK_ZOOM_REDRAW: + case HK_ZOOM_CENTER: + case HK_RESET_LOCAL_COORD: + break; + + case HK_REPEAT_LAST: + if( LibItemToRepeat && (LibItemToRepeat->m_Flags == 0) + && (LibItemToRepeat->m_StructType == COMPONENT_PIN_DRAW_TYPE) ) + { + RepeatPinItem( DC, (LibDrawPin*) LibItemToRepeat ); + } + else + wxBell(); + break; + } + + if( RefreshToolBar ) + SetToolbars(); } - diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp index da84ab6927..61a97e79b2 100644 --- a/eeschema/load_one_schematic_file.cpp +++ b/eeschema/load_one_schematic_file.cpp @@ -1,6 +1,6 @@ - /****************************************/ - /* Module to load/save EESchema files. */ - /****************************************/ +/****************************************/ +/* Module to load/save EESchema files. */ +/****************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -15,955 +15,1014 @@ #include "id.h" /* Format des fichiers: - - entete: -EESchema Schematic File Version n - - liste des librairies utilisees -LIBS:lib1,lib2,... - - - description des elements: - - ici Dimensions du schema, cartouche..: -$Descr A3 xx yy (format A3 (A..A0 / A..E / "user") xx yy = dims internes ) -$EndDescr - - - ici: polyline -P L 0 3 - 2208 1008 - 2208 1136 - 2128 1136 - - - ici: Segment (wire, bus) ( 1; W = segment type Wire, 2: W = Wire B = Bus - 3: L ou B = epaisseur ( L = ligne, B = bus) -W W L (W B B si bus) - 1856 1008 1856 1136 (debut X,Y fin X,Y) - - - ici: Raccord (wire, bus) -R W L - 1856 1008 1856 1136 (debut X,Y fin X,Y) - - - ici: Sheet ( Sous-feuille de hierarchie) -$Sheet -S 1856 1008 1856 1136 (debut X,Y fin X,Y) -F0 "texte" X X posx posy ; sheetname -F1 "texte" X X posx posy ; filename -Fn "label" type side posx posy size ; n lignes de label -$EndSheet - - - ici: composant -$Comp -L CAPACITOR C1 H H -30863 -14794 1968 1184 nom, ref, dir et pos - 1 2016 1136 1904 1024 2128 1248 multi, posx,y, rect encadrement - 1 0 0 -1 matrice de rotation/miroir -$EndComp -*/ + * - entete: + * EESchema Schematic File Version n + * - liste des librairies utilisees + * LIBS:lib1,lib2,... + * + * - description des elements: + * - ici Dimensions du schema, cartouche..: + * $Descr A3 xx yy (format A3 (A..A0 / A..E / "user") xx yy = dims internes ) + * $EndDescr + * + * - ici: polyline + * P L 0 3 + * 2208 1008 + * 2208 1136 + * 2128 1136 + * + * - ici: Segment (wire, bus) ( 1; W = segment type Wire, 2: W = Wire B = Bus + * 3: L ou B = epaisseur ( L = ligne, B = bus) + * W W L (W B B si bus) + * 1856 1008 1856 1136 (debut X,Y fin X,Y) + * + * - ici: Raccord (wire, bus) + * R W L + * 1856 1008 1856 1136 (debut X,Y fin X,Y) + * + * - ici: Sheet ( Sous-feuille de hierarchie) + * $Sheet + * S 1856 1008 1856 1136 (debut X,Y fin X,Y) + * F0 "texte" X X posx posy ; sheetname + * F1 "texte" X X posx posy ; filename + * Fn "label" type side posx posy size ; n lignes de label + * $EndSheet + * + * - ici: composant + * $Comp + * L CAPACITOR C1 H H -30863 -14794 1968 1184 nom, ref, dir et pos + * 1 2016 1136 1904 1024 2128 1248 multi, posx,y, rect encadrement + * 1 0 0 -1 matrice de rotation/miroir + * $EndComp + */ /* Fonctions locales */ -static int ReadPartDescr(wxWindow * frame, char *Line, FILE *f, BASE_SCREEN *Window); -static int ReadSheetDescr(wxWindow * frame, char *Line, FILE *f, BASE_SCREEN * Window); -static int ReadSchemaDescr(wxWindow * frame, char *Line, FILE *f, BASE_SCREEN * Window); -static void LoadLayers(FILE *f, int * linecnt); +static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window ); +static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window ); +static int ReadSchemaDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window ); +static void LoadLayers( FILE* f, int* linecnt ); /* Variables locales */ -static int LineCount; /* Decompte de num de ligne lue dans eeload() */ -static wxString MsgDiag; /* Error and log messages */ +static int LineCount; /* Decompte de num de ligne lue dans eeload() */ +static wxString MsgDiag; /* Error and log messages */ /************************************************************************************************/ -bool WinEDA_SchematicFrame::LoadOneEEFile(SCH_SCREEN *screen, const wxString & FullFileName) +bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFileName ) /************************************************************************************************/ + /* Routine to load an EESchema file. -Returns TRUE if file has been loaded (at list partially.) -*/ + * Returns TRUE if file has been loaded (at list partially.) + */ { -char Line[1024], * SLine; -char Name1[256], - Name2[256]; -int ii, layer, orient, size; -wxPoint pos; -bool Failed = FALSE; -EDA_BaseStruct *Phead, *Pnext; -DrawJunctionStruct *ConnectionStruct; -DrawPolylineStruct *PolylineStruct; -EDA_DrawLineStruct * SegmentStruct; -DrawBusEntryStruct * RaccordStruct; -DrawMarkerStruct * MarkerStruct; -DrawNoConnectStruct * NoConnectStruct; + char Line[1024], * SLine; + char Name1[256], + Name2[256]; + int ii, layer, orient, size; + wxPoint pos; + bool Failed = FALSE; + EDA_BaseStruct* Phead, * Pnext; + DrawJunctionStruct* ConnectionStruct; + DrawPolylineStruct* PolylineStruct; + EDA_DrawLineStruct* SegmentStruct; + DrawBusEntryStruct* RaccordStruct; + DrawMarkerStruct* MarkerStruct; + DrawNoConnectStruct* NoConnectStruct; -FILE *f; + FILE* f; - if ( screen == NULL ) return FALSE; - if( FullFileName.IsEmpty() ) return FALSE; + if( screen == NULL ) + return FALSE; + if( FullFileName.IsEmpty() ) + return FALSE; - screen->m_CurrentItem = NULL; + screen->SetCurItem( NULL ); - LineCount = 1; - if ((f = wxFopen(FullFileName, wxT("rt")) ) == NULL) - { - MsgDiag = _("Failed to open ") + FullFileName; - DisplayError(this, MsgDiag); - return FALSE; - } + LineCount = 1; + if( ( f = wxFopen( FullFileName, wxT( "rt" ) ) ) == NULL ) + { + MsgDiag = _( "Failed to open " ) + FullFileName; + DisplayError( this, MsgDiag ); + return FALSE; + } - MsgDiag = _("Loading ") + FullFileName; - PrintMsg(MsgDiag); + MsgDiag = _( "Loading " ) + FullFileName; + PrintMsg( MsgDiag ); - if (fgets(Line, 1024 - 1, f) == NULL || - strncmp(Line+9, SCHEMATIC_HEAD_STRING, sizeof(SCHEMATIC_HEAD_STRING) - 1) - != 0) - { - MsgDiag = FullFileName + _(" is NOT EESchema file"); - DisplayError(this, MsgDiag); - fclose(f); - return FALSE; - } + if( fgets( Line, 1024 - 1, f ) == NULL + || strncmp( Line + 9, SCHEMATIC_HEAD_STRING, sizeof(SCHEMATIC_HEAD_STRING) - 1 ) + != 0 ) + { + MsgDiag = FullFileName + _( " is NOT EESchema file" ); + DisplayError( this, MsgDiag ); + fclose( f ); + return FALSE; + } - LineCount++; - if(fgets(Line, 1024 - 1, f) == NULL || strncmp(Line, "LIBS:", 5) != 0) - { - MsgDiag = FullFileName + _(" is NOT EESchema file"); - DisplayError(this, MsgDiag); - fclose(f); - return FALSE; - } + LineCount++; + if( fgets( Line, 1024 - 1, f ) == NULL || strncmp( Line, "LIBS:", 5 ) != 0 ) + { + MsgDiag = FullFileName + _( " is NOT EESchema file" ); + DisplayError( this, MsgDiag ); + fclose( f ); + return FALSE; + } - LoadLayers(f, &LineCount); + LoadLayers( f, &LineCount ); - while (!feof(f) && GetLine(f, Line, &LineCount, sizeof(Line)) != NULL) - { - SLine = Line; - while( (*SLine != ' ' ) && *SLine ) SLine++; - switch(Line[0]) - { - case '$': /* identification de bloc */ - if(Line[1] == 'C') - { - Failed = ReadPartDescr(this, Line, f, screen); - } - else if(Line[1] == 'S') - { - Failed = ReadSheetDescr(this, Line, f, screen); - } - else if(Line[1] == 'D') - { - Failed = ReadSchemaDescr(this, Line, f, screen); - } - break; + while( !feof( f ) && GetLine( f, Line, &LineCount, sizeof(Line) ) != NULL ) + { + SLine = Line; + while( (*SLine != ' ' ) && *SLine ) + SLine++; - case 'L': /* Its a library item. */ - Failed = ReadPartDescr(this, Line, f, screen); - break; /* Fin lecture 1 composant */ + switch( Line[0] ) + { + case '$': /* identification de bloc */ + if( Line[1] == 'C' ) + { + Failed = ReadPartDescr( this, Line, f, screen ); + } + else if( Line[1] == 'S' ) + { + Failed = ReadSheetDescr( this, Line, f, screen ); + } + else if( Line[1] == 'D' ) + { + Failed = ReadSchemaDescr( this, Line, f, screen ); + } + break; + + case 'L': /* Its a library item. */ + Failed = ReadPartDescr( this, Line, f, screen ); + break; /* Fin lecture 1 composant */ - case 'W': /* Its a Segment (WIRE or BUS) item. */ - if( sscanf(SLine, "%s %s", Name1, Name2) != 2 ) - { - MsgDiag.Printf( - wxT("EESchema file Segment struct error at line %d, aborted"), - LineCount); - Failed = TRUE; - break; - } - layer = LAYER_NOTES; - if( Name1[0] == 'W' ) layer = LAYER_WIRE; - if( Name1[0] == 'B' ) layer = LAYER_BUS; + case 'W': /* Its a Segment (WIRE or BUS) item. */ + if( sscanf( SLine, "%s %s", Name1, Name2 ) != 2 ) + { + MsgDiag.Printf( + wxT( "EESchema file Segment struct error at line %d, aborted" ), + LineCount ); + Failed = TRUE; + break; + } + layer = LAYER_NOTES; + if( Name1[0] == 'W' ) + layer = LAYER_WIRE; + if( Name1[0] == 'B' ) + layer = LAYER_BUS; - SegmentStruct = new EDA_DrawLineStruct(wxPoint(0,0),layer); + SegmentStruct = new EDA_DrawLineStruct( wxPoint( 0, 0 ), layer ); - LineCount++; - if (fgets(Line, 256 - 1, f) == NULL || - sscanf(Line, "%d %d %d %d ", - &SegmentStruct->m_Start.x,&SegmentStruct->m_Start.y, - &SegmentStruct->m_End.x,&SegmentStruct->m_End.y) != 4 ) - { - MsgDiag.Printf( - wxT("EESchema file Segment struct error at line %d, aborted"), - LineCount); - Failed = TRUE; - delete SegmentStruct; - break; - } + LineCount++; + if( fgets( Line, 256 - 1, f ) == NULL + || sscanf( Line, "%d %d %d %d ", + &SegmentStruct->m_Start.x, &SegmentStruct->m_Start.y, + &SegmentStruct->m_End.x, &SegmentStruct->m_End.y ) != 4 ) + { + MsgDiag.Printf( + wxT( "EESchema file Segment struct error at line %d, aborted" ), + LineCount ); + Failed = TRUE; + delete SegmentStruct; + break; + } - if (!Failed) - { - SegmentStruct->Pnext = screen->EEDrawList; - screen->EEDrawList = (EDA_BaseStruct *) SegmentStruct; - } - break; + if( !Failed ) + { + SegmentStruct->Pnext = screen->EEDrawList; + screen->EEDrawList = (EDA_BaseStruct*) SegmentStruct; + } + break; - case 'E': /* Its a Raccord (WIRE or BUS) item. */ - if( sscanf(SLine, "%s %s", Name1, Name2) != 2 ) - { - MsgDiag.Printf( - wxT("EESchema file Raccord struct error at line %d, aborted"), - LineCount); - Failed = TRUE; - break; - } + case 'E': /* Its a Raccord (WIRE or BUS) item. */ + if( sscanf( SLine, "%s %s", Name1, Name2 ) != 2 ) + { + MsgDiag.Printf( + wxT( "EESchema file Raccord struct error at line %d, aborted" ), + LineCount ); + Failed = TRUE; + break; + } - ii = WIRE_TO_BUS; - if( Name1[0] == 'B' ) ii = BUS_TO_BUS; - RaccordStruct = new DrawBusEntryStruct(wxPoint(0,0), '\\', ii); - LineCount++; - if (fgets(Line, 256 - 1, f) == NULL || - sscanf(Line, "%d %d %d %d ", - &RaccordStruct->m_Pos.x,&RaccordStruct->m_Pos.y, - &RaccordStruct->m_Size.x,&RaccordStruct->m_Size.y) != 4 ) - { - MsgDiag.Printf( - wxT("EESchema file Raccord struct error at line %d, aborted"), - LineCount); - Failed = TRUE; - delete RaccordStruct; - break; - } + ii = WIRE_TO_BUS; + if( Name1[0] == 'B' ) + ii = BUS_TO_BUS; + RaccordStruct = new DrawBusEntryStruct( wxPoint( 0, 0 ), '\\', ii ); + LineCount++; + if( fgets( Line, 256 - 1, f ) == NULL + || sscanf( Line, "%d %d %d %d ", + &RaccordStruct->m_Pos.x, &RaccordStruct->m_Pos.y, + &RaccordStruct->m_Size.x, &RaccordStruct->m_Size.y ) != 4 ) + { + MsgDiag.Printf( + wxT( "EESchema file Raccord struct error at line %d, aborted" ), + LineCount ); + Failed = TRUE; + delete RaccordStruct; + break; + } - if (!Failed) - { - RaccordStruct->m_Size.x -= RaccordStruct->m_Pos.x; - RaccordStruct->m_Size.y -= RaccordStruct->m_Pos.y; - RaccordStruct->Pnext = screen->EEDrawList; - screen->EEDrawList = RaccordStruct; - } - break; + if( !Failed ) + { + RaccordStruct->m_Size.x -= RaccordStruct->m_Pos.x; + RaccordStruct->m_Size.y -= RaccordStruct->m_Pos.y; + RaccordStruct->Pnext = screen->EEDrawList; + screen->EEDrawList = RaccordStruct; + } + break; - case 'P': /* Its a polyline item. */ - if (sscanf(SLine, "%s %s %d", Name1, Name2, &ii) != 3 ) - { - MsgDiag.Printf( - wxT("EESchema file polyline struct error at line %d, aborted"), - LineCount); - Failed = TRUE; - break; - } - layer = LAYER_NOTES; - if( Name2[0] == 'W' ) layer = LAYER_WIRE; - if( Name2[0] == 'B' ) layer = LAYER_BUS; + case 'P': /* Its a polyline item. */ + if( sscanf( SLine, "%s %s %d", Name1, Name2, &ii ) != 3 ) + { + MsgDiag.Printf( + wxT( "EESchema file polyline struct error at line %d, aborted" ), + LineCount ); + Failed = TRUE; + break; + } + layer = LAYER_NOTES; + if( Name2[0] == 'W' ) + layer = LAYER_WIRE; + if( Name2[0] == 'B' ) + layer = LAYER_BUS; - PolylineStruct = new DrawPolylineStruct(layer); + PolylineStruct = new DrawPolylineStruct( layer ); - PolylineStruct->m_NumOfPoints = ii; - PolylineStruct->m_Points = (int *) MyZMalloc(sizeof(int) * 2 * - PolylineStruct->m_NumOfPoints); - for (ii = 0; ii < PolylineStruct->m_NumOfPoints; ii++) - { - LineCount++; - if (fgets(Line, 256 - 1, f) == NULL || - sscanf(Line, "%d %d", &PolylineStruct->m_Points[ii*2], - &PolylineStruct->m_Points[ii*2+1]) != 2) - { - MsgDiag.Printf( - wxT("EESchema file polyline struct error at line %d, aborted"), - LineCount); - Failed = TRUE; - delete PolylineStruct; - break; - } - } + PolylineStruct->m_NumOfPoints = ii; + PolylineStruct->m_Points = (int*) MyZMalloc( sizeof(int) * 2 * + PolylineStruct->m_NumOfPoints ); + for( ii = 0; ii < PolylineStruct->m_NumOfPoints; ii++ ) + { + LineCount++; + if( fgets( Line, 256 - 1, f ) == NULL + || sscanf( Line, "%d %d", &PolylineStruct->m_Points[ii * 2], + &PolylineStruct->m_Points[ii * 2 + 1] ) != 2 ) + { + MsgDiag.Printf( + wxT( "EESchema file polyline struct error at line %d, aborted" ), + LineCount ); + Failed = TRUE; + delete PolylineStruct; + break; + } + } - if (!Failed) - { - PolylineStruct->Pnext = screen->EEDrawList; - screen->EEDrawList = (EDA_BaseStruct *) - PolylineStruct; - } - break; + if( !Failed ) + { + PolylineStruct->Pnext = screen->EEDrawList; + screen->EEDrawList = (EDA_BaseStruct*) + PolylineStruct; + } + break; - case 'C': /* Its a connection item. */ - ConnectionStruct = new DrawJunctionStruct(wxPoint(0,0)); - if (sscanf(SLine, "%s %d %d", Name1, - &ConnectionStruct->m_Pos.x, - &ConnectionStruct->m_Pos.y) != 3) - { - MsgDiag.Printf( - wxT("EESchema file connection struct error at line %d, aborted"), - LineCount); - Failed = TRUE; - delete ConnectionStruct; - } - else - { - ConnectionStruct->Pnext = screen->EEDrawList; - screen->EEDrawList = ConnectionStruct; - } - break; + case 'C': /* Its a connection item. */ + ConnectionStruct = new DrawJunctionStruct( wxPoint( 0, 0 ) ); + if( sscanf( SLine, "%s %d %d", Name1, + &ConnectionStruct->m_Pos.x, + &ConnectionStruct->m_Pos.y ) != 3 ) + { + MsgDiag.Printf( + wxT( "EESchema file connection struct error at line %d, aborted" ), + LineCount ); + Failed = TRUE; + delete ConnectionStruct; + } + else + { + ConnectionStruct->Pnext = screen->EEDrawList; + screen->EEDrawList = ConnectionStruct; + } + break; - case 'N': /* Its a NoConnect item. */ - if (sscanf(SLine, "%s %d %d", Name1, &pos.x, &pos.y) != 3) - { - MsgDiag.Printf( - wxT("EESchema file NoConnect struct error at line %d, aborted"), - LineCount); - Failed = TRUE; - } - else - { - NoConnectStruct = new DrawNoConnectStruct(pos); - NoConnectStruct->Pnext = screen->EEDrawList; - screen->EEDrawList = NoConnectStruct; - } - break; + case 'N': /* Its a NoConnect item. */ + if( sscanf( SLine, "%s %d %d", Name1, &pos.x, &pos.y ) != 3 ) + { + MsgDiag.Printf( + wxT( "EESchema file NoConnect struct error at line %d, aborted" ), + LineCount ); + Failed = TRUE; + } + else + { + NoConnectStruct = new DrawNoConnectStruct( pos ); + NoConnectStruct->Pnext = screen->EEDrawList; + screen->EEDrawList = NoConnectStruct; + } + break; - case 'K': /* Its a MarKer item. */ - if (sscanf(SLine, "%s %d %d", Name1, &pos.x, &pos.y) != 3) - { - MsgDiag.Printf( - wxT("EESchema file marker struct error line %d, aborted"), - LineCount); - Failed = TRUE; - } - else - { - char * text; - char BufLine[1024]; - MarkerStruct = new DrawMarkerStruct(pos,wxEmptyString); - ii = ReadDelimitedText(BufLine, Line, 256 ); - MarkerStruct->m_Type = (TypeMarker)((Name1[0] & 255) - 'A'); - if( MarkerStruct->m_Type < 0 ) - MarkerStruct->m_Type = MARQ_UNSPEC; - if ( ii ) MarkerStruct->m_Comment = CONV_FROM_UTF8(BufLine); - text = strstr(Line," F="); - if (text) - { - sscanf(text+3, "%X", &ii); - MarkerStruct->m_MarkFlags = ii; - } - MarkerStruct->Pnext = screen->EEDrawList; - screen->EEDrawList = MarkerStruct; - } - break; + case 'K': /* Its a MarKer item. */ + if( sscanf( SLine, "%s %d %d", Name1, &pos.x, &pos.y ) != 3 ) + { + MsgDiag.Printf( + wxT( "EESchema file marker struct error line %d, aborted" ), + LineCount ); + Failed = TRUE; + } + else + { + char* text; + char BufLine[1024]; + MarkerStruct = new DrawMarkerStruct( pos, wxEmptyString ); + ii = ReadDelimitedText( BufLine, Line, 256 ); + MarkerStruct->m_Type = (TypeMarker) ( (Name1[0] & 255) - 'A' ); + if( MarkerStruct->m_Type < 0 ) + MarkerStruct->m_Type = MARQ_UNSPEC; + if( ii ) + MarkerStruct->m_Comment = CONV_FROM_UTF8( BufLine ); + text = strstr( Line, " F=" ); + if( text ) + { + sscanf( text + 3, "%X", &ii ); + MarkerStruct->m_MarkFlags = ii; + } + MarkerStruct->Pnext = screen->EEDrawList; + screen->EEDrawList = MarkerStruct; + } + break; - case 'T': /* Its a text item. */ - { - EDA_BaseStruct * Struct = NULL; - *Name1 = *Name2 = 0; - ii = sscanf(SLine, "%s %d %d %d %d %s", - Name1, &pos.x, &pos.y, &orient, &size, Name2); + case 'T': /* Its a text item. */ + { + EDA_BaseStruct* Struct = NULL; + *Name1 = *Name2 = 0; + ii = sscanf( SLine, "%s %d %d %d %d %s", + Name1, &pos.x, &pos.y, &orient, &size, Name2 ); - if( ii < 4 ) - { - MsgDiag.Printf( - wxT("EESchema file text struct error line %d, aborted"), - LineCount); - Failed = TRUE; - } - else if( fgets(Line, 256 - 1, f) == NULL ) - { - LineCount++; - MsgDiag.Printf( - wxT("EESchema file text struct error line %d (No text), aborted"), - LineCount); - Failed = TRUE; - } - else - { - LineCount++; - if( size == 0 ) size = DEFAULT_SIZE_TEXT; - char * text = strtok(Line, "\n\r"); - if ( text == NULL ) break; + if( ii < 4 ) + { + MsgDiag.Printf( + wxT( "EESchema file text struct error line %d, aborted" ), + LineCount ); + Failed = TRUE; + } + else if( fgets( Line, 256 - 1, f ) == NULL ) + { + LineCount++; + MsgDiag.Printf( + wxT( "EESchema file text struct error line %d (No text), aborted" ), + LineCount ); + Failed = TRUE; + } + else + { + LineCount++; + if( size == 0 ) + size = DEFAULT_SIZE_TEXT; + char* text = strtok( Line, "\n\r" ); + if( text == NULL ) + break; - if( Name1[0] == 'L' ) - { - DrawLabelStruct * TextStruct = - new DrawLabelStruct(pos, CONV_FROM_UTF8(text)); - TextStruct->m_Size.x = TextStruct->m_Size.y = size; - TextStruct->m_Orient = orient; - Struct = (EDA_BaseStruct*)TextStruct; - } - else if( Name1[0] == 'G' ) - { - DrawGlobalLabelStruct * TextStruct = - new DrawGlobalLabelStruct(pos, CONV_FROM_UTF8(text)); - Struct = (EDA_BaseStruct*)TextStruct; - TextStruct->m_Size.x = TextStruct->m_Size.y = size; - TextStruct->m_Orient = orient; - if( stricmp(Name2,SheetLabelType[NET_OUTPUT]) == 0 ) - TextStruct->m_Shape = NET_OUTPUT; - if( stricmp(Name2,SheetLabelType[NET_BIDI]) == 0 ) - TextStruct->m_Shape = NET_BIDI; - if( stricmp(Name2,SheetLabelType[NET_TRISTATE]) == 0 ) - TextStruct->m_Shape = NET_TRISTATE; - if( stricmp(Name2,SheetLabelType[NET_UNSPECIFIED]) == 0 ) - TextStruct->m_Shape = NET_UNSPECIFIED; - } - else - { - DrawTextStruct * TextStruct = - new DrawTextStruct(pos, CONV_FROM_UTF8(text)); - TextStruct->m_Size.x = TextStruct->m_Size.y = size; - TextStruct->m_Orient = orient; - Struct = (EDA_BaseStruct*)TextStruct; - } - if (Struct ) - { - Struct->Pnext = screen->EEDrawList; - screen->EEDrawList = Struct; - } - } - break; - } + if( Name1[0] == 'L' ) + { + DrawLabelStruct* TextStruct = + new DrawLabelStruct( pos, CONV_FROM_UTF8( text ) ); + TextStruct->m_Size.x = TextStruct->m_Size.y = size; + TextStruct->m_Orient = orient; + Struct = (EDA_BaseStruct*) TextStruct; + } + else if( Name1[0] == 'G' ) + { + DrawGlobalLabelStruct* TextStruct = + new DrawGlobalLabelStruct( pos, CONV_FROM_UTF8( text ) ); + Struct = (EDA_BaseStruct*) TextStruct; + TextStruct->m_Size.x = TextStruct->m_Size.y = size; + TextStruct->m_Orient = orient; + if( stricmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 ) + TextStruct->m_Shape = NET_OUTPUT; + if( stricmp( Name2, SheetLabelType[NET_BIDI] ) == 0 ) + TextStruct->m_Shape = NET_BIDI; + if( stricmp( Name2, SheetLabelType[NET_TRISTATE] ) == 0 ) + TextStruct->m_Shape = NET_TRISTATE; + if( stricmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 ) + TextStruct->m_Shape = NET_UNSPECIFIED; + } + else + { + DrawTextStruct* TextStruct = + new DrawTextStruct( pos, CONV_FROM_UTF8( text ) ); + TextStruct->m_Size.x = TextStruct->m_Size.y = size; + TextStruct->m_Orient = orient; + Struct = (EDA_BaseStruct*) TextStruct; + } + if( Struct ) + { + Struct->Pnext = screen->EEDrawList; + screen->EEDrawList = Struct; + } + } + break; + } - default: - Failed = FALSE; - MsgDiag.Printf( - wxT("EESchema file undef structdef at line %d, aborted"), - LineCount); - break; - } + default: + Failed = FALSE; + MsgDiag.Printf( + wxT( "EESchema file undef structdef at line %d, aborted" ), + LineCount ); + break; + } - if (Failed) - { - DisplayError(this, MsgDiag); - break; - } - } + if( Failed ) + { + DisplayError( this, MsgDiag ); + break; + } + } - /* EEDrawList was constructed in reverse order - reverse it back: */ - Phead = NULL; - while (screen->EEDrawList) - { - Pnext = screen->EEDrawList; - screen->EEDrawList = screen->EEDrawList->Pnext; - Pnext->Pnext = Phead; - Phead = Pnext; - } - screen->EEDrawList = Phead; + /* EEDrawList was constructed in reverse order - reverse it back: */ + Phead = NULL; + while( screen->EEDrawList ) + { + Pnext = screen->EEDrawList; + screen->EEDrawList = screen->EEDrawList->Pnext; + Pnext->Pnext = Phead; + Phead = Pnext; + } - fclose(f); + screen->EEDrawList = Phead; - TestDanglingEnds(screen->EEDrawList, NULL); - - return TRUE; /* Although it may be that file is only partially loaded. */ + fclose( f ); + + TestDanglingEnds( screen->EEDrawList, NULL ); + + return TRUE; /* Although it may be that file is only partially loaded. */ } - /*************************************************************/ -static int ReadPartDescr(wxWindow * frame, char *Line, FILE *f, - BASE_SCREEN * Window) +static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, + BASE_SCREEN* Window ) /*************************************************************/ /* Fonction utilisee par LoadEEFile(). - Lit les lignes relatives a la description d'un composant en schema -*/ + * Lit les lignes relatives a la description d'un composant en schema + */ { -int ii, fieldref; -char Name1[256], Name2[256], - Char1[256], Char2[256], Char3[256]; -EDA_SchComponentStruct *LibItemStruct; -int Failed = 0, newfmt = 0; -char * ptcar; + int ii, fieldref; + char Name1[256], Name2[256], + Char1[256], Char2[256], Char3[256]; + EDA_SchComponentStruct* LibItemStruct; + int Failed = 0, newfmt = 0; + char* ptcar; - LibItemStruct = new EDA_SchComponentStruct(); - LibItemStruct->m_Convert = 1; + LibItemStruct = new EDA_SchComponentStruct(); + LibItemStruct->m_Convert = 1; - if(Line[0] == '$') - { - newfmt = 1; - LineCount++; - if( fgets(Line, 256 - 1, f) == 0) return(TRUE); - } + if( Line[0] == '$' ) + { + newfmt = 1; + LineCount++; + if( fgets( Line, 256 - 1, f ) == 0 ) + return TRUE; + } - /* Traitement de la 1ere ligne de description */ - if( sscanf(&Line[1], "%s %s", Name1, Name2) != 2 ) - { - MsgDiag.Printf( - wxT("EESchema Component descr error at line %d, aborted"), - LineCount); - Failed = TRUE; - return(Failed); - } + /* Traitement de la 1ere ligne de description */ + if( sscanf( &Line[1], "%s %s", Name1, Name2 ) != 2 ) + { + MsgDiag.Printf( + wxT( "EESchema Component descr error at line %d, aborted" ), + LineCount ); + Failed = TRUE; + return Failed; + } - if (strcmp(Name1, NULL_STRING) != 0) - { - for (ii = 0; ii < (int)strlen(Name1); ii++) - if (Name1[ii] == '~') Name1[ii] = ' '; - LibItemStruct->m_ChipName = CONV_FROM_UTF8(Name1); - if( !newfmt ) - LibItemStruct->m_Field[VALUE].m_Text = CONV_FROM_UTF8(Name1); - } - else - { - LibItemStruct->m_ChipName.Empty(); - LibItemStruct->m_Field[VALUE].m_Text.Empty(); - LibItemStruct->m_Field[VALUE].m_Orient = TEXT_ORIENT_HORIZ; - LibItemStruct->m_Field[VALUE].m_Attributs = TEXT_NO_VISIBLE; - } + if( strcmp( Name1, NULL_STRING ) != 0 ) + { + for( ii = 0; ii < (int) strlen( Name1 ); ii++ ) + if( Name1[ii] == '~' ) + Name1[ii] = ' '; - if (strcmp(Name2, NULL_STRING) != 0) - { - for (ii = 0; ii < (int)strlen(Name2); ii++) - if (Name2[ii] == '~') Name2[ii] = ' '; - if(!newfmt) LibItemStruct->m_Field[REFERENCE].m_Text = CONV_FROM_UTF8(Name2); - } - else - { - LibItemStruct->m_Field[REFERENCE].m_Attributs = TEXT_NO_VISIBLE; - } + LibItemStruct->m_ChipName = CONV_FROM_UTF8( Name1 ); + if( !newfmt ) + LibItemStruct->m_Field[VALUE].m_Text = CONV_FROM_UTF8( Name1 ); + } + else + { + LibItemStruct->m_ChipName.Empty(); + LibItemStruct->m_Field[VALUE].m_Text.Empty(); + LibItemStruct->m_Field[VALUE].m_Orient = TEXT_ORIENT_HORIZ; + LibItemStruct->m_Field[VALUE].m_Attributs = TEXT_NO_VISIBLE; + } - /* Traitement des autres lignes de description */ - /* Ces lignes commencent par: - "P " = position - "U " = Num Unit, et Conversion - "Fn" = Champs ( n = 0.. = numero de champ ) - */ + if( strcmp( Name2, NULL_STRING ) != 0 ) + { + for( ii = 0; ii < (int) strlen( Name2 ); ii++ ) + if( Name2[ii] == '~' ) + Name2[ii] = ' '; - /* Lecture des champs */ - for(;;) - { - LineCount++; - if( fgets(Line, 256 - 1, f) == NULL ) return(TRUE); - if( (Line[0] != 'F' ) && - (Line[0] != 'P' ) && - (Line[0] != 'U' ) ) - break; + if( !newfmt ) + LibItemStruct->m_Field[REFERENCE].m_Text = CONV_FROM_UTF8( Name2 ); + } + else + { + LibItemStruct->m_Field[REFERENCE].m_Attributs = TEXT_NO_VISIBLE; + } - if( Line[0] == 'U' ) /* Lecture num multi, conversion et time stamp */ - { - sscanf(Line+1,"%d %d %lX", - &LibItemStruct->m_Multi, &LibItemStruct->m_Convert, - &LibItemStruct->m_TimeStamp); - } + /* Traitement des autres lignes de description */ - if( Line[0] == 'P' ) - { - sscanf(Line+1,"%d %d", - &LibItemStruct->m_Pos.x, &LibItemStruct->m_Pos.y); - } + /* Ces lignes commencent par: + * "P " = position + * "U " = Num Unit, et Conversion + * "Fn" = Champs ( n = 0.. = numero de champ ) + */ - if( Line[0] == 'F' ) - { - char FieldUserName[1024]; - int hjustify = GR_TEXT_HJUSTIFY_CENTER; - int vjustify = GR_TEXT_VJUSTIFY_CENTER; - - FieldUserName[0] = 0; - - sscanf(Line+1,"%d", &fieldref); - if( fieldref >= NUMBER_OF_FIELDS) - { - MsgDiag.Printf( - wxT("Component Field number error at line %d, aborted"), - LineCount); - return(TRUE); - } - /* Lecture du champ */ - ptcar = Line; while( *ptcar && (*ptcar != '"') ) ptcar++; - if( *ptcar != '"') - { - MsgDiag.Printf( - wxT("EESchema file lib field F at line %d, aborted"), - LineCount); - return(TRUE); - } - - for(ptcar++, ii = 0; ; ii++, ptcar++ ) - { - Name1[ii] = *ptcar; - if( *ptcar == 0 ) - { - MsgDiag.Printf( - wxT("Component field F at line %d, aborted"), - LineCount); - return(TRUE); - } - if( *ptcar == '"' ) - { - Name1[ii] = 0; ptcar++; - break; - } - } + /* Lecture des champs */ + for( ; ; ) + { + LineCount++; + if( fgets( Line, 256 - 1, f ) == NULL ) + return TRUE; + if( (Line[0] != 'F' ) + && (Line[0] != 'P' ) + && (Line[0] != 'U' ) ) + break; - if(LibItemStruct->m_Field[fieldref].m_Text.IsEmpty()) - LibItemStruct->m_Field[fieldref].m_Text = CONV_FROM_UTF8(Name1); + if( Line[0] == 'U' ) /* Lecture num multi, conversion et time stamp */ + { + sscanf( Line + 1, "%d %d %lX", + &LibItemStruct->m_Multi, &LibItemStruct->m_Convert, + &LibItemStruct->m_TimeStamp ); + } - /* Lecture des coordonnees */ - if( (ii = sscanf(ptcar, "%s %d %d %d %X %s %s", Char1, - &LibItemStruct->m_Field[fieldref].m_Pos.x, - &LibItemStruct->m_Field[fieldref].m_Pos.y, - &LibItemStruct->m_Field[fieldref].m_Size.x, - &LibItemStruct->m_Field[fieldref].m_Attributs, - Char2, Char3) ) < 4 ) - { - MsgDiag.Printf( - wxT("Component Field error line %d, aborted"), - LineCount); - DisplayError(frame, MsgDiag); - continue; - } - - ReadDelimitedText(FieldUserName,ptcar, sizeof(FieldUserName) ); - if( (LibItemStruct->m_Field[fieldref].m_Size.x == 0 ) || (ii == 4) ) - LibItemStruct->m_Field[fieldref].m_Size.x = DEFAULT_SIZE_TEXT; - LibItemStruct->m_Field[fieldref].m_Orient = TEXT_ORIENT_HORIZ; - LibItemStruct->m_Field[fieldref].m_Size.y = LibItemStruct->m_Field[fieldref].m_Size.x; - if(Char1[0] == 'V') - LibItemStruct->m_Field[fieldref].m_Orient = TEXT_ORIENT_VERT; - if ( ii >= 7 ) - { - if ( *Char2 == 'L' ) hjustify = GR_TEXT_HJUSTIFY_LEFT; - else if ( *Char2 == 'R' ) hjustify = GR_TEXT_HJUSTIFY_RIGHT; - if ( *Char3 == 'B' ) vjustify = GR_TEXT_VJUSTIFY_BOTTOM; - else if ( *Char3 == 'T' ) vjustify = GR_TEXT_VJUSTIFY_TOP; - LibItemStruct->m_Field[fieldref].m_HJustify = hjustify; - LibItemStruct->m_Field[fieldref].m_VJustify = vjustify; - } - - if ( fieldref >= FIELD1 ) - { - LibItemStruct->m_Field[fieldref].m_Name = CONV_FROM_UTF8(FieldUserName); - } + if( Line[0] == 'P' ) + { + sscanf( Line + 1, "%d %d", + &LibItemStruct->m_Pos.x, &LibItemStruct->m_Pos.y ); + } + + if( Line[0] == 'F' ) + { + char FieldUserName[1024]; + int hjustify = GR_TEXT_HJUSTIFY_CENTER; + int vjustify = GR_TEXT_VJUSTIFY_CENTER; + + FieldUserName[0] = 0; + + sscanf( Line + 1, "%d", &fieldref ); + if( fieldref >= NUMBER_OF_FIELDS ) + { + MsgDiag.Printf( + wxT( "Component Field number error at line %d, aborted" ), + LineCount ); + return TRUE; + } + /* Lecture du champ */ + ptcar = Line; while( *ptcar && (*ptcar != '"') ) + ptcar++; + + if( *ptcar != '"' ) + { + MsgDiag.Printf( + wxT( "EESchema file lib field F at line %d, aborted" ), + LineCount ); + return TRUE; + } + + for( ptcar++, ii = 0; ; ii++, ptcar++ ) + { + Name1[ii] = *ptcar; + if( *ptcar == 0 ) + { + MsgDiag.Printf( + wxT( "Component field F at line %d, aborted" ), + LineCount ); + return TRUE; + } + if( *ptcar == '"' ) + { + Name1[ii] = 0; ptcar++; + break; + } + } + + if( LibItemStruct->m_Field[fieldref].m_Text.IsEmpty() ) + LibItemStruct->m_Field[fieldref].m_Text = CONV_FROM_UTF8( Name1 ); + + /* Lecture des coordonnees */ + if( ( ii = sscanf( ptcar, "%s %d %d %d %X %s %s", Char1, + &LibItemStruct->m_Field[fieldref].m_Pos.x, + &LibItemStruct->m_Field[fieldref].m_Pos.y, + &LibItemStruct->m_Field[fieldref].m_Size.x, + &LibItemStruct->m_Field[fieldref].m_Attributs, + Char2, Char3 ) ) < 4 ) + { + MsgDiag.Printf( + wxT( "Component Field error line %d, aborted" ), + LineCount ); + DisplayError( frame, MsgDiag ); + continue; + } + + ReadDelimitedText( FieldUserName, ptcar, sizeof(FieldUserName) ); + if( (LibItemStruct->m_Field[fieldref].m_Size.x == 0 ) || (ii == 4) ) + LibItemStruct->m_Field[fieldref].m_Size.x = DEFAULT_SIZE_TEXT; + LibItemStruct->m_Field[fieldref].m_Orient = TEXT_ORIENT_HORIZ; + LibItemStruct->m_Field[fieldref].m_Size.y = LibItemStruct->m_Field[fieldref].m_Size.x; + if( Char1[0] == 'V' ) + LibItemStruct->m_Field[fieldref].m_Orient = TEXT_ORIENT_VERT; + if( ii >= 7 ) + { + if( *Char2 == 'L' ) + hjustify = GR_TEXT_HJUSTIFY_LEFT; + else if( *Char2 == 'R' ) + hjustify = GR_TEXT_HJUSTIFY_RIGHT; + if( *Char3 == 'B' ) + vjustify = GR_TEXT_VJUSTIFY_BOTTOM; + else if( *Char3 == 'T' ) + vjustify = GR_TEXT_VJUSTIFY_TOP; + LibItemStruct->m_Field[fieldref].m_HJustify = hjustify; + LibItemStruct->m_Field[fieldref].m_VJustify = vjustify; + } + + if( fieldref >= FIELD1 ) + { + LibItemStruct->m_Field[fieldref].m_Name = CONV_FROM_UTF8( FieldUserName ); + } // 27 juin 2001: A Supprimer lorsque tous les schemas auront ete traites : -if ( fieldref == REFERENCE ) - if (LibItemStruct->m_Field[fieldref].m_Text[0] == '#' ) - LibItemStruct->m_Field[fieldref].m_Attributs |= TEXT_NO_VISIBLE; - } - } + if( fieldref == REFERENCE ) + if( LibItemStruct->m_Field[fieldref].m_Text[0] == '#' ) + LibItemStruct->m_Field[fieldref].m_Attributs |= TEXT_NO_VISIBLE; + } + } + /* Lecture multi et position du composant */ + if( sscanf( Line, "%d %d %d", + &LibItemStruct->m_Multi, + &LibItemStruct->m_Pos.x, &LibItemStruct->m_Pos.y ) != 3 ) + { + MsgDiag.Printf( + wxT( "Component unit & pos error at line %d, aborted" ), + LineCount ); + Failed = TRUE; + return Failed; + } - /* Lecture multi et position du composant */ - if( sscanf(Line, "%d %d %d", - &LibItemStruct->m_Multi, - &LibItemStruct->m_Pos.x, &LibItemStruct->m_Pos.y) != 3) - { - MsgDiag.Printf( - wxT("Component unit & pos error at line %d, aborted"), - LineCount); - Failed = TRUE; - return(Failed); - } + /* Lecture de la matrice de miroir / rotation */ + LineCount++; + if( (fgets( Line, 256 - 1, f ) == NULL) + || (sscanf( Line, "%d %d %d %d", + &LibItemStruct->m_Transform[0][0], + &LibItemStruct->m_Transform[0][1], + &LibItemStruct->m_Transform[1][0], + &LibItemStruct->m_Transform[1][1] ) != 4) ) + { + MsgDiag.Printf( + wxT( "Component orient error at line %d, aborted" ), + LineCount ); + Failed = TRUE; + return Failed; + } - /* Lecture de la matrice de miroir / rotation */ - LineCount++; - if( (fgets(Line, 256 - 1, f) == NULL) || - (sscanf(Line, "%d %d %d %d", - &LibItemStruct->m_Transform[0][0], - &LibItemStruct->m_Transform[0][1], - &LibItemStruct->m_Transform[1][0], - &LibItemStruct->m_Transform[1][1]) != 4) ) - { - MsgDiag.Printf( - wxT("Component orient error at line %d, aborted"), - LineCount); - Failed = TRUE; - return(Failed); - } + if( newfmt ) + { + LineCount++; + if( fgets( Line, 256 - 1, f ) == NULL ) + return TRUE; + if( strnicmp( "$End", Line, 4 ) != 0 ) + { + MsgDiag.Printf( + wxT( "Component End expected at line %d, aborted" ), + LineCount ); + Failed = TRUE; + } + } - if(newfmt) - { - LineCount++; - if( fgets(Line, 256 - 1, f) == NULL ) return(TRUE); - if( strnicmp("$End", Line,4) != 0 ) - { - MsgDiag.Printf( - wxT("Component End expected at line %d, aborted"), - LineCount); - Failed = TRUE; - } - } + if( !Failed ) + { + LibItemStruct->Pnext = Window->EEDrawList; + Window->EEDrawList = (EDA_BaseStruct*) LibItemStruct; + } - if (!Failed) - { - LibItemStruct->Pnext = Window->EEDrawList; - Window->EEDrawList = (EDA_BaseStruct *) LibItemStruct; - } - - return(Failed); /* Fin lecture 1 composant */ + return Failed; /* Fin lecture 1 composant */ } /*************************************************************************************/ -static int ReadSheetDescr(wxWindow * frame, char *Line, FILE *f, BASE_SCREEN * Window) +static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window ) /*************************************************************************************/ + /* Fonction utilisee par LoadEEFile(). - Lit les lignes relatives a la description d'une feuille de hierarchie -*/ + * Lit les lignes relatives a la description d'une feuille de hierarchie + */ { -int ii, fieldref, size; -char Name1[256], Char1[256], Char2[256]; -DrawSheetStruct *SheetStruct; -DrawSheetLabelStruct *SheetLabelStruct, *OldSheetLabel = NULL; -int Failed = FALSE; -char * ptcar; + int ii, fieldref, size; + char Name1[256], Char1[256], Char2[256]; + DrawSheetStruct* SheetStruct; + DrawSheetLabelStruct* SheetLabelStruct, * OldSheetLabel = NULL; + int Failed = FALSE; + char* ptcar; - SheetStruct = new DrawSheetStruct(); - SheetStruct->m_TimeStamp = GetTimeStamp(); - SheetStruct->m_Parent = Window; + SheetStruct = new DrawSheetStruct(); + SheetStruct->m_TimeStamp = GetTimeStamp(); + SheetStruct->m_Parent = Window; - if(Line[0] == '$') /* Ligne doit etre "$Sheet" */ - { - LineCount++; - if( fgets(Line, 256 - 1, f) == 0) - { - MsgDiag.Printf( wxT("Read File Errror") ); return(TRUE); - } - } + if( Line[0] == '$' ) /* Ligne doit etre "$Sheet" */ + { + LineCount++; + if( fgets( Line, 256 - 1, f ) == 0 ) + { + MsgDiag.Printf( wxT( "Read File Errror" ) ); return TRUE; + } + } - /* Next line: must be "S xx yy nn mm" with xx, yy = sheet position - ( upper left corner ) et nn,mm = sheet size */ - if( (sscanf(&Line[1], "%d %d %d %d", - &SheetStruct->m_Pos.x, &SheetStruct->m_Pos.y, - &SheetStruct->m_Size.x, &SheetStruct->m_Size.y) != 4) || - (Line[0] != 'S' ) ) - { - MsgDiag.Printf( - wxT(" ** EESchema file sheet struct error at line %d, aborted"), - LineCount); - Failed = TRUE; - return(Failed); - } + /* Next line: must be "S xx yy nn mm" with xx, yy = sheet position + * ( upper left corner ) et nn,mm = sheet size */ + if( (sscanf( &Line[1], "%d %d %d %d", + &SheetStruct->m_Pos.x, &SheetStruct->m_Pos.y, + &SheetStruct->m_Size.x, &SheetStruct->m_Size.y ) != 4) + || (Line[0] != 'S' ) ) + { + MsgDiag.Printf( + wxT( " ** EESchema file sheet struct error at line %d, aborted" ), + LineCount ); + Failed = TRUE; + return Failed; + } - /* Lecture des champs */ - for(;;) /* Analyse des lignes "Fn "texte" .." */ - { - LineCount++; - if( fgets(Line, 256 - 1, f) == NULL ) return(TRUE); - if( Line[0] != 'F' ) break; - sscanf(Line+1,"%d", &fieldref); - /* Lecture du champ : - si fieldref >= 2 : Fn "texte" t s posx posy - sinon F0 "texte" pour sheetname - et F1 "texte" pour filename */ + /* Lecture des champs */ + for( ; ; ) /* Analyse des lignes "Fn "texte" .." */ + { + LineCount++; + if( fgets( Line, 256 - 1, f ) == NULL ) + return TRUE; + if( Line[0] != 'F' ) + break; + sscanf( Line + 1, "%d", &fieldref ); - ptcar = Line; while( *ptcar && (*ptcar != '"') ) ptcar++; - if( *ptcar != '"') - { - MsgDiag.Printf( - wxT(" ** EESchema file sheet label F%d at line %d, aborted"), - fieldref, LineCount); - return(TRUE); - } - - for(ptcar++, ii = 0; ; ii++, ptcar++ ) - { - Name1[ii] = *ptcar; - if( *ptcar == 0 ) - { - MsgDiag.Printf( - wxT(" ** EESchema file sheet field F at line %d, aborted"), LineCount); - return(TRUE); - } - if( *ptcar == '"' ) - { - Name1[ii] = 0; ptcar++; - break; - } - } + /* Lecture du champ : + * si fieldref >= 2 : Fn "texte" t s posx posy + * sinon F0 "texte" pour sheetname + * et F1 "texte" pour filename */ - if( ( fieldref == 0 ) || ( fieldref == 1 ) ) - { - if( sscanf(ptcar, "%d", &size) != 1 ) - { - MsgDiag.Printf( - wxT(" ** EESchema file sheet Label Caract error line %d, aborted"),LineCount); - DisplayError(frame, MsgDiag); - } - if(size == 0) size = DEFAULT_SIZE_TEXT; - if ( fieldref == 0 ) - { - SheetStruct->m_SheetName = CONV_FROM_UTF8(Name1); - SheetStruct->m_SheetNameSize = size; - } - else - { - SheetStruct->m_FileName = CONV_FROM_UTF8(Name1); - SheetStruct->m_FileNameSize = size; - } - } + ptcar = Line; while( *ptcar && (*ptcar != '"') ) + ptcar++; - if( fieldref > 1 ) - { - SheetLabelStruct = new DrawSheetLabelStruct(SheetStruct, - wxPoint(0,0), CONV_FROM_UTF8(Name1) ); - if( SheetStruct->m_Label == NULL ) - OldSheetLabel = SheetStruct->m_Label = SheetLabelStruct; - else OldSheetLabel->Pnext = (EDA_BaseStruct*)SheetLabelStruct; - OldSheetLabel = SheetLabelStruct; + if( *ptcar != '"' ) + { + MsgDiag.Printf( + wxT( " ** EESchema file sheet label F%d at line %d, aborted" ), + fieldref, LineCount ); + return TRUE; + } - /* Lecture des coordonnees */ - if( sscanf(ptcar, "%s %s %d %d %d", Char1, Char2, - &SheetLabelStruct->m_Pos.x, &SheetLabelStruct->m_Pos.y, - &size) != 5 ) - { - MsgDiag.Printf( - wxT(" ** EESchema file Sheet Label Caract error line %d, aborted"),LineCount); - DisplayError(frame, MsgDiag); - continue; - } + for( ptcar++, ii = 0; ; ii++, ptcar++ ) + { + Name1[ii] = *ptcar; + if( *ptcar == 0 ) + { + MsgDiag.Printf( + wxT( " ** EESchema file sheet field F at line %d, aborted" ), LineCount ); + return TRUE; + } + if( *ptcar == '"' ) + { + Name1[ii] = 0; ptcar++; + break; + } + } - if(size == 0) size = DEFAULT_SIZE_TEXT; - SheetLabelStruct->m_Size.x = SheetLabelStruct->m_Size.y = size; - /* Mise a jour des cadrage et type */ - switch( Char1[0]) - { - case 'I': SheetLabelStruct->m_Shape = NET_INPUT; break; - case 'O': SheetLabelStruct->m_Shape = NET_OUTPUT; break; - case 'B': SheetLabelStruct->m_Shape = NET_BIDI; break; - case 'T': SheetLabelStruct->m_Shape = NET_TRISTATE; break; - case 'U': SheetLabelStruct->m_Shape = NET_UNSPECIFIED; break; - } - if( Char2[0] == 'R' ) SheetLabelStruct->m_Edge = 1; - } - } + if( ( fieldref == 0 ) || ( fieldref == 1 ) ) + { + if( sscanf( ptcar, "%d", &size ) != 1 ) + { + MsgDiag.Printf( + wxT( + " ** EESchema file sheet Label Caract error line %d, aborted" ), LineCount ); + DisplayError( frame, MsgDiag ); + } + if( size == 0 ) + size = DEFAULT_SIZE_TEXT; + if( fieldref == 0 ) + { + SheetStruct->m_SheetName = CONV_FROM_UTF8( Name1 ); + SheetStruct->m_SheetNameSize = size; + } + else + { + SheetStruct->m_FileName = CONV_FROM_UTF8( Name1 ); + SheetStruct->m_FileNameSize = size; + } + } - if( strnicmp("$End", Line,4) != 0 ) - { - MsgDiag.Printf( - wxT(" **EESchema file end_sheet struct error at line %d, aborted"), - LineCount); - Failed = TRUE; - } + if( fieldref > 1 ) + { + SheetLabelStruct = new DrawSheetLabelStruct( SheetStruct, + wxPoint( 0, 0 ), CONV_FROM_UTF8( Name1 ) ); + if( SheetStruct->m_Label == NULL ) + OldSheetLabel = SheetStruct->m_Label = SheetLabelStruct; + else + OldSheetLabel->Pnext = (EDA_BaseStruct*) SheetLabelStruct; + OldSheetLabel = SheetLabelStruct; - if (!Failed) - { - SheetStruct->Pnext = Window->EEDrawList; - Window->EEDrawList = (EDA_BaseStruct *) SheetStruct; - } + /* Lecture des coordonnees */ + if( sscanf( ptcar, "%s %s %d %d %d", Char1, Char2, + &SheetLabelStruct->m_Pos.x, &SheetLabelStruct->m_Pos.y, + &size ) != 5 ) + { + MsgDiag.Printf( + wxT( + " ** EESchema file Sheet Label Caract error line %d, aborted" ), LineCount ); + DisplayError( frame, MsgDiag ); + continue; + } - return(Failed); /* Fin lecture 1 composant */ + if( size == 0 ) + size = DEFAULT_SIZE_TEXT; + SheetLabelStruct->m_Size.x = SheetLabelStruct->m_Size.y = size; + + /* Mise a jour des cadrage et type */ + switch( Char1[0] ) + { + case 'I': + SheetLabelStruct->m_Shape = NET_INPUT; break; + + case 'O': + SheetLabelStruct->m_Shape = NET_OUTPUT; break; + + case 'B': + SheetLabelStruct->m_Shape = NET_BIDI; break; + + case 'T': + SheetLabelStruct->m_Shape = NET_TRISTATE; break; + + case 'U': + SheetLabelStruct->m_Shape = NET_UNSPECIFIED; break; + } + + if( Char2[0] == 'R' ) + SheetLabelStruct->m_Edge = 1; + } + } + + if( strnicmp( "$End", Line, 4 ) != 0 ) + { + MsgDiag.Printf( + wxT( " **EESchema file end_sheet struct error at line %d, aborted" ), + LineCount ); + Failed = TRUE; + } + + if( !Failed ) + { + SheetStruct->Pnext = Window->EEDrawList; + Window->EEDrawList = (EDA_BaseStruct*) SheetStruct; + } + + return Failed; /* Fin lecture 1 composant */ } /******************************************************************/ -static int ReadSchemaDescr(wxWindow * frame, char *Line, FILE *f, BASE_SCREEN * Window) +static int ReadSchemaDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window ) /******************************************************************/ + /* Analyse de l'entete du schema ( dims feuille, cartouche..) -*/ + */ { -char Text[256], buf[1024]; -int ii; -Ki_PageDescr * wsheet = &g_Sheet_A4; -static Ki_PageDescr * SheetFormatList[] = { - &g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2, &g_Sheet_A1, &g_Sheet_A0, - &g_Sheet_A, &g_Sheet_B, &g_Sheet_C, &g_Sheet_D, &g_Sheet_E, - &g_Sheet_user, NULL}; -wxSize PageSize; - - sscanf(Line, "%s %s %d %d", Text, Text, & PageSize.x, & PageSize.y); - /* Recherche de la descr correspondante: */ - wxString pagename = CONV_FROM_UTF8(Text); - for(ii = 0; SheetFormatList[ii] != NULL; ii++ ) - { - wsheet = SheetFormatList[ii]; - if( wsheet->m_Name.CmpNoCase(pagename) == 0 ) - { /* Descr found ! */ - if ( wsheet == & g_Sheet_user ) // Get the user page size and make it the default - { - g_Sheet_user.m_Size = PageSize; - } - break; - } - } + char Text[256], buf[1024]; + int ii; + Ki_PageDescr* wsheet = &g_Sheet_A4; + static Ki_PageDescr* SheetFormatList[] = { + &g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2, &g_Sheet_A1, &g_Sheet_A0, + &g_Sheet_A, &g_Sheet_B, &g_Sheet_C, &g_Sheet_D, &g_Sheet_E, + &g_Sheet_user, NULL + }; + wxSize PageSize; - if( SheetFormatList[ii] == NULL ) - { - /* Erreur ici: descr non trouvee */ - MsgDiag.Printf( - wxT("EESchema file Dims Caract error line %d, aborted"),LineCount); - DisplayError(frame, MsgDiag); - } + sscanf( Line, "%s %s %d %d", Text, Text, &PageSize.x, &PageSize.y ); + /* Recherche de la descr correspondante: */ + wxString pagename = CONV_FROM_UTF8( Text ); + for( ii = 0; SheetFormatList[ii] != NULL; ii++ ) + { + wsheet = SheetFormatList[ii]; + if( wsheet->m_Name.CmpNoCase( pagename ) == 0 ) + { /* Descr found ! */ + if( wsheet == &g_Sheet_user ) // Get the user page size and make it the default + { + g_Sheet_user.m_Size = PageSize; + } + break; + } + } - /* Ajuste ecran */ - Window->m_CurrentSheet = wsheet; + if( SheetFormatList[ii] == NULL ) + { + /* Erreur ici: descr non trouvee */ + MsgDiag.Printf( + wxT( "EESchema file Dims Caract error line %d, aborted" ), LineCount ); + DisplayError( frame, MsgDiag ); + } - /* Recheche suite et fin de descr */ - for( ;; ) - { - if( GetLine(f, Line, &LineCount, 1024 ) == NULL ) return(TRUE); - if( strnicmp(Line,"$End",4) == 0 ) break; + /* Ajuste ecran */ + Window->m_CurrentSheet = wsheet; - if( strnicmp(Line,"Sheet",2) == 0 ) - sscanf( Line+5," %d %d", - &Window->m_SheetNumber,&Window->m_NumberOfSheet); - - if( strnicmp(Line,"Title",2) == 0 ) - { - ReadDelimitedText( buf, Line, 256); - Window->m_Title = CONV_FROM_UTF8(buf); - continue; - } - - if( strnicmp(Line,"Date",2) == 0 ) - { - ReadDelimitedText( buf, Line, 256); - Window->m_Date = CONV_FROM_UTF8(buf); - continue; - } + /* Recheche suite et fin de descr */ + for( ; ; ) + { + if( GetLine( f, Line, &LineCount, 1024 ) == NULL ) + return TRUE; + if( strnicmp( Line, "$End", 4 ) == 0 ) + break; - if( strnicmp(Line,"Rev",2) == 0 ) - { - ReadDelimitedText( buf, Line, 256); - Window->m_Revision = CONV_FROM_UTF8(buf); - continue; - } + if( strnicmp( Line, "Sheet", 2 ) == 0 ) + sscanf( Line + 5, " %d %d", + &Window->m_SheetNumber, &Window->m_NumberOfSheet ); - if( strnicmp(Line,"Comp",4) == 0 ) - { - ReadDelimitedText( buf, Line, 256); - Window->m_Company = CONV_FROM_UTF8(buf); - continue; - } + if( strnicmp( Line, "Title", 2 ) == 0 ) + { + ReadDelimitedText( buf, Line, 256 ); + Window->m_Title = CONV_FROM_UTF8( buf ); + continue; + } - if( strnicmp(Line,"Comment1",8) == 0 ) - { - ReadDelimitedText( buf, Line, 256); - Window->m_Commentaire1 = CONV_FROM_UTF8(buf); - continue; - } + if( strnicmp( Line, "Date", 2 ) == 0 ) + { + ReadDelimitedText( buf, Line, 256 ); + Window->m_Date = CONV_FROM_UTF8( buf ); + continue; + } - if( strnicmp(Line,"Comment2",8) == 0 ) - { - ReadDelimitedText( buf, Line, 256); - Window->m_Commentaire2 = CONV_FROM_UTF8(buf); - continue; - } + if( strnicmp( Line, "Rev", 2 ) == 0 ) + { + ReadDelimitedText( buf, Line, 256 ); + Window->m_Revision = CONV_FROM_UTF8( buf ); + continue; + } - if( strnicmp(Line,"Comment3",8) == 0 ) - { - ReadDelimitedText( buf, Line, 256); - Window->m_Commentaire3 = CONV_FROM_UTF8(buf); - continue; - } + if( strnicmp( Line, "Comp", 4 ) == 0 ) + { + ReadDelimitedText( buf, Line, 256 ); + Window->m_Company = CONV_FROM_UTF8( buf ); + continue; + } - if( strnicmp(Line,"Comment4",8) == 0 ) - { - ReadDelimitedText( buf, Line, 256); - Window->m_Commentaire4 = CONV_FROM_UTF8(buf); - continue; - } - } - return(FALSE); + if( strnicmp( Line, "Comment1", 8 ) == 0 ) + { + ReadDelimitedText( buf, Line, 256 ); + Window->m_Commentaire1 = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( Line, "Comment2", 8 ) == 0 ) + { + ReadDelimitedText( buf, Line, 256 ); + Window->m_Commentaire2 = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( Line, "Comment3", 8 ) == 0 ) + { + ReadDelimitedText( buf, Line, 256 ); + Window->m_Commentaire3 = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( Line, "Comment4", 8 ) == 0 ) + { + ReadDelimitedText( buf, Line, 256 ); + Window->m_Commentaire4 = CONV_FROM_UTF8( buf ); + continue; + } + } + + return FALSE; } + /***********************************/ -static void LoadLayers(FILE *f, int * linecnt) +static void LoadLayers( FILE* f, int* linecnt ) /***********************************/ + /* Load the Layer Struct from a file -*/ + */ { -int cnt = 0, Number; -char Line[1024]; + int cnt = 0, Number; + char Line[1024]; + //int Mode,Color,Layer; -char Name[256]; + char Name[256]; - GetLine(f, Line, NULL, sizeof(Line) ); /* read line */ - (*linecnt)++; - sscanf(Line,"%s %d %d",Name,&Number,&g_LayerDescr.CurrentLayer); - if( strcmp(Name,"EELAYER") !=0 ) - { - /* error : init par defaut */ - Number = MAX_LAYER; - } - if ( Number <= 0 ) Number = MAX_LAYER; - if ( Number > MAX_LAYER ) Number = MAX_LAYER; + GetLine( f, Line, NULL, sizeof(Line) ); /* read line */ + (*linecnt)++; + sscanf( Line, "%s %d %d", Name, &Number, &g_LayerDescr.CurrentLayer ); + if( strcmp( Name, "EELAYER" ) !=0 ) + { + /* error : init par defaut */ + Number = MAX_LAYER; + } + if( Number <= 0 ) + Number = MAX_LAYER; + if( Number > MAX_LAYER ) + Number = MAX_LAYER; - g_LayerDescr.NumberOfLayers=Number; + g_LayerDescr.NumberOfLayers = Number; - while( GetLine(f, Line, NULL, sizeof(Line)) ) - { - (*linecnt)++; - if( strnicmp(Line,"EELAYER END",11) == 0 ) break; - cnt++; - } + while( GetLine( f, Line, NULL, sizeof(Line) ) ) + { + (*linecnt)++; + if( strnicmp( Line, "EELAYER END", 11 ) == 0 ) + break; + cnt++; + } } - - diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp index ff43d768b7..60bcfd1192 100644 --- a/eeschema/onleftclick.cpp +++ b/eeschema/onleftclick.cpp @@ -1,6 +1,6 @@ - /******************************************************/ - /* schedit.cpp: fonctions generales de la schematique */ - /******************************************************/ +/******************************************************/ +/* schedit.cpp: fonctions generales de la schematique */ +/******************************************************/ #include "fctsys.h" @@ -19,332 +19,336 @@ static wxArrayString s_CmpNameList; static wxArrayString s_PowerNameList; /**********************************************************************************/ -void WinEDA_SchematicFrame::OnLeftClick(wxDC * DC, const wxPoint& MousePos) +void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) /**********************************************************************************/ + /* Traite les commandes declench�e par le bouton gauche de la souris, - quand un outil est deja selectionn� -*/ + * quand un outil est deja selectionn� + */ { -EDA_BaseStruct * DrawStruct = m_CurrentScreen->m_CurrentItem; + EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem(); - if ( (m_ID_current_state == 0) || ( DrawStruct && DrawStruct->m_Flags ) ) - { - DrawPanel->m_AutoPAN_Request = FALSE; - g_ItemToRepeat = NULL; + if( (m_ID_current_state == 0) || ( DrawStruct && DrawStruct->m_Flags ) ) + { + DrawPanel->m_AutoPAN_Request = FALSE; + g_ItemToRepeat = NULL; - if ( DrawStruct && DrawStruct->m_Flags ) // Commande "POPUP" en cours - { - switch (DrawStruct->m_StructType ) - { - case DRAW_LABEL_STRUCT_TYPE: - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - case DRAW_TEXT_STRUCT_TYPE: - case DRAW_SHEETLABEL_STRUCT_TYPE: - case DRAW_SHEET_STRUCT_TYPE: - case DRAW_BUSENTRY_STRUCT_TYPE: - case DRAW_JUNCTION_STRUCT_TYPE: - case DRAW_LIB_ITEM_STRUCT_TYPE: - case DRAW_PART_TEXT_STRUCT_TYPE: - DrawStruct->Place( this, DC); - m_CurrentScreen->m_CurrentItem = NULL; - TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); - return; + if( DrawStruct && DrawStruct->m_Flags ) // Commande "POPUP" en cours + { + switch( DrawStruct->m_StructType ) + { + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + case DRAW_SHEETLABEL_STRUCT_TYPE: + case DRAW_SHEET_STRUCT_TYPE: + case DRAW_BUSENTRY_STRUCT_TYPE: + case DRAW_JUNCTION_STRUCT_TYPE: + case DRAW_LIB_ITEM_STRUCT_TYPE: + case DRAW_PART_TEXT_STRUCT_TYPE: + DrawStruct->Place( this, DC ); + m_CurrentScreen->SetCurItem( NULL ); + TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + return; - case SCREEN_STRUCT_TYPE: - case DRAW_PICK_ITEM_STRUCT_TYPE: - DisplayError(this, - wxT("OnLeftClick err: unexpected type for Place")); - DrawStruct->m_Flags = 0; - break; + case SCREEN_STRUCT_TYPE: + case DRAW_PICK_ITEM_STRUCT_TYPE: + DisplayError( this, + wxT( "OnLeftClick err: unexpected type for Place" ) ); + DrawStruct->m_Flags = 0; + break; - case DRAW_SEGMENT_STRUCT_TYPE: // Segment peut-etre en cours de trace - break; + case DRAW_SEGMENT_STRUCT_TYPE: // Segment peut-etre en cours de trace + break; - default: - DisplayError(this, - wxT("WinEDA_SchematicFrame::OnLeftClick err: m_Flags != 0")); - DrawStruct->m_Flags = 0; - break; - } - } - else - { - DrawStruct = SchematicGeneralLocateAndDisplay(); - } - } + default: + DisplayError( this, + wxT( "WinEDA_SchematicFrame::OnLeftClick err: m_Flags != 0" ) ); + DrawStruct->m_Flags = 0; + break; + } + } + else + { + DrawStruct = SchematicGeneralLocateAndDisplay(); + } + } - switch ( m_ID_current_state ) - { - case 0: - break; + switch( m_ID_current_state ) + { + case 0: + break; - case ID_NO_SELECT_BUTT: - break; + case ID_NO_SELECT_BUTT: + break; - case ID_HIERARCHY_PUSH_POP_BUTT: - if ( DrawStruct && DrawStruct->m_Flags ) break; - DrawStruct = SchematicGeneralLocateAndDisplay(); - if ( DrawStruct && (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) ) - { - InstallNextScreen((DrawSheetStruct *) DrawStruct); - } - else InstallPreviousScreen(); - break; + case ID_HIERARCHY_PUSH_POP_BUTT: + if( DrawStruct && DrawStruct->m_Flags ) + break; + DrawStruct = SchematicGeneralLocateAndDisplay(); + if( DrawStruct && (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) ) + { + InstallNextScreen( (DrawSheetStruct*) DrawStruct ); + } + else + InstallPreviousScreen(); + break; - case ID_NOCONN_BUTT: - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - m_CurrentScreen->m_CurrentItem = - g_ItemToRepeat = CreateNewNoConnectStruct(DC); - DrawPanel->m_AutoPAN_Request = TRUE; - } - else - { - DrawStruct->Place(this, DC); - DrawPanel->m_AutoPAN_Request = FALSE; - } - TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); - break; + case ID_NOCONN_BUTT: + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + g_ItemToRepeat = CreateNewNoConnectStruct( DC ); + m_CurrentScreen->SetCurItem( g_ItemToRepeat ); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place( this, DC ); + DrawPanel->m_AutoPAN_Request = FALSE; + } + TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + break; - case ID_JUNCTION_BUTT: - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - m_CurrentScreen->m_CurrentItem = g_ItemToRepeat - = CreateNewJunctionStruct(DC, m_CurrentScreen->m_Curseur, TRUE); - DrawPanel->m_AutoPAN_Request = TRUE; - } - else - { - DrawStruct->Place(this, DC); - DrawPanel->m_AutoPAN_Request = FALSE; - } - TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); - break; + case ID_JUNCTION_BUTT: + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + g_ItemToRepeat = CreateNewJunctionStruct( DC, m_CurrentScreen->m_Curseur, TRUE ); + m_CurrentScreen->SetCurItem( g_ItemToRepeat ); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place( this, DC ); + DrawPanel->m_AutoPAN_Request = FALSE; + } + TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + break; - case ID_WIRETOBUS_ENTRY_BUTT: - case ID_BUSTOBUS_ENTRY_BUTT: - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - m_CurrentScreen->m_CurrentItem = DrawStruct = - CreateBusEntry(DC, - (m_ID_current_state == ID_WIRETOBUS_ENTRY_BUTT) ? - WIRE_TO_BUS : BUS_TO_BUS); - DrawPanel->m_AutoPAN_Request = TRUE; - } - else - { - DrawStruct->Place(this, DC); - m_CurrentScreen->m_CurrentItem = NULL; - TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); - DrawPanel->m_AutoPAN_Request = FALSE; - } - break; + case ID_WIRETOBUS_ENTRY_BUTT: + case ID_BUSTOBUS_ENTRY_BUTT: + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + DrawStruct = + CreateBusEntry( DC, + (m_ID_current_state == ID_WIRETOBUS_ENTRY_BUTT) ? + WIRE_TO_BUS : BUS_TO_BUS ); + m_CurrentScreen->SetCurItem( DrawStruct ); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place( this, DC ); + m_CurrentScreen->SetCurItem( NULL ); + TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + DrawPanel->m_AutoPAN_Request = FALSE; + } + break; - case ID_SCHEMATIC_DELETE_ITEM_BUTT: - LocateAndDeleteItem(this, DC); - m_CurrentScreen->SetModify(); - m_CurrentScreen->m_CurrentItem = NULL; - TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); - break; + case ID_SCHEMATIC_DELETE_ITEM_BUTT: + LocateAndDeleteItem( this, DC ); + m_CurrentScreen->SetModify(); + m_CurrentScreen->SetCurItem( NULL ); + TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + break; - case ID_WIRE_BUTT: - BeginSegment(DC, LAYER_WIRE); - DrawPanel->m_AutoPAN_Request = TRUE; - break; + case ID_WIRE_BUTT: + BeginSegment( DC, LAYER_WIRE ); + DrawPanel->m_AutoPAN_Request = TRUE; + break; - case ID_BUS_BUTT: - BeginSegment(DC, LAYER_BUS); - DrawPanel->m_AutoPAN_Request = TRUE; - break; + case ID_BUS_BUTT: + BeginSegment( DC, LAYER_BUS ); + DrawPanel->m_AutoPAN_Request = TRUE; + break; - case ID_LINE_COMMENT_BUTT: - BeginSegment(DC, LAYER_NOTES); - DrawPanel->m_AutoPAN_Request = TRUE; - break; + case ID_LINE_COMMENT_BUTT: + BeginSegment( DC, LAYER_NOTES ); + DrawPanel->m_AutoPAN_Request = TRUE; + break; - case ID_TEXT_COMMENT_BUTT: - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - m_CurrentScreen->m_CurrentItem = - CreateNewText(DC, LAYER_NOTES); - DrawPanel->m_AutoPAN_Request = TRUE; - } - else - { - DrawStruct->Place(this, DC); - DrawPanel->m_AutoPAN_Request = FALSE; - } - break; + case ID_TEXT_COMMENT_BUTT: + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->SetCurItem( CreateNewText( DC, LAYER_NOTES ) ); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place( this, DC ); + DrawPanel->m_AutoPAN_Request = FALSE; + } + break; - case ID_LABEL_BUTT: - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - m_CurrentScreen->m_CurrentItem = - CreateNewText(DC, LAYER_LOCLABEL); - DrawPanel->m_AutoPAN_Request = TRUE; - } - else - { - DrawStruct->Place( this, DC); - DrawPanel->m_AutoPAN_Request = FALSE; - TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); - } - break; + case ID_LABEL_BUTT: + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->SetCurItem( CreateNewText( DC, LAYER_LOCLABEL ) ); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place( this, DC ); + DrawPanel->m_AutoPAN_Request = FALSE; + TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + } + break; - case ID_GLABEL_BUTT: - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - m_CurrentScreen->m_CurrentItem = - CreateNewText(DC, LAYER_GLOBLABEL); - DrawPanel->m_AutoPAN_Request = TRUE; - } - else - { - DrawStruct->Place(this, DC); - DrawPanel->m_AutoPAN_Request = FALSE; - TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); - } - break; + case ID_GLABEL_BUTT: + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->SetCurItem( CreateNewText( DC, LAYER_GLOBLABEL ) ); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place( this, DC ); + DrawPanel->m_AutoPAN_Request = FALSE; + TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + } + break; - case ID_SHEET_SYMBOL_BUTT: - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - m_CurrentScreen->m_CurrentItem = CreateSheet(DC); - DrawPanel->m_AutoPAN_Request = TRUE; - } - else - { - DrawStruct->Place( this, DC); - DrawPanel->m_AutoPAN_Request = FALSE; - TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); - } - break; + case ID_SHEET_SYMBOL_BUTT: + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->SetCurItem( CreateSheet( DC ) ); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place( this, DC ); + DrawPanel->m_AutoPAN_Request = FALSE; + TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + } + break; - case ID_IMPORT_GLABEL_BUTT: - case ID_SHEET_LABEL_BUTT: - if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - DrawStruct = SchematicGeneralLocateAndDisplay(); + case ID_IMPORT_GLABEL_BUTT: + case ID_SHEET_LABEL_BUTT: + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + DrawStruct = SchematicGeneralLocateAndDisplay(); - if ( DrawStruct == NULL) break; + if( DrawStruct == NULL ) + break; - if( (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) && - (DrawStruct->m_Flags == 0) ) - { - if ( m_ID_current_state == ID_IMPORT_GLABEL_BUTT ) - m_CurrentScreen->m_CurrentItem = - Import_PinSheet( (DrawSheetStruct *) DrawStruct, DC); - else - m_CurrentScreen->m_CurrentItem = - Create_PinSheet( (DrawSheetStruct *) DrawStruct, DC); - } - else if( (DrawStruct->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE) && - (DrawStruct->m_Flags != 0) ) - { - DrawStruct->Place(this, DC); - TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); - } - break; + if( (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) + && (DrawStruct->m_Flags == 0) ) + { + if( m_ID_current_state == ID_IMPORT_GLABEL_BUTT ) + m_CurrentScreen->SetCurItem( + Import_PinSheet( (DrawSheetStruct*) DrawStruct, DC ) ); + else + m_CurrentScreen->SetCurItem( + Create_PinSheet( (DrawSheetStruct*) DrawStruct, DC ) ); + } + else if( (DrawStruct->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE) + && (DrawStruct->m_Flags != 0) ) + { + DrawStruct->Place( this, DC ); + TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + } + break; - case ID_COMPONENT_BUTT: - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - m_CurrentScreen->m_CurrentItem = Load_Component(DC, wxEmptyString, - s_CmpNameList, TRUE); - DrawPanel->m_AutoPAN_Request = TRUE; - } - else - { - DrawStruct->Place( this, DC); - DrawPanel->m_AutoPAN_Request = FALSE; - TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); - } - break; + case ID_COMPONENT_BUTT: + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->SetCurItem( Load_Component( DC, wxEmptyString, + s_CmpNameList, TRUE ) ); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place( this, DC ); + DrawPanel->m_AutoPAN_Request = FALSE; + TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + } + break; - case ID_PLACE_POWER_BUTT: - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - m_CurrentScreen->m_CurrentItem = - Load_Component(DC, wxT("power"),s_PowerNameList, FALSE); - DrawPanel->m_AutoPAN_Request = TRUE; - } - else - { - DrawStruct->Place( this, DC); - DrawPanel->m_AutoPAN_Request = FALSE; - TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); - } - break; + case ID_PLACE_POWER_BUTT: + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->SetCurItem( + Load_Component( DC, wxT( "power" ), s_PowerNameList, FALSE ) ); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place( this, DC ); + DrawPanel->m_AutoPAN_Request = FALSE; + TestDanglingEnds( m_CurrentScreen->EEDrawList, DC ); + } + break; - default : - { - SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); - wxString msg( wxT("WinEDA_SchematicFrame::OnLeftClick error state ")); - msg << m_ID_current_state; - DisplayError(this, msg); - break; - } - } + default: + { + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); + wxString msg( wxT( "WinEDA_SchematicFrame::OnLeftClick error state " ) ); + + msg << m_ID_current_state; + DisplayError( this, msg ); + break; + } + } } + /***************************************************************************/ -void WinEDA_SchematicFrame::OnLeftDClick(wxDC * DC, const wxPoint& MousePos) +void WinEDA_SchematicFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) /***************************************************************************/ + /* Appel� sur un double click: - pour un �l�ment editable (textes, composant): - appel de l'editeur correspondant. - pour une connexion en cours: - termine la connexion -*/ + * pour un �l�ment editable (textes, composant): + * appel de l'editeur correspondant. + * pour une connexion en cours: + * termine la connexion + */ { -EDA_BaseStruct * DrawStruct = m_CurrentScreen->m_CurrentItem; -wxPoint pos = GetPosition(); + EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem(); + wxPoint pos = GetPosition(); - switch ( m_ID_current_state ) - { - case 0: - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - DrawStruct = SchematicGeneralLocateAndDisplay(); - } + switch( m_ID_current_state ) + { + case 0: + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + DrawStruct = SchematicGeneralLocateAndDisplay(); + } - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) ) - break; + if( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) ) + break; - // Element localis� - switch ( DrawStruct->m_StructType ) - { - case DRAW_SHEET_STRUCT_TYPE: - InstallNextScreen((DrawSheetStruct *) DrawStruct); - break; - - case DRAW_LIB_ITEM_STRUCT_TYPE: - InstallCmpeditFrame(this, pos, (EDA_SchComponentStruct *) DrawStruct); - DrawPanel->MouseToCursorSchema(); - break; + // Element localis� + switch( DrawStruct->m_StructType ) + { + case DRAW_SHEET_STRUCT_TYPE: + InstallNextScreen( (DrawSheetStruct*) DrawStruct ); + break; - case DRAW_TEXT_STRUCT_TYPE: - case DRAW_LABEL_STRUCT_TYPE: - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - EditSchematicText( (DrawTextStruct*)DrawStruct, DC); - break; + case DRAW_LIB_ITEM_STRUCT_TYPE: + InstallCmpeditFrame( this, pos, (EDA_SchComponentStruct*) DrawStruct ); + DrawPanel->MouseToCursorSchema(); + break; - case DRAW_PART_TEXT_STRUCT_TYPE: - EditCmpFieldText( (PartTextStruct *)DrawStruct, DC); - DrawPanel->MouseToCursorSchema(); - break; + case DRAW_TEXT_STRUCT_TYPE: + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + EditSchematicText( (DrawTextStruct*) DrawStruct, DC ); + break; - default: - break; - } - break; // end case 0 + case DRAW_PART_TEXT_STRUCT_TYPE: + EditCmpFieldText( (PartTextStruct*) DrawStruct, DC ); + DrawPanel->MouseToCursorSchema(); + break; - case ID_BUS_BUTT: - case ID_WIRE_BUTT: - case ID_LINE_COMMENT_BUTT: - if ( DrawStruct && (DrawStruct->m_Flags & IS_NEW) ) - EndSegment(DC); - break; - } + default: + break; + } + + break; // end case 0 + + case ID_BUS_BUTT: + case ID_WIRE_BUTT: + case ID_LINE_COMMENT_BUTT: + if( DrawStruct && (DrawStruct->m_Flags & IS_NEW) ) + EndSegment( DC ); + break; + } } - - diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index ee94e40e98..a6bc5551d4 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -1,7 +1,7 @@ - /******************************************************************/ - /* onrightclick.cpp - creation du menu popup appele par le bouton */ - /* droit de la souris */ - /******************************************************************/ +/******************************************************************/ +/* onrightclick.cpp - creation du menu popup appele par le bouton */ +/* droit de la souris */ +/******************************************************************/ #ifdef __GNUG__ #pragma implementation @@ -44,514 +44,555 @@ #include "Edit_Comp_Value.xpm" /* functions to add commands and submenus depending on the item */ -static void AddMenusForBlock(wxMenu * PopMenu, WinEDA_SchematicFrame * frame); -static void AddMenusForWire(wxMenu * PopMenu, EDA_DrawLineStruct * Wire, - WinEDA_SchematicFrame * frame); -static void AddMenusForBus(wxMenu * PopMenu, EDA_DrawLineStruct * Bus, - WinEDA_SchematicFrame * frame); -static void AddMenusForHierchicalSheet(wxMenu * PopMenu, DrawSheetStruct * Sheet); -static void AddMenusForPinSheet(wxMenu * PopMenu, DrawSheetLabelStruct * PinSheet); -static void AddMenusForText(wxMenu * PopMenu, DrawTextStruct * Text ); -static void AddMenusForLabel(wxMenu * PopMenu, DrawLabelStruct * Label ); -static void AddMenusForGLabel(wxMenu * PopMenu, DrawGlobalLabelStruct * GLabel ); -static void AddMenusForComponent(wxMenu * PopMenu, EDA_SchComponentStruct * Component ); -static void AddMenusForComponentField(wxMenu * PopMenu, PartTextStruct * Field ); -static void AddMenusForJunction(wxMenu * PopMenu, DrawJunctionStruct * Junction, - WinEDA_SchematicFrame * frame); +static void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame ); +static void AddMenusForWire( wxMenu* PopMenu, EDA_DrawLineStruct* Wire, + WinEDA_SchematicFrame* frame ); +static void AddMenusForBus( wxMenu* PopMenu, EDA_DrawLineStruct* Bus, + WinEDA_SchematicFrame* frame ); +static void AddMenusForHierchicalSheet( wxMenu* PopMenu, DrawSheetStruct* Sheet ); +static void AddMenusForPinSheet( wxMenu* PopMenu, DrawSheetLabelStruct* PinSheet ); +static void AddMenusForText( wxMenu* PopMenu, DrawTextStruct* Text ); +static void AddMenusForLabel( wxMenu* PopMenu, DrawLabelStruct* Label ); +static void AddMenusForGLabel( wxMenu* PopMenu, DrawGlobalLabelStruct* GLabel ); +static void AddMenusForComponent( wxMenu* PopMenu, EDA_SchComponentStruct* Component ); +static void AddMenusForComponentField( wxMenu* PopMenu, PartTextStruct* Field ); +static void AddMenusForJunction( wxMenu* PopMenu, DrawJunctionStruct* Junction, + WinEDA_SchematicFrame* frame ); /***********************************************************************/ -void WinEDA_SchematicFrame::ToolOnRightClick(wxCommandEvent& event) +void WinEDA_SchematicFrame::ToolOnRightClick( wxCommandEvent& event ) /***********************************************************************/ { -int id = event.GetId(); + int id = event.GetId(); - switch ( id ) - { - default: - DisplayError(this, wxT("ToolOnRightClick() error")); - break; - } + switch( id ) + { + default: + DisplayError( this, wxT( "ToolOnRightClick() error" ) ); + break; + } } /*****************************************************************/ -void WinEDA_SchematicFrame::OnRightClick(const wxPoint& MousePos, - wxMenu * PopMenu) +void WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, + wxMenu* PopMenu ) /*****************************************************************/ + /* Prepare le menu PullUp affich� par un click sur le bouton droit -de la souris. - Ce menu est ensuite compl�t� par la liste des commandes de ZOOM -*/ + * de la souris. + * Ce menu est ensuite compl�t� par la liste des commandes de ZOOM + */ { -EDA_BaseStruct *DrawStruct = m_CurrentScreen->m_CurrentItem; -bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE); + EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem(); + bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE); - DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu + DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu - // Simple localisation des elements si possible - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - DrawStruct = SchematicGeneralLocateAndDisplay(FALSE); - if ( DrawStruct && (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) ) - { - DrawSheetLabelStruct * slabel; - slabel = LocateSheetLabel( (DrawSheetStruct *)DrawStruct, - m_CurrentScreen->m_Curseur); - if ( slabel ) DrawStruct = slabel; - } - } + // Simple localisation des elements si possible + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + DrawStruct = SchematicGeneralLocateAndDisplay( FALSE ); + if( DrawStruct && (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) ) + { + DrawSheetLabelStruct* slabel; + slabel = LocateSheetLabel( (DrawSheetStruct*) DrawStruct, + m_CurrentScreen->m_Curseur ); + if( slabel ) + DrawStruct = slabel; + } + } - // If Command in progress: put the menu "cancel" and "end tool" - if ( m_ID_current_state ) - { - if ( DrawStruct && DrawStruct->m_Flags ) - { - ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _("Cancel"), cancel_xpm); - } - else - { - ADD_MENUITEM(PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL, _("End Tool"), cancel_tool_xpm); - } - PopMenu->AppendSeparator(); - } + // If Command in progress: put the menu "cancel" and "end tool" + if( m_ID_current_state ) + { + if( DrawStruct && DrawStruct->m_Flags ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm ); + } + else + { + ADD_MENUITEM( PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL, _( "End Tool" ), cancel_tool_xpm ); + } + PopMenu->AppendSeparator(); + } + else + { + if( (DrawStruct && DrawStruct->m_Flags) || BlockActive ) + { + if( BlockActive ) + AddMenusForBlock( PopMenu, this ); + else + ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm ); + PopMenu->AppendSeparator(); + } + } - else - { - if ( (DrawStruct && DrawStruct->m_Flags) || BlockActive ) - { - if ( BlockActive ) AddMenusForBlock( PopMenu, this); - else ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _("Cancel"), cancel_xpm); - PopMenu->AppendSeparator(); - } - } + if( BlockActive ) + return; + if( DrawStruct == NULL ) + { + if( m_CurrentScreen != ScreenSch ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_LEAVE_SHEET, _( "Leave Sheet" ), leave_sheet_xpm ); + PopMenu->AppendSeparator(); + } + return; + } - if ( BlockActive ) return; - if ( DrawStruct == NULL ) - { - if ( m_CurrentScreen != ScreenSch ) - { - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_LEAVE_SHEET, _("Leave Sheet") , leave_sheet_xpm); - PopMenu->AppendSeparator(); - } - return; - } + m_CurrentScreen->SetCurItem( DrawStruct ); - m_CurrentScreen->m_CurrentItem = DrawStruct; + int flags = DrawStruct->m_Flags; + bool is_new = (flags & IS_NEW) ? TRUE : FALSE; + + switch( DrawStruct->m_StructType ) + { + case DRAW_NOCONNECT_STRUCT_TYPE: -int flags = DrawStruct->m_Flags; -bool is_new = (flags & IS_NEW) ? TRUE : FALSE; - - switch ( DrawStruct->m_StructType ) - { - case DRAW_NOCONNECT_STRUCT_TYPE: // if( !flags ) PopMenu->Append(ID_POPUP_SCH_MOVE_ITEM_REQUEST, "Move noconnect"); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("delete noconn"), delete_xpm); - break; + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "delete noconn" ), delete_xpm ); + break; - case DRAW_JUNCTION_STRUCT_TYPE: - AddMenusForJunction(PopMenu, (DrawJunctionStruct *)DrawStruct, this); - break; + case DRAW_JUNCTION_STRUCT_TYPE: + AddMenusForJunction( PopMenu, (DrawJunctionStruct*) DrawStruct, this ); + break; - case DRAW_BUSENTRY_STRUCT_TYPE: - if( !flags ) - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, - _("Move bus entry"), move_xpm); - if( GetBusEntryShape((DrawBusEntryStruct *)DrawStruct) == '\\') - PopMenu->Append(ID_POPUP_SCH_ENTRY_SELECT_SLASH, _("set bus entry /")); - else PopMenu->Append(ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH, _("set bus entry \\")); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, - _("delete bus entry"), delete_bus_xpm); - break; + case DRAW_BUSENTRY_STRUCT_TYPE: + if( !flags ) + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, + _( "Move bus entry" ), move_xpm ); + if( GetBusEntryShape( (DrawBusEntryStruct*) DrawStruct ) == '\\' ) + PopMenu->Append( ID_POPUP_SCH_ENTRY_SELECT_SLASH, _( "set bus entry /" ) ); + else + PopMenu->Append( ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH, _( "set bus entry \\" ) ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, + _( "delete bus entry" ), delete_bus_xpm ); + break; - case DRAW_MARKER_STRUCT_TYPE: - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("delete Marker"), delete_xpm); - break; + case DRAW_MARKER_STRUCT_TYPE: + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "delete Marker" ), delete_xpm ); + break; - case DRAW_TEXT_STRUCT_TYPE: - AddMenusForText( PopMenu, (DrawTextStruct *) DrawStruct); - break; + case DRAW_TEXT_STRUCT_TYPE: + AddMenusForText( PopMenu, (DrawTextStruct*) DrawStruct ); + break; - case DRAW_LABEL_STRUCT_TYPE: - AddMenusForLabel( PopMenu, (DrawLabelStruct *) DrawStruct); - break; + case DRAW_LABEL_STRUCT_TYPE: + AddMenusForLabel( PopMenu, (DrawLabelStruct*) DrawStruct ); + break; - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - AddMenusForGLabel(PopMenu, (DrawGlobalLabelStruct *) DrawStruct ); - break; + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + AddMenusForGLabel( PopMenu, (DrawGlobalLabelStruct*) DrawStruct ); + break; - case DRAW_PART_TEXT_STRUCT_TYPE: - { - AddMenusForComponentField(PopMenu, (PartTextStruct *) DrawStruct ); - if ( flags) break; - // Many fields are inside a component. If this is the case, add the component menu - EDA_SchComponentStruct * Component = LocateSmallestComponent( GetScreen() ); - if ( Component ) - { - PopMenu->AppendSeparator(); - AddMenusForComponent(PopMenu, (EDA_SchComponentStruct *) DrawStruct ); - } - } - break; + case DRAW_PART_TEXT_STRUCT_TYPE: + { + AddMenusForComponentField( PopMenu, (PartTextStruct*) DrawStruct ); + if( flags ) + break; - case DRAW_LIB_ITEM_STRUCT_TYPE: - AddMenusForComponent(PopMenu, (EDA_SchComponentStruct *) DrawStruct ); - break; + // Many fields are inside a component. If this is the case, add the component menu + EDA_SchComponentStruct* Component = LocateSmallestComponent( GetScreen() ); + if( Component ) + { + PopMenu->AppendSeparator(); + AddMenusForComponent( PopMenu, (EDA_SchComponentStruct*) DrawStruct ); + } + } + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE: + AddMenusForComponent( PopMenu, (EDA_SchComponentStruct*) DrawStruct ); + break; + + case DRAW_SEGMENT_STRUCT_TYPE: - case DRAW_SEGMENT_STRUCT_TYPE: // if( !flags ) PopMenu->Append(ID_POPUP_SCH_MOVE_ITEM_REQUEST, "Move"); - switch ( ((EDA_DrawLineStruct*)DrawStruct)->m_Layer) - { - case LAYER_WIRE: - AddMenusForWire(PopMenu, (EDA_DrawLineStruct*)DrawStruct, this); - break; + switch( ( (EDA_DrawLineStruct*) DrawStruct )->m_Layer ) + { + case LAYER_WIRE: + AddMenusForWire( PopMenu, (EDA_DrawLineStruct*) DrawStruct, this ); + break; - case LAYER_BUS: - AddMenusForBus(PopMenu, (EDA_DrawLineStruct*)DrawStruct, this); - break; + case LAYER_BUS: + AddMenusForBus( PopMenu, (EDA_DrawLineStruct*) DrawStruct, this ); + break; - default: - if ( is_new ) - ADD_MENUITEM(PopMenu, ID_POPUP_END_LINE, _("End drawing"), apply_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, - _("Delete drawing"), delete_xpm); - break; - } - break; + default: + if( is_new ) + ADD_MENUITEM( PopMenu, ID_POPUP_END_LINE, _( "End drawing" ), apply_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, + _( "Delete drawing" ), delete_xpm ); + break; + } - case DRAW_SHEET_STRUCT_TYPE: - AddMenusForHierchicalSheet(PopMenu, (DrawSheetStruct *) DrawStruct); - break; + break; - case DRAW_SHEETLABEL_STRUCT_TYPE: - AddMenusForPinSheet(PopMenu, (DrawSheetLabelStruct *) DrawStruct); - break; + case DRAW_SHEET_STRUCT_TYPE: + AddMenusForHierchicalSheet( PopMenu, (DrawSheetStruct*) DrawStruct ); + break; - default: - wxString msg; - msg.Printf( - wxT("WinEDA_SchematicFrame::OnRightClick Error: unknown DrawType %d"), - DrawStruct->m_StructType); - DisplayError(this, msg ); - break; - } + case DRAW_SHEETLABEL_STRUCT_TYPE: + AddMenusForPinSheet( PopMenu, (DrawSheetLabelStruct*) DrawStruct ); + break; - PopMenu->AppendSeparator(); + default: + wxString msg; + msg.Printf( + wxT( "WinEDA_SchematicFrame::OnRightClick Error: unknown DrawType %d" ), + DrawStruct->m_StructType ); + DisplayError( this, msg ); + break; + } + + PopMenu->AppendSeparator(); } /*************************************************************************/ -void AddMenusForComponentField(wxMenu * PopMenu, PartTextStruct * Field ) +void AddMenusForComponentField( wxMenu* PopMenu, PartTextStruct* Field ) /*************************************************************************/ + /* Add menu commands for a component field (like value, reference) -*/ + */ { - if( ! Field->m_Flags ) - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _("Move Field"), move_text_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ROTATE_FIELD, _("Rotate Field"), rotate_field_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_FIELD, _("Edit Field"), edit_text_xpm); + if( !Field->m_Flags ) + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Field" ), move_text_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_FIELD, _( "Rotate Field" ), rotate_field_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_FIELD, _( "Edit Field" ), edit_text_xpm ); } + /**************************************************************************/ -void AddMenusForComponent(wxMenu * PopMenu, EDA_SchComponentStruct * Component ) +void AddMenusForComponent( wxMenu* PopMenu, EDA_SchComponentStruct* Component ) /**************************************************************************/ + /* Add menu commands for a component -*/ + */ { -EDA_LibComponentStruct * LibEntry; - - LibEntry = FindLibPart(Component->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + EDA_LibComponentStruct* LibEntry; - if( ! Component->m_Flags ) - { - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_CMP_REQUEST, - _("Move Component (M)"), move_xpm); - } - // add menu orient et sous menu: - wxMenu *orientmenu = new wxMenu; - ADD_MENUITEM(orientmenu, ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE, - _("Rotate + (R)"), rotate_pos_xpm); - ADD_MENUITEM(orientmenu, ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE, _("Rotate -"), rotate_neg_xpm); - ADD_MENUITEM(orientmenu, ID_POPUP_SCH_MIROR_X_CMP, _("Mirror -- (X)"), mirror_V_xpm); - ADD_MENUITEM(orientmenu, ID_POPUP_SCH_MIROR_Y_CMP, _("Mirror || (Y)"), mirror_H_xpm); - ADD_MENUITEM(orientmenu, ID_POPUP_SCH_ORIENT_NORMAL_CMP, _("Normal (N)"), normal_xpm); - ADD_MENUITEM_WITH_SUBMENU(PopMenu, orientmenu, - ID_POPUP_SCH_GENERIC_ORIENT_CMP, _("Orient Component"), orient_xpm); + LibEntry = FindLibPart( Component->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); - wxMenu *editmenu = new wxMenu; - ADD_MENUITEM(editmenu, ID_POPUP_SCH_EDIT_CMP, _("Edit"), edit_component_xpm); - - if ( LibEntry && LibEntry->m_Options != ENTRY_POWER ) - { - ADD_MENUITEM(editmenu, ID_POPUP_SCH_EDIT_VALUE_CMP, _("Value"), edit_comp_value_xpm); - ADD_MENUITEM(editmenu, ID_POPUP_SCH_EDIT_REF_CMP, _("Reference"), edit_comp_ref_xpm); - } - if( LibEntry && (LookForConvertPart(LibEntry) >= 2) ) - editmenu->Append(ID_POPUP_SCH_EDIT_CONVERT_CMP, _("Convert")); - if( LibEntry && (LibEntry->m_UnitCount >= 2) ) - { - wxMenu *sel_unit_menu = new wxMenu; int ii; - for( ii = 0; ii < LibEntry->m_UnitCount; ii++ ) - { - wxString num_unit; num_unit.Printf( _("Unit %d %c"), ii+1, "?ABCDEFGHIJKLMNOPQRSTUVWXYZ"[ii+1]); - sel_unit_menu->Append(ID_POPUP_SCH_SELECT_UNIT1 + ii, - num_unit); - } - editmenu->Append(ID_POPUP_SCH_SELECT_UNIT_CMP, _("Unit"), sel_unit_menu); - } + if( !Component->m_Flags ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_CMP_REQUEST, + _( "Move Component (M)" ), move_xpm ); + } - ADD_MENUITEM_WITH_SUBMENU(PopMenu, editmenu, - ID_POPUP_SCH_GENERIC_EDIT_CMP, _("Edit Component"), edit_component_xpm); + // add menu orient et sous menu: + wxMenu* orientmenu = new wxMenu; + ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE, + _( "Rotate + (R)" ), rotate_pos_xpm ); + ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE, _( "Rotate -" ), rotate_neg_xpm ); + ADD_MENUITEM( orientmenu, ID_POPUP_SCH_MIROR_X_CMP, _( "Mirror -- (X)" ), mirror_V_xpm ); + ADD_MENUITEM( orientmenu, ID_POPUP_SCH_MIROR_Y_CMP, _( "Mirror || (Y)" ), mirror_H_xpm ); + ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ORIENT_NORMAL_CMP, _( "Normal (N)" ), normal_xpm ); + ADD_MENUITEM_WITH_SUBMENU( PopMenu, orientmenu, + ID_POPUP_SCH_GENERIC_ORIENT_CMP, _( + "Orient Component" ), orient_xpm ); - if( ! Component->m_Flags ) - { - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_COPY_COMPONENT_CMP, _("Copy Component"), import_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE_CMP, _("Delete Component"), delete_xpm); - } - - LibEntry = FindLibPart(Component->m_ChipName.GetData(), wxEmptyString, FIND_ALIAS); - if ( LibEntry && ! LibEntry->m_DocFile.IsEmpty() ) - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DISPLAYDOC_CMP, _("Doc"), datasheet_xpm); + wxMenu* editmenu = new wxMenu; + ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_CMP, _( "Edit" ), edit_component_xpm ); + + if( LibEntry && LibEntry->m_Options != ENTRY_POWER ) + { + ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_VALUE_CMP, _( "Value" ), edit_comp_value_xpm ); + ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_REF_CMP, _( "Reference" ), edit_comp_ref_xpm ); + } + if( LibEntry && (LookForConvertPart( LibEntry ) >= 2) ) + editmenu->Append( ID_POPUP_SCH_EDIT_CONVERT_CMP, _( "Convert" ) ); + if( LibEntry && (LibEntry->m_UnitCount >= 2) ) + { + wxMenu* sel_unit_menu = new wxMenu; int ii; + for( ii = 0; ii < LibEntry->m_UnitCount; ii++ ) + { + wxString num_unit; num_unit.Printf( _( + "Unit %d %c" ), ii + 1, + "?ABCDEFGHIJKLMNOPQRSTUVWXYZ"[ii + 1] ); + sel_unit_menu->Append( ID_POPUP_SCH_SELECT_UNIT1 + ii, + num_unit ); + } + + editmenu->Append( ID_POPUP_SCH_SELECT_UNIT_CMP, _( "Unit" ), sel_unit_menu ); + } + + ADD_MENUITEM_WITH_SUBMENU( PopMenu, editmenu, + ID_POPUP_SCH_GENERIC_EDIT_CMP, _( + "Edit Component" ), edit_component_xpm ); + + if( !Component->m_Flags ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_COMPONENT_CMP, _( "Copy Component" ), import_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CMP, _( "Delete Component" ), delete_xpm ); + } + + LibEntry = FindLibPart( Component->m_ChipName.GetData(), wxEmptyString, FIND_ALIAS ); + if( LibEntry && !LibEntry->m_DocFile.IsEmpty() ) + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DISPLAYDOC_CMP, _( "Doc" ), datasheet_xpm ); } +/*******************************************************************/ +void AddMenusForGLabel( wxMenu* PopMenu, DrawGlobalLabelStruct* GLabel ) +/*******************************************************************/ -/*******************************************************************/ -void AddMenusForGLabel(wxMenu * PopMenu, DrawGlobalLabelStruct * GLabel ) -/*******************************************************************/ /* Add menu commands for a Global Label -*/ + */ { -wxMenu * menu_change_type = new wxMenu; - if( ! GLabel->m_Flags ) - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _("Move Glabel"), move_text_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _("Rotate GLabel (R)"), rotate_glabel_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_TEXT, _("Edit GLabel"), edit_text_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete Glabel"), delete_text_xpm); + wxMenu* menu_change_type = new wxMenu; - // add menu change type text (to label, glabel, text): - ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL, - _("Change to Label"), glabel2label_xpm); - ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT, - _("Change to Text"), glabel2text_xpm); - ADD_MENUITEM_WITH_SUBMENU(PopMenu, menu_change_type, - ID_POPUP_SCH_CHANGE_TYPE_TEXT, _("Change Type"), gl_change_xpm); + if( !GLabel->m_Flags ) + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Glabel" ), move_text_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _( "Rotate GLabel (R)" ), rotate_glabel_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, _( "Edit GLabel" ), edit_text_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Glabel" ), delete_text_xpm ); + + // add menu change type text (to label, glabel, text): + ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL, + _( "Change to Label" ), glabel2label_xpm ); + ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT, + _( "Change to Text" ), glabel2text_xpm ); + ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, + ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm ); } + /*****************************************************************/ -void AddMenusForLabel(wxMenu * PopMenu, DrawLabelStruct * Label ) +void AddMenusForLabel( wxMenu* PopMenu, DrawLabelStruct* Label ) /*****************************************************************/ + /* Add menu commands for a Label -*/ + */ { -wxMenu * menu_change_type = new wxMenu; - - if( ! Label->m_Flags ) - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _("Move Label"), move_text_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _("Rotate Label (R)"), rotate_pos_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_TEXT, _("Edit Label"), edit_text_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete Label"), delete_text_xpm); + wxMenu* menu_change_type = new wxMenu; - // add menu change type text (to label, glabel, text): - ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL, - _("Change to Glabel"), label2glabel_xpm); - ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT, - _("Change to Text"), label2text_xpm); - ADD_MENUITEM_WITH_SUBMENU(PopMenu, menu_change_type, - ID_POPUP_SCH_CHANGE_TYPE_TEXT, _("Change Type"), gl_change_xpm); + if( !Label->m_Flags ) + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Label" ), move_text_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _( "Rotate Label (R)" ), rotate_pos_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, _( "Edit Label" ), edit_text_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Label" ), delete_text_xpm ); + + // add menu change type text (to label, glabel, text): + ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL, + _( "Change to Glabel" ), label2glabel_xpm ); + ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT, + _( "Change to Text" ), label2text_xpm ); + ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, + ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm ); } - + + /*****************************************************************/ -void AddMenusForText(wxMenu * PopMenu, DrawTextStruct * Text ) +void AddMenusForText( wxMenu* PopMenu, DrawTextStruct* Text ) /*****************************************************************/ + /* Add menu commands for a Text (a comment) -*/ + */ { -wxMenu * menu_change_type = new wxMenu; - - if( ! Text->m_Flags ) - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _("Move Text"), move_text_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _("Rotate Text (R)"), rotate_pos_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_TEXT, _("Edit Text"), edit_text_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete Text"), delete_text_xpm); + wxMenu* menu_change_type = new wxMenu; - // add menu change type text (to label, glabel, text): - ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL, - _("Change to Label"), label2text_xpm); - ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL, - _("Change to Glabel"), label2glabel_xpm); - ADD_MENUITEM_WITH_SUBMENU(PopMenu, menu_change_type, - ID_POPUP_SCH_CHANGE_TYPE_TEXT, _("Change Type"), gl_change_xpm); + if( !Text->m_Flags ) + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Text" ), move_text_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _( "Rotate Text (R)" ), rotate_pos_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, _( "Edit Text" ), edit_text_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Text" ), delete_text_xpm ); + + // add menu change type text (to label, glabel, text): + ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL, + _( "Change to Label" ), label2text_xpm ); + ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL, + _( "Change to Glabel" ), label2glabel_xpm ); + ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, + ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm ); } - /*****************************************************************/ -void AddMenusForJunction(wxMenu * PopMenu, DrawJunctionStruct * Junction, - WinEDA_SchematicFrame * frame) +void AddMenusForJunction( wxMenu* PopMenu, DrawJunctionStruct* Junction, + WinEDA_SchematicFrame* frame ) /*****************************************************************/ + /* Add menu commands for a junction -*/ + */ { -bool is_new = (Junction->m_Flags & IS_NEW) ? TRUE : FALSE; - if ( ! is_new ) - { - if ( PickStruct(frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList, - WIREITEM|BUSITEM|EXCLUDE_WIRE_BUS_ENDPOINTS) ) - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_BREAK_WIRE, _("Break Wire"), break_line_xpm); - } - - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("delete junction"), delete_xpm); - - if ( PickStruct(frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList, - WIREITEM|BUSITEM) ) - { - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE_NODE, _("Delete node"), delete_node_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _("Delete connection"), delete_connection_xpm); - } + bool is_new = (Junction->m_Flags & IS_NEW) ? TRUE : FALSE; + + if( !is_new ) + { + if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList, + WIREITEM | BUSITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) ) + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm ); + } + + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "delete junction" ), delete_xpm ); + + if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList, + WIREITEM | BUSITEM ) ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete node" ), delete_node_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( + "Delete connection" ), delete_connection_xpm ); + } } + /*****************************************************************/ -void AddMenusForWire(wxMenu * PopMenu, EDA_DrawLineStruct * Wire, - WinEDA_SchematicFrame * frame) +void AddMenusForWire( wxMenu* PopMenu, EDA_DrawLineStruct* Wire, + WinEDA_SchematicFrame* frame ) /*****************************************************************/ + /* Add menu commands for a wire -*/ + */ { -bool is_new = (Wire->m_Flags & IS_NEW) ? TRUE : FALSE; -wxPoint pos = frame->GetScreen()->m_Curseur; - - if ( is_new ) - ADD_MENUITEM(PopMenu, ID_POPUP_END_LINE, _("End Wire"), apply_xpm); + bool is_new = (Wire->m_Flags & IS_NEW) ? TRUE : FALSE; + wxPoint pos = frame->GetScreen()->m_Curseur; - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete Wire"), delete_xpm); - - if ( is_new ) return; - - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE_NODE, _("Delete node"), delete_node_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _("Delete connection"), delete_connection_xpm); + if( is_new ) + ADD_MENUITEM( PopMenu, ID_POPUP_END_LINE, _( "End Wire" ), apply_xpm ); - if ( PickStruct(frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList, - WIREITEM|BUSITEM|EXCLUDE_WIRE_BUS_ENDPOINTS) ) - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_BREAK_WIRE, _("Break Wire"), break_line_xpm); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Wire" ), delete_xpm ); - PopMenu->AppendSeparator(); + if( is_new ) + return; - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _("Add junction") , add_junction_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_LABEL, _("Add label") , add_line_label_xpm); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete node" ), delete_node_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( + "Delete connection" ), delete_connection_xpm ); - // Place Global label command only if the cursor is over one end of the Wire: - if ( ( pos.x == Wire->m_Start.x && pos.y == Wire->m_Start.y) || - ( pos.x == Wire->m_End.x && pos.y == Wire->m_End.y ) ) - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_GLABEL, _("Add global label") , add_glabel_xpm); + if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList, + WIREITEM | BUSITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) ) + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm ); + + PopMenu->AppendSeparator(); + + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _( "Add junction" ), add_junction_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_LABEL, _( "Add label" ), add_line_label_xpm ); + + // Place Global label command only if the cursor is over one end of the Wire: + if( ( pos.x == Wire->m_Start.x && pos.y == Wire->m_Start.y) + || ( pos.x == Wire->m_End.x && pos.y == Wire->m_End.y ) ) + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add global label" ), add_glabel_xpm ); } + /*****************************************************************/ -void AddMenusForBus(wxMenu * PopMenu, EDA_DrawLineStruct * Bus, - WinEDA_SchematicFrame * frame) +void AddMenusForBus( wxMenu* PopMenu, EDA_DrawLineStruct* Bus, + WinEDA_SchematicFrame* frame ) /*****************************************************************/ + /* Add menu commands for a Bus -*/ + */ { -bool is_new = (Bus->m_Flags & IS_NEW) ? TRUE : FALSE; -wxPoint pos = frame->GetScreen()->m_Curseur; + bool is_new = (Bus->m_Flags & IS_NEW) ? TRUE : FALSE; + wxPoint pos = frame->GetScreen()->m_Curseur; - if ( is_new ) ADD_MENUITEM(PopMenu, ID_POPUP_END_LINE, _("End Bus"), apply_xpm); + if( is_new ) + ADD_MENUITEM( PopMenu, ID_POPUP_END_LINE, _( "End Bus" ), apply_xpm ); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, - _("Delete Bus"), delete_bus_xpm); - - if ( ! is_new ) - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_BREAK_WIRE, - _("Break Bus"), break_bus_xpm); - - PopMenu->AppendSeparator(); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _("Add junction") , add_junction_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_LABEL, _("Add label") , add_line_label_xpm); - // Place Global label command only if the cursor is over one end of the Bus: - if ( ( pos.x == Bus->m_Start.x && pos.y == Bus->m_Start.y) || - ( pos.x == Bus->m_End.x && pos.y == Bus->m_End.y ) ) - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_GLABEL, _("Add global label") , add_glabel_xpm); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, + _( "Delete Bus" ), delete_bus_xpm ); + + if( !is_new ) + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, + _( "Break Bus" ), break_bus_xpm ); + + PopMenu->AppendSeparator(); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _( "Add junction" ), add_junction_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_LABEL, _( "Add label" ), add_line_label_xpm ); + + // Place Global label command only if the cursor is over one end of the Bus: + if( ( pos.x == Bus->m_Start.x && pos.y == Bus->m_Start.y) + || ( pos.x == Bus->m_End.x && pos.y == Bus->m_End.y ) ) + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add global label" ), add_glabel_xpm ); } + /************************************************************************/ -void AddMenusForHierchicalSheet(wxMenu * PopMenu, DrawSheetStruct * Sheet) +void AddMenusForHierchicalSheet( wxMenu* PopMenu, DrawSheetStruct* Sheet ) /************************************************************************/ + /* Add menu commands for a Sheet -*/ + */ { - if( ! Sheet->m_Flags ) - { - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ENTER_SHEET, _("Enter Sheet"), enter_sheet_xpm); - PopMenu->AppendSeparator(); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _("Move Sheet"), move_sheet_xpm); - } - - if ( Sheet->m_Flags ) - { - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_END_SHEET, _("Place Sheet"), apply_xpm); - } - else - { - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_SHEET, _("Edit Sheet"), edit_sheet_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_RESIZE_SHEET, _("Resize Sheet"), resize_sheet_xpm); - if ( Sheet->m_Label ) // Sheet has pin labels, and can be cleaned - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_CLEANUP_SHEET, - _("Cleanup PinSheets"), options_pinsheet_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete Sheet"), delete_sheet_xpm); - } + if( !Sheet->m_Flags ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ENTER_SHEET, _( "Enter Sheet" ), enter_sheet_xpm ); + PopMenu->AppendSeparator(); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Sheet" ), move_sheet_xpm ); + } + + if( Sheet->m_Flags ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_END_SHEET, _( "Place Sheet" ), apply_xpm ); + } + else + { + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_SHEET, _( "Edit Sheet" ), edit_sheet_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_RESIZE_SHEET, _( "Resize Sheet" ), resize_sheet_xpm ); + if( Sheet->m_Label ) // Sheet has pin labels, and can be cleaned + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_CLEANUP_SHEET, + _( "Cleanup PinSheets" ), options_pinsheet_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Sheet" ), delete_sheet_xpm ); + } } /************************************************************************/ -void AddMenusForPinSheet(wxMenu * PopMenu, DrawSheetLabelStruct * PinSheet) +void AddMenusForPinSheet( wxMenu* PopMenu, DrawSheetLabelStruct* PinSheet ) /************************************************************************/ + /* Add menu commands for a Pin Sheet (or Sheet label) -*/ + */ { - if( ! PinSheet->m_Flags ) - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_PINSHEET, _("Move PinSheet"), move_xpm); + if( !PinSheet->m_Flags ) + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_PINSHEET, _( "Move PinSheet" ), move_xpm ); - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_PINSHEET, _("Edit PinSheet"), edit_xpm); + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_PINSHEET, _( "Edit PinSheet" ), edit_xpm ); - if( ! PinSheet->m_Flags ) - ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete PinSheet"), delete_pinsheet_xpm); + if( !PinSheet->m_Flags ) + ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete PinSheet" ), delete_pinsheet_xpm ); } + /**********************************************************************/ -void AddMenusForBlock(wxMenu * PopMenu, WinEDA_SchematicFrame * frame) +void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame ) /**********************************************************************/ + /* Add menu commands for block -*/ + */ { - ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _("Cancel Block"), cancel_xpm); + ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ), cancel_xpm ); - PopMenu->AppendSeparator(); + PopMenu->AppendSeparator(); - if ( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) - ADD_MENUITEM(PopMenu, ID_POPUP_ZOOM_BLOCK, - _("Win. Zoom (Midd butt drag mouse)"), zoom_selected_xpm); + if( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) + ADD_MENUITEM( PopMenu, ID_POPUP_ZOOM_BLOCK, + _( "Win. Zoom (Midd butt drag mouse)" ), zoom_selected_xpm ); - ADD_MENUITEM(PopMenu, ID_POPUP_PLACE_BLOCK, _("Place Block"), apply_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_PLACE_BLOCK, _( "Place Block" ), apply_xpm ); - if ( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) - { - wxMenu * menu_other_block_commands = new wxMenu; - ADD_MENUITEM_WITH_SUBMENU(PopMenu, menu_other_block_commands, - -1, _("Other block commands"), right_xpm); - ADD_MENUITEM(menu_other_block_commands, wxID_COPY, _("Save Block"), copy_button); - ADD_MENUITEM(menu_other_block_commands, ID_POPUP_COPY_BLOCK, - _("Copy Block (shift + drag mouse)"), copyblock_xpm); - ADD_MENUITEM(menu_other_block_commands, ID_POPUP_DRAG_BLOCK, _("Drag Block (ctrl + drag mouse)"), move_xpm ); - ADD_MENUITEM(menu_other_block_commands, ID_POPUP_DELETE_BLOCK, - _("Del. Block (shift+ctrl + drag mouse)"), delete_xpm ); - ADD_MENUITEM(menu_other_block_commands, ID_POPUP_MIRROR_Y_BLOCK, _("Mirror Block ||"), mirror_H_xpm); + if( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) + { + wxMenu* menu_other_block_commands = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_other_block_commands, + -1, _( "Other block commands" ), right_xpm ); + ADD_MENUITEM( menu_other_block_commands, wxID_COPY, _( "Save Block" ), copy_button ); + ADD_MENUITEM( menu_other_block_commands, ID_POPUP_COPY_BLOCK, + _( "Copy Block (shift + drag mouse)" ), copyblock_xpm ); + ADD_MENUITEM( menu_other_block_commands, ID_POPUP_DRAG_BLOCK, + _( "Drag Block (ctrl + drag mouse)" ), move_xpm ); + ADD_MENUITEM( menu_other_block_commands, ID_POPUP_DELETE_BLOCK, + _( "Del. Block (shift+ctrl + drag mouse)" ), delete_xpm ); + ADD_MENUITEM( menu_other_block_commands, ID_POPUP_MIRROR_Y_BLOCK, _( + "Mirror Block ||" ), mirror_H_xpm ); #if 0 #ifdef __WINDOWS__ - ADD_MENUITEM(menu_other_block_commands, ID_GEN_COPY_BLOCK_TO_CLIPBOARD, - _("Copy to Clipboard"), copy_button); + ADD_MENUITEM( menu_other_block_commands, ID_GEN_COPY_BLOCK_TO_CLIPBOARD, + _( "Copy to Clipboard" ), copy_button ); #endif #endif - } + } } diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 6c3531ffe8..ca4c202d67 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -1,6 +1,6 @@ - /******************************************************/ - /* schedit.cpp: fonctions generales de la schematique */ - /******************************************************/ +/******************************************************/ +/* schedit.cpp: fonctions generales de la schematique */ +/******************************************************/ #include "fctsys.h" @@ -16,778 +16,812 @@ #include "protos.h" /********************************************************************************/ -void WinEDA_SchematicFrame::Process_Special_Functions(wxCommandEvent& event) +void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) /********************************************************************************/ + /* Traite les selections d'outils et les commandes appelees du menu POPUP -*/ + */ { -int id = event.GetId(); -wxPoint pos; -wxClientDC dc(DrawPanel); -wxPoint defaultpos(-1,-1); - - DrawPanel->PrepareGraphicContext(&dc); - - pos = wxGetMousePosition(); - - pos.y += 20; - - // If needed, stop the current command and deselect current tool - switch ( id ) - { - case ID_POPUP_SCH_ENTRY_SELECT_SLASH: // Do nothing: - case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH: - case ID_POPUP_END_LINE: - case ID_POPUP_SCH_EDIT_TEXT: - case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL: - case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL: - case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT: - case ID_POPUP_SCH_SET_SHAPE_TEXT: - case ID_POPUP_SCH_ROTATE_TEXT: - case ID_POPUP_SCH_EDIT_SHEET: - case ID_POPUP_SCH_CLEANUP_SHEET: - case ID_POPUP_SCH_END_SHEET: - case ID_POPUP_SCH_RESIZE_SHEET: - case ID_POPUP_SCH_EDIT_PINSHEET: - case ID_POPUP_SCH_MOVE_PINSHEET: - case ID_POPUP_SCH_MOVE_ITEM_REQUEST: - case ID_POPUP_SCH_MOVE_CMP_REQUEST: - case ID_POPUP_SCH_EDIT_CMP: - case ID_POPUP_SCH_MIROR_X_CMP: - case ID_POPUP_SCH_MIROR_Y_CMP: - case ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE: - case ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE: - case ID_POPUP_SCH_ORIENT_NORMAL_CMP: - case ID_POPUP_SCH_INIT_CMP: - case ID_POPUP_SCH_DISPLAYDOC_CMP: - case ID_POPUP_SCH_EDIT_VALUE_CMP: - case ID_POPUP_SCH_EDIT_REF_CMP: - case ID_POPUP_SCH_EDIT_CONVERT_CMP: - case ID_POPUP_SCH_SELECT_UNIT_CMP: - case ID_POPUP_SCH_SELECT_UNIT1: - case ID_POPUP_SCH_SELECT_UNIT2: - case ID_POPUP_SCH_SELECT_UNIT3: - case ID_POPUP_SCH_SELECT_UNIT4: - case ID_POPUP_SCH_SELECT_UNIT5: - case ID_POPUP_SCH_SELECT_UNIT6: - case ID_POPUP_SCH_SELECT_UNIT7: - case ID_POPUP_SCH_SELECT_UNIT8: - case ID_POPUP_SCH_SELECT_UNIT9: - case ID_POPUP_SCH_SELECT_UNIT10: - case ID_POPUP_SCH_SELECT_UNIT11: - case ID_POPUP_SCH_SELECT_UNIT12: - case ID_POPUP_SCH_SELECT_UNIT13: - case ID_POPUP_SCH_SELECT_UNIT14: - case ID_POPUP_SCH_SELECT_UNIT15: - case ID_POPUP_SCH_SELECT_UNIT16: - case ID_POPUP_SCH_SELECT_UNIT17: - case ID_POPUP_SCH_SELECT_UNIT18: - case ID_POPUP_SCH_SELECT_UNIT19: - case ID_POPUP_SCH_SELECT_UNIT20: - case ID_POPUP_SCH_SELECT_UNIT21: - case ID_POPUP_SCH_SELECT_UNIT22: - case ID_POPUP_SCH_SELECT_UNIT23: - case ID_POPUP_SCH_SELECT_UNIT24: - case ID_POPUP_SCH_SELECT_UNIT25: - case ID_POPUP_SCH_SELECT_UNIT26: - case ID_POPUP_SCH_ROTATE_FIELD: - case ID_POPUP_SCH_EDIT_FIELD: - case ID_POPUP_DELETE_BLOCK: - case ID_POPUP_PLACE_BLOCK: - case ID_POPUP_ZOOM_BLOCK: - case ID_POPUP_DRAG_BLOCK: - case ID_POPUP_COPY_BLOCK: - case ID_POPUP_ROTATE_BLOCK: - case ID_POPUP_MIRROR_X_BLOCK: - case ID_POPUP_MIRROR_Y_BLOCK: - case ID_POPUP_SCH_DELETE_NODE: - case ID_POPUP_SCH_DELETE_CONNECTION: - case wxID_CUT: - case wxID_COPY: - case ID_POPUP_SCH_ENTER_SHEET: - case ID_POPUP_SCH_LEAVE_SHEET: - case ID_POPUP_SCH_ADD_JUNCTION: - case ID_POPUP_SCH_ADD_LABEL: - break; // Do nothing: - - case ID_POPUP_CANCEL_CURRENT_COMMAND: - if (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE) - DrawPanel->SetCursor(wxCursor(DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor) ); - - if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) - { - DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); - } - /* ne devrait pas etre execute, sauf bug: */ - if (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE) - { - m_CurrentScreen->BlockLocate.m_Command = BLOCK_IDLE; - m_CurrentScreen->BlockLocate.m_State = STATE_NO_BLOCK; - m_CurrentScreen->BlockLocate.m_BlockDrawStruct = NULL; - } - break; - - case ID_POPUP_SCH_DELETE_CMP: - case ID_POPUP_SCH_DELETE: // Stop the, current command, keep the current tool - if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) - { - DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); - } - break; - - default: // Stop the current command, and deselect the current tool - if(DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) - { - DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); - } - DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor = wxCURSOR_ARROW; - SetToolID(0, DrawPanel->m_PanelCursor, wxEmptyString); - break; - } // End switch commande en cours - - switch ( id ) // Command execution: - { - case ID_EXIT : - Close(TRUE); - break; - - case ID_NEW_PROJECT: /* New EED Project */ - LoadOneEEProject( wxEmptyString, TRUE); - break; - - case ID_LOAD_PROJECT: - LoadOneEEProject( wxEmptyString, FALSE); - break; - - case ID_LOAD_ONE_SHEET: - LoadOneSheet(GetScreen(), wxEmptyString); - break; - - case ID_LOAD_FILE_1: - case ID_LOAD_FILE_2: - case ID_LOAD_FILE_3: - case ID_LOAD_FILE_4: - case ID_LOAD_FILE_5: - case ID_LOAD_FILE_6: - case ID_LOAD_FILE_7: - case ID_LOAD_FILE_8: - case ID_LOAD_FILE_9: - case ID_LOAD_FILE_10: - LoadOneEEProject(GetLastProject(id - ID_LOAD_FILE_1).GetData(), FALSE); - break; - - case ID_TO_LIBRARY : - if ( m_Parent->LibeditFrame ) - { - m_Parent->LibeditFrame->Show(TRUE); - } - else - { - m_Parent->LibeditFrame = new - WinEDA_LibeditFrame(m_Parent->SchematicFrame, - m_Parent, - wxT("Library Editor"), - wxPoint(-1,-1), wxSize(600,400) ); - ActiveScreen = ScreenLib; - m_Parent->LibeditFrame->AdjustScrollBars(); - } - break; - - case ID_TO_PCB: - { - wxString Line; - if( ScreenSch->m_FileName != wxEmptyString ) - { - Line = ScreenSch->m_FileName; - AddDelimiterString(Line); - ChangeFileNameExt( Line,wxEmptyString); - ExecuteFile(this, PCBNEW_EXE, Line); - } - - else ExecuteFile(this, PCBNEW_EXE); - break; - } - - case ID_TO_CVPCB: - { - wxString Line; - if( ScreenSch->m_FileName != wxEmptyString ) - { - Line = ScreenSch->m_FileName; - AddDelimiterString(Line); - ChangeFileNameExt( Line,wxEmptyString); - ExecuteFile(this, CVPCB_EXE, Line); - } - - else ExecuteFile(this, CVPCB_EXE); - break; - } - - case ID_TO_LIBVIEW : - if ( m_Parent->ViewlibFrame ) - { - m_Parent->ViewlibFrame->Show(TRUE); - } - else - { - m_Parent->ViewlibFrame = new - WinEDA_ViewlibFrame(m_Parent->SchematicFrame, m_Parent); - m_Parent->ViewlibFrame->AdjustScrollBars(); - } - break; - - case ID_HIERARCHY: - InstallHierarchyFrame(&dc, pos); - g_ItemToRepeat = NULL; - break; - - case wxID_CUT: - if ( m_CurrentScreen->BlockLocate.m_Command != BLOCK_MOVE ) - break; - HandleBlockEndByPopUp(BLOCK_DELETE, &dc); - g_ItemToRepeat = NULL; - break; - - - case wxID_PASTE: - HandleBlockBegin(&dc, BLOCK_PASTE,m_CurrentScreen->m_Curseur); - break; - - case ID_GET_ANNOTATE: - InstallAnnotateFrame(this, defaultpos); - break; - - case ID_GET_ERC: - InstallErcFrame(this, defaultpos); - break; - - case ID_GET_NETLIST: - InstallNetlistFrame(this, defaultpos); - break; - - case ID_GET_TOOLS: - InstallToolsFrame(this, defaultpos ); - break; - - case ID_FIND_ITEMS: - InstallFindFrame(this, pos); - break; - - case ID_HIERARCHY_PUSH_POP_BUTT: - SetToolID( id, wxCURSOR_HAND, _("Push/Pop Hierarchy") ); - break; - - case ID_NOCONN_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _("Add NoConnect Flag")); - break; - - case ID_WIRE_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _("Add Wire")); - break; - - case ID_BUS_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _("Add Bus")); - break; - - case ID_LINE_COMMENT_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _("Add Drawing")); - break; - - case ID_JUNCTION_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _("Add Junction")); - break; - - case ID_LABEL_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _("Add Label")); - break; - - case ID_GLABEL_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _("Add Global label")); - break; - - case ID_TEXT_COMMENT_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _("Add Text")); - break; - - case ID_WIRETOBUS_ENTRY_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _("Add Wire to Bus Entry")); - break; - - case ID_BUSTOBUS_ENTRY_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _("Add Bus to Bus entry")); - break; - - case ID_SHEET_SYMBOL_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _("Add Sheet")); - break; - - case ID_SHEET_LABEL_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _("Add PinSheet")); - break; - - case ID_IMPORT_GLABEL_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _("Import PinSheet")); - break; - - case ID_COMPONENT_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _("Add Component")); - break; - - case ID_PLACE_POWER_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _("Add Power")); - break; - - case ID_POPUP_SCH_ENTRY_SELECT_SLASH: - DrawPanel->MouseToCursorSchema(); - SetBusEntryShape(&dc, - (DrawBusEntryStruct*)m_CurrentScreen->m_CurrentItem, '/'); - break; - - case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH: - DrawPanel->MouseToCursorSchema(); - SetBusEntryShape(&dc, - (DrawBusEntryStruct*)m_CurrentScreen->m_CurrentItem, '\\'); - break; - - case ID_NO_SELECT_BUTT: - SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); - break; - - case ID_POPUP_CANCEL_CURRENT_COMMAND: - if (m_ID_current_state == 0) - SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); - break; - - case ID_POPUP_END_LINE: - DrawPanel->MouseToCursorSchema(); - EndSegment(&dc); - break; - - case ID_POPUP_SCH_EDIT_TEXT: - EditSchematicText( - (DrawTextStruct*)m_CurrentScreen->m_CurrentItem, &dc); - break; - - case ID_POPUP_SCH_ROTATE_TEXT: - DrawPanel->MouseToCursorSchema(); - ChangeTextOrient( - (DrawTextStruct*)m_CurrentScreen->m_CurrentItem, &dc); - break; - - case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL: - DrawPanel->MouseToCursorSchema(); - ConvertTextType( (DrawTextStruct*)m_CurrentScreen->m_CurrentItem, - &dc, DRAW_LABEL_STRUCT_TYPE); - break; - - case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL: - DrawPanel->MouseToCursorSchema(); - ConvertTextType( (DrawTextStruct*)m_CurrentScreen->m_CurrentItem, - &dc, DRAW_GLOBAL_LABEL_STRUCT_TYPE); - break; - - case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT: - DrawPanel->MouseToCursorSchema(); - ConvertTextType( (DrawTextStruct*)m_CurrentScreen->m_CurrentItem, - &dc, DRAW_TEXT_STRUCT_TYPE); - break; - - case ID_POPUP_SCH_SET_SHAPE_TEXT: - // Non utilis� - break; - - case ID_POPUP_SCH_ROTATE_FIELD: - DrawPanel->MouseToCursorSchema(); - RotateCmpField( (PartTextStruct *)m_CurrentScreen->m_CurrentItem, &dc); - break; - - case ID_POPUP_SCH_EDIT_FIELD: - EditCmpFieldText( (PartTextStruct *)m_CurrentScreen->m_CurrentItem, &dc); - break; - - case ID_POPUP_SCH_DELETE_NODE: - case ID_POPUP_SCH_DELETE_CONNECTION: - DrawPanel->MouseToCursorSchema(); - DeleteConnection(&dc, id == ID_POPUP_SCH_DELETE_CONNECTION ? TRUE : FALSE); - m_CurrentScreen->m_CurrentItem = NULL; - g_ItemToRepeat = NULL; - TestDanglingEnds(m_CurrentScreen->EEDrawList, &dc); - break; - - case ID_POPUP_SCH_BREAK_WIRE: - { - DrawPickedStruct * ListForUndo; - DrawPanel->MouseToCursorSchema(); - ListForUndo = BreakSegment((SCH_SCREEN*)m_CurrentScreen, - m_CurrentScreen->m_Curseur, TRUE); - if ( ListForUndo ) SaveCopyInUndoList(ListForUndo, IS_NEW|IS_CHANGED); - TestDanglingEnds(m_CurrentScreen->EEDrawList, &dc); - } - break; - - case ID_POPUP_SCH_DELETE_CMP: - if ( m_CurrentScreen->m_CurrentItem == NULL) break; - // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); - case ID_POPUP_SCH_DELETE: - if ( m_CurrentScreen->m_CurrentItem == NULL) break; - DeleteStruct(this->DrawPanel, &dc, m_CurrentScreen->m_CurrentItem); - m_CurrentScreen->m_CurrentItem = NULL; - g_ItemToRepeat = NULL; - TestDanglingEnds(m_CurrentScreen->EEDrawList, &dc); - m_CurrentScreen->SetModify(); - break; - - case ID_SCHEMATIC_DELETE_ITEM_BUTT: - SetToolID( id, wxCURSOR_BULLSEYE, _("Delete item")); - break; - - case ID_POPUP_SCH_END_SHEET: - DrawPanel->MouseToCursorSchema(); - m_CurrentScreen->m_CurrentItem->Place(this, &dc); - break; - - case ID_POPUP_SCH_RESIZE_SHEET: - DrawPanel->MouseToCursorSchema(); - ReSizeSheet((DrawSheetStruct *) - m_CurrentScreen->m_CurrentItem, &dc); - TestDanglingEnds(m_CurrentScreen->EEDrawList, &dc); - break; - - case ID_POPUP_SCH_EDIT_SHEET: - EditSheet((DrawSheetStruct *) - m_CurrentScreen->m_CurrentItem, &dc); - break; - case ID_POPUP_SCH_CLEANUP_SHEET: - ((DrawSheetStruct *) - m_CurrentScreen->m_CurrentItem)->CleanupSheet(this, &dc); - break; - - case ID_POPUP_SCH_EDIT_PINSHEET: - Edit_PinSheet((DrawSheetLabelStruct *) - m_CurrentScreen->m_CurrentItem, &dc); - break; - - case ID_POPUP_SCH_MOVE_PINSHEET: - DrawPanel->MouseToCursorSchema(); - StartMove_PinSheet((DrawSheetLabelStruct *) - m_CurrentScreen->m_CurrentItem, &dc); - break; - - case ID_POPUP_SCH_MOVE_CMP_REQUEST: - // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); - if ( m_CurrentScreen->m_CurrentItem == NULL ) break; - case ID_POPUP_SCH_MOVE_ITEM_REQUEST: - DrawPanel->MouseToCursorSchema(); - Process_Move_Item(m_CurrentScreen->m_CurrentItem, &dc); - break; - - case ID_POPUP_SCH_EDIT_CMP: - // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); - if ( m_CurrentScreen->m_CurrentItem == NULL ) break; - InstallCmpeditFrame(this, pos, - (EDA_SchComponentStruct *) m_CurrentScreen->m_CurrentItem); - break; - - case ID_POPUP_SCH_MIROR_X_CMP: - case ID_POPUP_SCH_MIROR_Y_CMP: - case ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE: - case ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE: - case ID_POPUP_SCH_ORIENT_NORMAL_CMP: - // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); - if ( m_CurrentScreen->m_CurrentItem == NULL ) break; - { - int option; - switch (id) - { - case ID_POPUP_SCH_MIROR_X_CMP: - option = CMP_MIROIR_X; break; - - case ID_POPUP_SCH_MIROR_Y_CMP: - option = CMP_MIROIR_Y; break; - - case ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE: - option = CMP_ROTATE_COUNTERCLOCKWISE; break; - - case ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE: - option = CMP_ROTATE_CLOCKWISE; break; - - default: - case ID_POPUP_SCH_ORIENT_NORMAL_CMP: - option = CMP_NORMAL; break; - } - DrawPanel->MouseToCursorSchema(); - if ( m_CurrentScreen->m_CurrentItem->m_Flags == 0 ) - SaveCopyInUndoList(m_CurrentScreen->m_CurrentItem, IS_CHANGED); - CmpRotationMiroir( - (EDA_SchComponentStruct *) m_CurrentScreen->m_CurrentItem, - &dc, option ); - break; - } - - case ID_POPUP_SCH_INIT_CMP: - DrawPanel->MouseToCursorSchema(); - break; - - case ID_POPUP_SCH_EDIT_VALUE_CMP: - // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); - if ( m_CurrentScreen->m_CurrentItem == NULL ) break; - EditComponentValue( - (EDA_SchComponentStruct *) m_CurrentScreen->m_CurrentItem, &dc); - break; - - case ID_POPUP_SCH_EDIT_REF_CMP: - // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); - if ( m_CurrentScreen->m_CurrentItem == NULL ) break; - EditComponentReference( - (EDA_SchComponentStruct *) m_CurrentScreen->m_CurrentItem, &dc); - break; - - case ID_POPUP_SCH_EDIT_CONVERT_CMP: - // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); - if ( m_CurrentScreen->m_CurrentItem == NULL ) break; - DrawPanel->MouseToCursorSchema(); - ConvertPart( - (EDA_SchComponentStruct *) m_CurrentScreen->m_CurrentItem, - &dc); - break; - - case ID_POPUP_SCH_COPY_COMPONENT_CMP: - DrawPanel->MouseToCursorSchema(); - { - EDA_SchComponentStruct * olditem, * newitem; - if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); - olditem = (EDA_SchComponentStruct *) m_CurrentScreen->m_CurrentItem; - if ( olditem == NULL ) break; - newitem = olditem->GenCopy(); - newitem->m_TimeStamp = GetTimeStamp(); - newitem->ClearAnnotation(); - newitem->m_Flags = IS_NEW; - StartMovePart(newitem, &dc); - /* Redraw the original part, because StartMovePart() has erase it from screen */ - RedrawOneStruct(DrawPanel, &dc, olditem, GR_DEFAULT_DRAWMODE); - } - break; - - case ID_POPUP_SCH_SELECT_UNIT1: - case ID_POPUP_SCH_SELECT_UNIT2: - case ID_POPUP_SCH_SELECT_UNIT3: - case ID_POPUP_SCH_SELECT_UNIT4: - case ID_POPUP_SCH_SELECT_UNIT5: - case ID_POPUP_SCH_SELECT_UNIT6: - case ID_POPUP_SCH_SELECT_UNIT7: - case ID_POPUP_SCH_SELECT_UNIT8: - case ID_POPUP_SCH_SELECT_UNIT9: - case ID_POPUP_SCH_SELECT_UNIT10: - case ID_POPUP_SCH_SELECT_UNIT11: - case ID_POPUP_SCH_SELECT_UNIT12: - case ID_POPUP_SCH_SELECT_UNIT13: - case ID_POPUP_SCH_SELECT_UNIT14: - case ID_POPUP_SCH_SELECT_UNIT15: - case ID_POPUP_SCH_SELECT_UNIT16: - case ID_POPUP_SCH_SELECT_UNIT17: - case ID_POPUP_SCH_SELECT_UNIT18: - case ID_POPUP_SCH_SELECT_UNIT19: - case ID_POPUP_SCH_SELECT_UNIT20: - case ID_POPUP_SCH_SELECT_UNIT21: - case ID_POPUP_SCH_SELECT_UNIT22: - case ID_POPUP_SCH_SELECT_UNIT23: - case ID_POPUP_SCH_SELECT_UNIT24: - case ID_POPUP_SCH_SELECT_UNIT25: - case ID_POPUP_SCH_SELECT_UNIT26: - // Ensure the struct is a component (could be a struct of a component, like Field, text..) - if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); - if ( m_CurrentScreen->m_CurrentItem == NULL ) break; - DrawPanel->MouseToCursorSchema(); - SelPartUnit( - (EDA_SchComponentStruct *) m_CurrentScreen->m_CurrentItem, - id + 1 - ID_POPUP_SCH_SELECT_UNIT1, - &dc); - break; - - case ID_POPUP_SCH_DISPLAYDOC_CMP: - // Ensure the struct is a component (could be a piece of a component, like Field, text..) - if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) - m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); - if ( m_CurrentScreen->m_CurrentItem == NULL ) break; - { - EDA_LibComponentStruct * LibEntry; - LibEntry = FindLibPart(((EDA_SchComponentStruct *) - m_CurrentScreen->m_CurrentItem)->m_ChipName, - wxEmptyString, FIND_ALIAS); - if ( LibEntry && LibEntry->m_DocFile != wxEmptyString ) - GetAssociatedDocument(this, g_RealLibDirBuffer, LibEntry->m_DocFile); - } - break; - - case ID_POPUP_SCH_ENTER_SHEET: - { - EDA_BaseStruct *DrawStruct = m_CurrentScreen->m_CurrentItem; - if ( DrawStruct && (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) ) - { - InstallNextScreen((DrawSheetStruct *) DrawStruct); - } - } - break; - - case ID_POPUP_SCH_LEAVE_SHEET: - InstallPreviousScreen(); - break; - - case ID_POPUP_CLOSE_CURRENT_TOOL: - SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); - break; - - case wxID_COPY: // really this is a Save block for paste - HandleBlockEndByPopUp(BLOCK_SAVE, &dc); - break; - - case ID_POPUP_PLACE_BLOCK: - DrawPanel->m_AutoPAN_Request = FALSE; - DrawPanel->MouseToCursorSchema(); - HandleBlockPlace(&dc); - break; - - case ID_POPUP_ZOOM_BLOCK: - HandleBlockEndByPopUp(BLOCK_ZOOM, &dc); - break; - - case ID_POPUP_DELETE_BLOCK: - DrawPanel->MouseToCursorSchema(); - HandleBlockEndByPopUp(BLOCK_DELETE, &dc); - break; - - case ID_POPUP_ROTATE_BLOCK: - DrawPanel->MouseToCursorSchema(); - HandleBlockEndByPopUp(BLOCK_ROTATE, &dc); - break; - - case ID_POPUP_MIRROR_X_BLOCK: - case ID_POPUP_MIRROR_Y_BLOCK: - DrawPanel->MouseToCursorSchema(); - HandleBlockEndByPopUp(BLOCK_MIRROR_Y, &dc); - break; - - case ID_POPUP_COPY_BLOCK: - DrawPanel->MouseToCursorSchema(); - HandleBlockEndByPopUp(BLOCK_COPY, &dc); - break; - - case ID_POPUP_DRAG_BLOCK: - DrawPanel->MouseToCursorSchema(); - HandleBlockEndByPopUp(BLOCK_DRAG, &dc); - break; - - case ID_POPUP_SCH_ADD_JUNCTION: - DrawPanel->MouseToCursorSchema(); - m_CurrentScreen->m_CurrentItem = - CreateNewJunctionStruct(&dc, m_CurrentScreen->m_Curseur, TRUE); - TestDanglingEnds(m_CurrentScreen->EEDrawList, &dc); - m_CurrentScreen->m_CurrentItem = NULL; - break; - - case ID_POPUP_SCH_ADD_LABEL: - case ID_POPUP_SCH_ADD_GLABEL: - m_CurrentScreen->m_CurrentItem = CreateNewText(&dc, - id == ID_POPUP_SCH_ADD_LABEL ? LAYER_LOCLABEL : LAYER_GLOBLABEL); - if ( m_CurrentScreen->m_CurrentItem ) - { - m_CurrentScreen->m_CurrentItem->Place( this, &dc); - TestDanglingEnds(m_CurrentScreen->EEDrawList, &dc); - m_CurrentScreen->m_CurrentItem = NULL; - } - break; - - case ID_SCHEMATIC_UNDO: - GetSchematicFromUndoList(); - DrawPanel->Refresh(TRUE); - break; - - case ID_SCHEMATIC_REDO: - GetSchematicFromRedoList(); - DrawPanel->Refresh(TRUE); - break; - - default: // Log error: - DisplayError(this, wxT("WinEDA_SchematicFrame::Process_Special_Functions error") ); - break; - } // End switch ( id ) (Command execution) - - if ( m_ID_current_state == 0 ) g_ItemToRepeat = NULL; - SetToolbars(); - - dc.SetBrush(wxNullBrush); - dc.SetPen(wxNullPen); + int id = event.GetId(); + wxPoint pos; + wxClientDC dc( DrawPanel ); + wxPoint defaultpos( -1, -1 ); + + DrawPanel->PrepareGraphicContext( &dc ); + + pos = wxGetMousePosition(); + + pos.y += 20; + + // If needed, stop the current command and deselect current tool + switch( id ) + { + case ID_POPUP_SCH_ENTRY_SELECT_SLASH: // Do nothing: + case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH: + case ID_POPUP_END_LINE: + case ID_POPUP_SCH_EDIT_TEXT: + case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL: + case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL: + case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT: + case ID_POPUP_SCH_SET_SHAPE_TEXT: + case ID_POPUP_SCH_ROTATE_TEXT: + case ID_POPUP_SCH_EDIT_SHEET: + case ID_POPUP_SCH_CLEANUP_SHEET: + case ID_POPUP_SCH_END_SHEET: + case ID_POPUP_SCH_RESIZE_SHEET: + case ID_POPUP_SCH_EDIT_PINSHEET: + case ID_POPUP_SCH_MOVE_PINSHEET: + case ID_POPUP_SCH_MOVE_ITEM_REQUEST: + case ID_POPUP_SCH_MOVE_CMP_REQUEST: + case ID_POPUP_SCH_EDIT_CMP: + case ID_POPUP_SCH_MIROR_X_CMP: + case ID_POPUP_SCH_MIROR_Y_CMP: + case ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE: + case ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE: + case ID_POPUP_SCH_ORIENT_NORMAL_CMP: + case ID_POPUP_SCH_INIT_CMP: + case ID_POPUP_SCH_DISPLAYDOC_CMP: + case ID_POPUP_SCH_EDIT_VALUE_CMP: + case ID_POPUP_SCH_EDIT_REF_CMP: + case ID_POPUP_SCH_EDIT_CONVERT_CMP: + case ID_POPUP_SCH_SELECT_UNIT_CMP: + case ID_POPUP_SCH_SELECT_UNIT1: + case ID_POPUP_SCH_SELECT_UNIT2: + case ID_POPUP_SCH_SELECT_UNIT3: + case ID_POPUP_SCH_SELECT_UNIT4: + case ID_POPUP_SCH_SELECT_UNIT5: + case ID_POPUP_SCH_SELECT_UNIT6: + case ID_POPUP_SCH_SELECT_UNIT7: + case ID_POPUP_SCH_SELECT_UNIT8: + case ID_POPUP_SCH_SELECT_UNIT9: + case ID_POPUP_SCH_SELECT_UNIT10: + case ID_POPUP_SCH_SELECT_UNIT11: + case ID_POPUP_SCH_SELECT_UNIT12: + case ID_POPUP_SCH_SELECT_UNIT13: + case ID_POPUP_SCH_SELECT_UNIT14: + case ID_POPUP_SCH_SELECT_UNIT15: + case ID_POPUP_SCH_SELECT_UNIT16: + case ID_POPUP_SCH_SELECT_UNIT17: + case ID_POPUP_SCH_SELECT_UNIT18: + case ID_POPUP_SCH_SELECT_UNIT19: + case ID_POPUP_SCH_SELECT_UNIT20: + case ID_POPUP_SCH_SELECT_UNIT21: + case ID_POPUP_SCH_SELECT_UNIT22: + case ID_POPUP_SCH_SELECT_UNIT23: + case ID_POPUP_SCH_SELECT_UNIT24: + case ID_POPUP_SCH_SELECT_UNIT25: + case ID_POPUP_SCH_SELECT_UNIT26: + case ID_POPUP_SCH_ROTATE_FIELD: + case ID_POPUP_SCH_EDIT_FIELD: + case ID_POPUP_DELETE_BLOCK: + case ID_POPUP_PLACE_BLOCK: + case ID_POPUP_ZOOM_BLOCK: + case ID_POPUP_DRAG_BLOCK: + case ID_POPUP_COPY_BLOCK: + case ID_POPUP_ROTATE_BLOCK: + case ID_POPUP_MIRROR_X_BLOCK: + case ID_POPUP_MIRROR_Y_BLOCK: + case ID_POPUP_SCH_DELETE_NODE: + case ID_POPUP_SCH_DELETE_CONNECTION: + case wxID_CUT: + case wxID_COPY: + case ID_POPUP_SCH_ENTER_SHEET: + case ID_POPUP_SCH_LEAVE_SHEET: + case ID_POPUP_SCH_ADD_JUNCTION: + case ID_POPUP_SCH_ADD_LABEL: + break; // Do nothing: + + case ID_POPUP_CANCEL_CURRENT_COMMAND: + if( m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE ) + DrawPanel->SetCursor( wxCursor( DrawPanel->m_PanelCursor = DrawPanel-> + m_PanelDefaultCursor ) ); + + if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); + } + /* ne devrait pas etre execute, sauf bug: */ + if( m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE ) + { + m_CurrentScreen->BlockLocate.m_Command = BLOCK_IDLE; + m_CurrentScreen->BlockLocate.m_State = STATE_NO_BLOCK; + m_CurrentScreen->BlockLocate.m_BlockDrawStruct = NULL; + } + break; + + case ID_POPUP_SCH_DELETE_CMP: + case ID_POPUP_SCH_DELETE: // Stop the, current command, keep the current tool + if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); + } + break; + + default: // Stop the current command, and deselect the current tool + if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); + } + DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor = wxCURSOR_ARROW; + SetToolID( 0, DrawPanel->m_PanelCursor, wxEmptyString ); + break; + } + + // End switch commande en cours + + switch( id ) // Command execution: + { + case ID_EXIT: + Close( TRUE ); + break; + + case ID_NEW_PROJECT: /* New EED Project */ + LoadOneEEProject( wxEmptyString, TRUE ); + break; + + case ID_LOAD_PROJECT: + LoadOneEEProject( wxEmptyString, FALSE ); + break; + + case ID_LOAD_ONE_SHEET: + LoadOneSheet( GetScreen(), wxEmptyString ); + break; + + case ID_LOAD_FILE_1: + case ID_LOAD_FILE_2: + case ID_LOAD_FILE_3: + case ID_LOAD_FILE_4: + case ID_LOAD_FILE_5: + case ID_LOAD_FILE_6: + case ID_LOAD_FILE_7: + case ID_LOAD_FILE_8: + case ID_LOAD_FILE_9: + case ID_LOAD_FILE_10: + LoadOneEEProject( GetLastProject( id - ID_LOAD_FILE_1 ).GetData(), FALSE ); + break; + + case ID_TO_LIBRARY: + if( m_Parent->LibeditFrame ) + { + m_Parent->LibeditFrame->Show( TRUE ); + } + else + { + m_Parent->LibeditFrame = new + WinEDA_LibeditFrame( m_Parent->SchematicFrame, + m_Parent, + wxT( "Library Editor" ), + wxPoint( -1, -1 ), wxSize( 600, 400 ) ); + ActiveScreen = ScreenLib; + m_Parent->LibeditFrame->AdjustScrollBars(); + } + break; + + case ID_TO_PCB: + { + wxString Line; + if( ScreenSch->m_FileName != wxEmptyString ) + { + Line = ScreenSch->m_FileName; + AddDelimiterString( Line ); + ChangeFileNameExt( Line, wxEmptyString ); + ExecuteFile( this, PCBNEW_EXE, Line ); + } + else + ExecuteFile( this, PCBNEW_EXE ); + break; + } + + case ID_TO_CVPCB: + { + wxString Line; + if( ScreenSch->m_FileName != wxEmptyString ) + { + Line = ScreenSch->m_FileName; + AddDelimiterString( Line ); + ChangeFileNameExt( Line, wxEmptyString ); + ExecuteFile( this, CVPCB_EXE, Line ); + } + else + ExecuteFile( this, CVPCB_EXE ); + break; + } + + case ID_TO_LIBVIEW: + if( m_Parent->ViewlibFrame ) + { + m_Parent->ViewlibFrame->Show( TRUE ); + } + else + { + m_Parent->ViewlibFrame = new + WinEDA_ViewlibFrame( m_Parent->SchematicFrame, m_Parent ); + m_Parent->ViewlibFrame->AdjustScrollBars(); + } + break; + + case ID_HIERARCHY: + InstallHierarchyFrame( &dc, pos ); + g_ItemToRepeat = NULL; + break; + + case wxID_CUT: + if( m_CurrentScreen->BlockLocate.m_Command != BLOCK_MOVE ) + break; + HandleBlockEndByPopUp( BLOCK_DELETE, &dc ); + g_ItemToRepeat = NULL; + break; + + + case wxID_PASTE: + HandleBlockBegin( &dc, BLOCK_PASTE, m_CurrentScreen->m_Curseur ); + break; + + case ID_GET_ANNOTATE: + InstallAnnotateFrame( this, defaultpos ); + break; + + case ID_GET_ERC: + InstallErcFrame( this, defaultpos ); + break; + + case ID_GET_NETLIST: + InstallNetlistFrame( this, defaultpos ); + break; + + case ID_GET_TOOLS: + InstallToolsFrame( this, defaultpos ); + break; + + case ID_FIND_ITEMS: + InstallFindFrame( this, pos ); + break; + + case ID_HIERARCHY_PUSH_POP_BUTT: + SetToolID( id, wxCURSOR_HAND, _( "Push/Pop Hierarchy" ) ); + break; + + case ID_NOCONN_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Add NoConnect Flag" ) ); + break; + + case ID_WIRE_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Add Wire" ) ); + break; + + case ID_BUS_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Add Bus" ) ); + break; + + case ID_LINE_COMMENT_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Add Drawing" ) ); + break; + + case ID_JUNCTION_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Add Junction" ) ); + break; + + case ID_LABEL_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Add Label" ) ); + break; + + case ID_GLABEL_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Add Global label" ) ); + break; + + case ID_TEXT_COMMENT_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Add Text" ) ); + break; + + case ID_WIRETOBUS_ENTRY_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Add Wire to Bus Entry" ) ); + break; + + case ID_BUSTOBUS_ENTRY_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Add Bus to Bus entry" ) ); + break; + + case ID_SHEET_SYMBOL_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Add Sheet" ) ); + break; + + case ID_SHEET_LABEL_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Add PinSheet" ) ); + break; + + case ID_IMPORT_GLABEL_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Import PinSheet" ) ); + break; + + case ID_COMPONENT_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Add Component" ) ); + break; + + case ID_PLACE_POWER_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Add Power" ) ); + break; + + case ID_POPUP_SCH_ENTRY_SELECT_SLASH: + DrawPanel->MouseToCursorSchema(); + SetBusEntryShape( &dc, + (DrawBusEntryStruct*) m_CurrentScreen->GetCurItem(), '/' ); + break; + + case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH: + DrawPanel->MouseToCursorSchema(); + SetBusEntryShape( &dc, + (DrawBusEntryStruct*) m_CurrentScreen->GetCurItem(), '\\' ); + break; + + case ID_NO_SELECT_BUTT: + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); + break; + + case ID_POPUP_CANCEL_CURRENT_COMMAND: + if( m_ID_current_state == 0 ) + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); + break; + + case ID_POPUP_END_LINE: + DrawPanel->MouseToCursorSchema(); + EndSegment( &dc ); + break; + + case ID_POPUP_SCH_EDIT_TEXT: + EditSchematicText( + (DrawTextStruct*) m_CurrentScreen->GetCurItem(), &dc ); + break; + + case ID_POPUP_SCH_ROTATE_TEXT: + DrawPanel->MouseToCursorSchema(); + ChangeTextOrient( + (DrawTextStruct*) m_CurrentScreen->GetCurItem(), &dc ); + break; + + case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL: + DrawPanel->MouseToCursorSchema(); + ConvertTextType( (DrawTextStruct*) m_CurrentScreen->GetCurItem(), + &dc, DRAW_LABEL_STRUCT_TYPE ); + break; + + case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL: + DrawPanel->MouseToCursorSchema(); + ConvertTextType( (DrawTextStruct*) m_CurrentScreen->GetCurItem(), + &dc, DRAW_GLOBAL_LABEL_STRUCT_TYPE ); + break; + + case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT: + DrawPanel->MouseToCursorSchema(); + ConvertTextType( (DrawTextStruct*) m_CurrentScreen->GetCurItem(), + &dc, DRAW_TEXT_STRUCT_TYPE ); + break; + + case ID_POPUP_SCH_SET_SHAPE_TEXT: + + // Non utilis� + break; + + case ID_POPUP_SCH_ROTATE_FIELD: + DrawPanel->MouseToCursorSchema(); + RotateCmpField( (PartTextStruct*) m_CurrentScreen->GetCurItem(), &dc ); + break; + + case ID_POPUP_SCH_EDIT_FIELD: + EditCmpFieldText( (PartTextStruct*) m_CurrentScreen->GetCurItem(), &dc ); + break; + + case ID_POPUP_SCH_DELETE_NODE: + case ID_POPUP_SCH_DELETE_CONNECTION: + DrawPanel->MouseToCursorSchema(); + DeleteConnection( &dc, id == ID_POPUP_SCH_DELETE_CONNECTION ? TRUE : FALSE ); + m_CurrentScreen->SetCurItem( NULL ); + g_ItemToRepeat = NULL; + TestDanglingEnds( m_CurrentScreen->EEDrawList, &dc ); + break; + + case ID_POPUP_SCH_BREAK_WIRE: + { + DrawPickedStruct* ListForUndo; + DrawPanel->MouseToCursorSchema(); + ListForUndo = BreakSegment( (SCH_SCREEN*) m_CurrentScreen, + m_CurrentScreen->m_Curseur, TRUE ); + if( ListForUndo ) + SaveCopyInUndoList( ListForUndo, IS_NEW | IS_CHANGED ); + TestDanglingEnds( m_CurrentScreen->EEDrawList, &dc ); + } + break; + + case ID_POPUP_SCH_DELETE_CMP: + if( m_CurrentScreen->GetCurItem() == NULL ) + break; + + // Ensure the struct is a component (could be a struct of a component, like Field, text..) + if( m_CurrentScreen->GetCurItem()->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); + + case ID_POPUP_SCH_DELETE: + if( m_CurrentScreen->GetCurItem() == NULL ) + break; + DeleteStruct( this->DrawPanel, &dc, m_CurrentScreen->GetCurItem() ); + m_CurrentScreen->SetCurItem( NULL ); + g_ItemToRepeat = NULL; + TestDanglingEnds( m_CurrentScreen->EEDrawList, &dc ); + m_CurrentScreen->SetModify(); + break; + + case ID_SCHEMATIC_DELETE_ITEM_BUTT: + SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) ); + break; + + case ID_POPUP_SCH_END_SHEET: + DrawPanel->MouseToCursorSchema(); + m_CurrentScreen->GetCurItem()->Place( this, &dc ); + break; + + case ID_POPUP_SCH_RESIZE_SHEET: + DrawPanel->MouseToCursorSchema(); + ReSizeSheet( (DrawSheetStruct*) + m_CurrentScreen->GetCurItem(), &dc ); + TestDanglingEnds( m_CurrentScreen->EEDrawList, &dc ); + break; + + case ID_POPUP_SCH_EDIT_SHEET: + EditSheet( (DrawSheetStruct*) + m_CurrentScreen->GetCurItem(), &dc ); + break; + + case ID_POPUP_SCH_CLEANUP_SHEET: + ( (DrawSheetStruct*) + m_CurrentScreen->GetCurItem() )->CleanupSheet( this, &dc ); + break; + + case ID_POPUP_SCH_EDIT_PINSHEET: + Edit_PinSheet( (DrawSheetLabelStruct*) + m_CurrentScreen->GetCurItem(), &dc ); + break; + + case ID_POPUP_SCH_MOVE_PINSHEET: + DrawPanel->MouseToCursorSchema(); + StartMove_PinSheet( (DrawSheetLabelStruct*) + m_CurrentScreen->GetCurItem(), &dc ); + break; + + case ID_POPUP_SCH_MOVE_CMP_REQUEST: + + // Ensure the struct is a component (could be a struct of a component, like Field, text..) + if( m_CurrentScreen->GetCurItem()->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); + if( m_CurrentScreen->GetCurItem() == NULL ) + break; + + case ID_POPUP_SCH_MOVE_ITEM_REQUEST: + DrawPanel->MouseToCursorSchema(); + Process_Move_Item( m_CurrentScreen->GetCurItem(), &dc ); + break; + + case ID_POPUP_SCH_EDIT_CMP: + + // Ensure the struct is a component (could be a struct of a component, like Field, text..) + if( m_CurrentScreen->GetCurItem()->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); + if( m_CurrentScreen->GetCurItem() == NULL ) + break; + InstallCmpeditFrame( this, pos, + (EDA_SchComponentStruct*) m_CurrentScreen->GetCurItem() ); + break; + + case ID_POPUP_SCH_MIROR_X_CMP: + case ID_POPUP_SCH_MIROR_Y_CMP: + case ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE: + case ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE: + case ID_POPUP_SCH_ORIENT_NORMAL_CMP: + + // Ensure the struct is a component (could be a struct of a component, like Field, text..) + if( m_CurrentScreen->GetCurItem()->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); + if( m_CurrentScreen->GetCurItem() == NULL ) + break; + { + int option; + + switch( id ) + { + case ID_POPUP_SCH_MIROR_X_CMP: + option = CMP_MIROIR_X; break; + + case ID_POPUP_SCH_MIROR_Y_CMP: + option = CMP_MIROIR_Y; break; + + case ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE: + option = CMP_ROTATE_COUNTERCLOCKWISE; break; + + case ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE: + option = CMP_ROTATE_CLOCKWISE; break; + + default: + case ID_POPUP_SCH_ORIENT_NORMAL_CMP: + option = CMP_NORMAL; break; + } + + DrawPanel->MouseToCursorSchema(); + if( m_CurrentScreen->GetCurItem()->m_Flags == 0 ) + SaveCopyInUndoList( m_CurrentScreen->GetCurItem(), IS_CHANGED ); + CmpRotationMiroir( + (EDA_SchComponentStruct*) m_CurrentScreen->GetCurItem(), + &dc, option ); + break; + } + + case ID_POPUP_SCH_INIT_CMP: + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_SCH_EDIT_VALUE_CMP: + + // Ensure the struct is a component (could be a struct of a component, like Field, text..) + if( m_CurrentScreen->GetCurItem()->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); + if( m_CurrentScreen->GetCurItem() == NULL ) + break; + EditComponentValue( + (EDA_SchComponentStruct*) m_CurrentScreen->GetCurItem(), &dc ); + break; + + case ID_POPUP_SCH_EDIT_REF_CMP: + + // Ensure the struct is a component (could be a struct of a component, like Field, text..) + if( m_CurrentScreen->GetCurItem()->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); + if( m_CurrentScreen->GetCurItem() == NULL ) + break; + EditComponentReference( + (EDA_SchComponentStruct*) m_CurrentScreen->GetCurItem(), &dc ); + break; + + case ID_POPUP_SCH_EDIT_CONVERT_CMP: + + // Ensure the struct is a component (could be a struct of a component, like Field, text..) + if( m_CurrentScreen->GetCurItem()->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); + if( m_CurrentScreen->GetCurItem() == NULL ) + break; + DrawPanel->MouseToCursorSchema(); + ConvertPart( + (EDA_SchComponentStruct*) m_CurrentScreen->GetCurItem(), + &dc ); + break; + + case ID_POPUP_SCH_COPY_COMPONENT_CMP: + DrawPanel->MouseToCursorSchema(); + { + EDA_SchComponentStruct* olditem, * newitem; + if( m_CurrentScreen->GetCurItem()->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); + olditem = (EDA_SchComponentStruct*) m_CurrentScreen->GetCurItem(); + if( olditem == NULL ) + break; + newitem = olditem->GenCopy(); + newitem->m_TimeStamp = GetTimeStamp(); + newitem->ClearAnnotation(); + newitem->m_Flags = IS_NEW; + StartMovePart( newitem, &dc ); + /* Redraw the original part, because StartMovePart() has erase it from screen */ + RedrawOneStruct( DrawPanel, &dc, olditem, GR_DEFAULT_DRAWMODE ); + } + break; + + case ID_POPUP_SCH_SELECT_UNIT1: + case ID_POPUP_SCH_SELECT_UNIT2: + case ID_POPUP_SCH_SELECT_UNIT3: + case ID_POPUP_SCH_SELECT_UNIT4: + case ID_POPUP_SCH_SELECT_UNIT5: + case ID_POPUP_SCH_SELECT_UNIT6: + case ID_POPUP_SCH_SELECT_UNIT7: + case ID_POPUP_SCH_SELECT_UNIT8: + case ID_POPUP_SCH_SELECT_UNIT9: + case ID_POPUP_SCH_SELECT_UNIT10: + case ID_POPUP_SCH_SELECT_UNIT11: + case ID_POPUP_SCH_SELECT_UNIT12: + case ID_POPUP_SCH_SELECT_UNIT13: + case ID_POPUP_SCH_SELECT_UNIT14: + case ID_POPUP_SCH_SELECT_UNIT15: + case ID_POPUP_SCH_SELECT_UNIT16: + case ID_POPUP_SCH_SELECT_UNIT17: + case ID_POPUP_SCH_SELECT_UNIT18: + case ID_POPUP_SCH_SELECT_UNIT19: + case ID_POPUP_SCH_SELECT_UNIT20: + case ID_POPUP_SCH_SELECT_UNIT21: + case ID_POPUP_SCH_SELECT_UNIT22: + case ID_POPUP_SCH_SELECT_UNIT23: + case ID_POPUP_SCH_SELECT_UNIT24: + case ID_POPUP_SCH_SELECT_UNIT25: + case ID_POPUP_SCH_SELECT_UNIT26: + + // Ensure the struct is a component (could be a struct of a component, like Field, text..) + if( m_CurrentScreen->GetCurItem()->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); + if( m_CurrentScreen->GetCurItem() == NULL ) + break; + DrawPanel->MouseToCursorSchema(); + SelPartUnit( + (EDA_SchComponentStruct*) m_CurrentScreen->GetCurItem(), + id + 1 - ID_POPUP_SCH_SELECT_UNIT1, + &dc ); + break; + + case ID_POPUP_SCH_DISPLAYDOC_CMP: + + // Ensure the struct is a component (could be a piece of a component, like Field, text..) + if( m_CurrentScreen->GetCurItem()->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->SetCurItem( LocateSmallestComponent( GetScreen() ) ); + if( m_CurrentScreen->GetCurItem() == NULL ) + break; + { + EDA_LibComponentStruct* LibEntry; + LibEntry = FindLibPart( ( (EDA_SchComponentStruct*) + m_CurrentScreen->GetCurItem() )->m_ChipName, + wxEmptyString, FIND_ALIAS ); + if( LibEntry && LibEntry->m_DocFile != wxEmptyString ) + GetAssociatedDocument( this, g_RealLibDirBuffer, LibEntry->m_DocFile ); + } + break; + + case ID_POPUP_SCH_ENTER_SHEET: + { + EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem(); + if( DrawStruct && (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) ) + { + InstallNextScreen( (DrawSheetStruct*) DrawStruct ); + } + } + break; + + case ID_POPUP_SCH_LEAVE_SHEET: + InstallPreviousScreen(); + break; + + case ID_POPUP_CLOSE_CURRENT_TOOL: + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); + break; + + case wxID_COPY: // really this is a Save block for paste + HandleBlockEndByPopUp( BLOCK_SAVE, &dc ); + break; + + case ID_POPUP_PLACE_BLOCK: + DrawPanel->m_AutoPAN_Request = FALSE; + DrawPanel->MouseToCursorSchema(); + HandleBlockPlace( &dc ); + break; + + case ID_POPUP_ZOOM_BLOCK: + HandleBlockEndByPopUp( BLOCK_ZOOM, &dc ); + break; + + case ID_POPUP_DELETE_BLOCK: + DrawPanel->MouseToCursorSchema(); + HandleBlockEndByPopUp( BLOCK_DELETE, &dc ); + break; + + case ID_POPUP_ROTATE_BLOCK: + DrawPanel->MouseToCursorSchema(); + HandleBlockEndByPopUp( BLOCK_ROTATE, &dc ); + break; + + case ID_POPUP_MIRROR_X_BLOCK: + case ID_POPUP_MIRROR_Y_BLOCK: + DrawPanel->MouseToCursorSchema(); + HandleBlockEndByPopUp( BLOCK_MIRROR_Y, &dc ); + break; + + case ID_POPUP_COPY_BLOCK: + DrawPanel->MouseToCursorSchema(); + HandleBlockEndByPopUp( BLOCK_COPY, &dc ); + break; + + case ID_POPUP_DRAG_BLOCK: + DrawPanel->MouseToCursorSchema(); + HandleBlockEndByPopUp( BLOCK_DRAG, &dc ); + break; + + case ID_POPUP_SCH_ADD_JUNCTION: + DrawPanel->MouseToCursorSchema(); + m_CurrentScreen->SetCurItem( + CreateNewJunctionStruct( &dc, m_CurrentScreen->m_Curseur, TRUE ) ); + TestDanglingEnds( m_CurrentScreen->EEDrawList, &dc ); + m_CurrentScreen->SetCurItem( NULL ); + break; + + case ID_POPUP_SCH_ADD_LABEL: + case ID_POPUP_SCH_ADD_GLABEL: + m_CurrentScreen->SetCurItem( CreateNewText( &dc, + id == ID_POPUP_SCH_ADD_LABEL ? + LAYER_LOCLABEL : LAYER_GLOBLABEL ) ); + if( m_CurrentScreen->GetCurItem() ) + { + m_CurrentScreen->GetCurItem()->Place( this, &dc ); + TestDanglingEnds( m_CurrentScreen->EEDrawList, &dc ); + m_CurrentScreen->SetCurItem( NULL ); + } + break; + + case ID_SCHEMATIC_UNDO: + GetSchematicFromUndoList(); + DrawPanel->Refresh( TRUE ); + break; + + case ID_SCHEMATIC_REDO: + GetSchematicFromRedoList(); + DrawPanel->Refresh( TRUE ); + break; + + default: // Log error: + DisplayError( this, wxT( "WinEDA_SchematicFrame::Process_Special_Functions error" ) ); + break; + } + + // End switch ( id ) (Command execution) + + if( m_ID_current_state == 0 ) + g_ItemToRepeat = NULL; + SetToolbars(); + + dc.SetBrush( wxNullBrush ); + dc.SetPen( wxNullPen ); } /********************************************************************************/ -void WinEDA_SchematicFrame::Process_Move_Item(EDA_BaseStruct *DrawStruct, - wxDC * DC) +void WinEDA_SchematicFrame::Process_Move_Item( EDA_BaseStruct* DrawStruct, + wxDC* DC ) /********************************************************************************/ { + if( DrawStruct == NULL ) + return; - if ( DrawStruct == NULL ) return; + DrawPanel->MouseToCursorSchema(); - DrawPanel->MouseToCursorSchema(); - switch ( DrawStruct->m_StructType ) - { - case DRAW_JUNCTION_STRUCT_TYPE: - break; + switch( DrawStruct->m_StructType ) + { + case DRAW_JUNCTION_STRUCT_TYPE: + break; - case DRAW_BUSENTRY_STRUCT_TYPE: - StartMoveBusEntry((DrawBusEntryStruct *) DrawStruct, DC); - break; + case DRAW_BUSENTRY_STRUCT_TYPE: + StartMoveBusEntry( (DrawBusEntryStruct*) DrawStruct, DC ); + break; - case DRAW_LABEL_STRUCT_TYPE: - case DRAW_GLOBAL_LABEL_STRUCT_TYPE: - case DRAW_TEXT_STRUCT_TYPE: - StartMoveTexte( (DrawTextStruct *) DrawStruct, DC); - break; + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + StartMoveTexte( (DrawTextStruct*) DrawStruct, DC ); + break; - case DRAW_LIB_ITEM_STRUCT_TYPE: - StartMovePart( (EDA_SchComponentStruct *) DrawStruct, DC); - break; + case DRAW_LIB_ITEM_STRUCT_TYPE: + StartMovePart( (EDA_SchComponentStruct*) DrawStruct, DC ); + break; - case DRAW_SEGMENT_STRUCT_TYPE: - break; + case DRAW_SEGMENT_STRUCT_TYPE: + break; - case DRAW_SHEET_STRUCT_TYPE: - StartMoveSheet( (DrawSheetStruct*) DrawStruct, DC); - break; + case DRAW_SHEET_STRUCT_TYPE: + StartMoveSheet( (DrawSheetStruct*) DrawStruct, DC ); + break; - case DRAW_NOCONNECT_STRUCT_TYPE: - break; + case DRAW_NOCONNECT_STRUCT_TYPE: + break; - case DRAW_PART_TEXT_STRUCT_TYPE: - StartMoveCmpField( (PartTextStruct *) DrawStruct, DC); - break; + case DRAW_PART_TEXT_STRUCT_TYPE: + StartMoveCmpField( (PartTextStruct*) DrawStruct, DC ); + break; - case DRAW_MARKER_STRUCT_TYPE: - case DRAW_SHEETLABEL_STRUCT_TYPE: - default: - wxString msg; - msg.Printf( - wxT("WinEDA_SchematicFrame::Move_Item Error: Bad DrawType %d"), - DrawStruct->m_StructType); - DisplayError(this, msg ); - break; - } + case DRAW_MARKER_STRUCT_TYPE: + case DRAW_SHEETLABEL_STRUCT_TYPE: + default: + wxString msg; + msg.Printf( + wxT( "WinEDA_SchematicFrame::Move_Item Error: Bad DrawType %d" ), + DrawStruct->m_StructType ); + DisplayError( this, msg ); + break; + } } - - diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 6c7f79ba0a..14dc8c2d99 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -1,17 +1,18 @@ ///////////////////////////////////////////////////////////////////////////// + // Name: sheet.cpp -// Purpose: +// Purpose: // Author: jean-pierre Charras -// Modified by: +// Modified by: // Created: 08/02/2006 18:37:02 -// RCS-ID: +// RCS-ID: // Copyright: License GNU -// Licence: +// Licence: ///////////////////////////////////////////////////////////////////////////// // Generated by DialogBlocks (unregistered), 08/02/2006 18:37:02 -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#if defined (__GNUG__) && !defined (NO_GCC_PRAGMA) #pragma implementation "sheet.h" #endif @@ -39,12 +40,12 @@ #include "protos.h" /* Routines Locales */ -static void ExitSheet(WinEDA_DrawPanel * Panel, wxDC * DC); -static void DeplaceSheet(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void ExitSheet( WinEDA_DrawPanel* Panel, wxDC* DC ); +static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); /* Variables locales */ -static int s_SheetMindx, s_SheetMindy; -static wxPoint s_OldPos; /* Ancienne pos pour annulation ReSize ou move */ +static int s_SheetMindx, s_SheetMindy; +static wxPoint s_OldPos; /* Ancienne pos pour annulation ReSize ou move */ #include "sheet.h" @@ -65,9 +66,9 @@ IMPLEMENT_DYNAMIC_CLASS( WinEDA_SheetPropertiesFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_SheetPropertiesFrame, wxDialog ) ////@begin WinEDA_SheetPropertiesFrame event table entries - EVT_BUTTON( wxID_CANCEL, WinEDA_SheetPropertiesFrame::OnCancelClick ) +EVT_BUTTON( wxID_CANCEL, WinEDA_SheetPropertiesFrame::OnCancelClick ) - EVT_BUTTON( wxID_OK, WinEDA_SheetPropertiesFrame::OnOkClick ) +EVT_BUTTON( wxID_OK, WinEDA_SheetPropertiesFrame::OnOkClick ) ////@end WinEDA_SheetPropertiesFrame event table entries @@ -77,123 +78,158 @@ END_EVENT_TABLE() * WinEDA_SheetPropertiesFrame constructors */ -WinEDA_SheetPropertiesFrame::WinEDA_SheetPropertiesFrame( ) +WinEDA_SheetPropertiesFrame::WinEDA_SheetPropertiesFrame() { } + WinEDA_SheetPropertiesFrame::WinEDA_SheetPropertiesFrame( WinEDA_SchematicFrame* parent, - DrawSheetStruct * currentsheet, - wxWindowID id, const wxString& caption, - const wxPoint & pos, const wxSize& size, long style ) + DrawSheetStruct* currentsheet, + wxWindowID id, + const wxString& caption, + const wxPoint& pos, + const wxSize& size, + long style ) { - m_Parent = parent; - m_CurrentSheet = currentsheet; - Create(parent, id, caption, pos, size, style); + m_Parent = parent; + m_CurrentSheet = currentsheet; + Create( parent, id, caption, pos, size, style ); - AddUnitSymbol(*m_SheetNameTextSize); - PutValueInLocalUnits(*m_SheetNameSize,m_CurrentSheet->m_SheetNameSize, - m_Parent->m_InternalUnits); + AddUnitSymbol( *m_SheetNameTextSize ); + PutValueInLocalUnits( *m_SheetNameSize, m_CurrentSheet->m_SheetNameSize, + m_Parent->m_InternalUnits ); - AddUnitSymbol(*m_FileNameTextSize); - PutValueInLocalUnits(*m_FileNameSize, m_CurrentSheet->m_FileNameSize, - m_Parent->m_InternalUnits); + AddUnitSymbol( *m_FileNameTextSize ); + PutValueInLocalUnits( *m_FileNameSize, m_CurrentSheet->m_FileNameSize, + m_Parent->m_InternalUnits ); } + /*! * WinEDA_SheetPropertiesFrame creator */ -bool WinEDA_SheetPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint & pos, const wxSize& size, long style ) +bool WinEDA_SheetPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, + const wxPoint& pos, const wxSize& size, long style ) { ////@begin WinEDA_SheetPropertiesFrame member initialisation - m_FileNameWin = NULL; - m_SheetNameWin = NULL; - m_FileNameTextSize = NULL; - m_FileNameSize = NULL; + m_FileNameWin = NULL; + m_SheetNameWin = NULL; + m_FileNameTextSize = NULL; + m_FileNameSize = NULL; m_SheetNameTextSize = NULL; - m_SheetNameSize = NULL; + m_SheetNameSize = NULL; + ////@end WinEDA_SheetPropertiesFrame member initialisation ////@begin WinEDA_SheetPropertiesFrame creation - SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + SetExtraStyle( GetExtraStyle() | wxWS_EX_BLOCK_EVENTS ); wxDialog::Create( parent, id, caption, pos, size, style ); CreateControls(); - GetSizer()->Fit(this); - GetSizer()->SetSizeHints(this); + GetSizer()->Fit( this ); + GetSizer()->SetSizeHints( this ); Centre(); + ////@end WinEDA_SheetPropertiesFrame creation return true; } + /*! * Control creation for WinEDA_SheetPropertiesFrame */ void WinEDA_SheetPropertiesFrame::CreateControls() -{ - SetFont(*g_DialogFont); +{ + SetFont( *g_DialogFont ); ////@begin WinEDA_SheetPropertiesFrame content construction // Generated by DialogBlocks, 27/02/2006 14:12:10 (unregistered) WinEDA_SheetPropertiesFrame* itemDialog1 = this; - wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); - itemDialog1->SetSizer(itemBoxSizer2); + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxVERTICAL ); + itemDialog1->SetSizer( itemBoxSizer2 ); - wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); - itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5); + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer( wxHORIZONTAL ); + itemBoxSizer2->Add( itemBoxSizer3, 0, wxGROW | wxALL, 5 ); - wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxBoxSizer* itemBoxSizer4 = new wxBoxSizer( wxVERTICAL ); + itemBoxSizer3->Add( itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("Filename:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer4->Add(itemStaticText5, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _( + "Filename:" ), wxDefaultPosition, + wxDefaultSize, 0 ); + itemBoxSizer4->Add( itemStaticText5, + 0, + wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, + 5 ); - m_FileNameWin = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxSize(300, -1), wxTE_PROCESS_ENTER ); - itemBoxSizer4->Add(m_FileNameWin, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); + m_FileNameWin = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T( "" ), wxDefaultPosition, + wxSize( 300, -1 ), wxTE_PROCESS_ENTER ); + itemBoxSizer4->Add( m_FileNameWin, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); - wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _("Sheetname:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer4->Add(itemStaticText7, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _( + "Sheetname:" ), wxDefaultPosition, + wxDefaultSize, 0 ); + itemBoxSizer4->Add( itemStaticText7, + 0, + wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, + 5 ); - m_SheetNameWin = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(300, -1), 0 ); - itemBoxSizer4->Add(m_SheetNameWin, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); + m_SheetNameWin = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( "" ), wxDefaultPosition, + wxSize( 300, -1 ), 0 ); + itemBoxSizer4->Add( m_SheetNameWin, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); - wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer3->Add(itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxBoxSizer* itemBoxSizer9 = new wxBoxSizer( wxVERTICAL ); + itemBoxSizer3->Add( itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - m_FileNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _("Size"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer9->Add(m_FileNameTextSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + m_FileNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _( + "Size" ), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer9->Add( m_FileNameTextSize, + 0, + wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, + 5 ); - m_FileNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer9->Add(m_FileNameSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); + m_FileNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T( + "" ), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer9->Add( m_FileNameSize, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); - m_SheetNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _("Size"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer9->Add(m_SheetNameTextSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + m_SheetNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _( + "Size" ), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer9->Add( m_SheetNameTextSize, + 0, + wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, + 5 ); - m_SheetNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer9->Add(m_SheetNameSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); + m_SheetNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T( + "" ), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer9->Add( m_SheetNameSize, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); - itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + itemBoxSizer2->Add( 5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); - wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxHORIZONTAL); - itemBoxSizer2->Add(itemBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + wxBoxSizer* itemBoxSizer15 = new wxBoxSizer( wxHORIZONTAL ); + itemBoxSizer2->Add( itemBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); - wxButton* itemButton16 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton16->SetForegroundColour(wxColour(0, 0, 255)); - itemBoxSizer15->Add(itemButton16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxButton* itemButton16 = new wxButton( itemDialog1, wxID_CANCEL, _( + "&Cancel" ), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton16->SetForegroundColour( wxColour( 0, 0, 255 ) ); + itemBoxSizer15->Add( itemButton16, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - wxButton* itemButton17 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton17->SetForegroundColour(wxColour(196, 0, 0)); - itemBoxSizer15->Add(itemButton17, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxButton* itemButton17 = new wxButton( itemDialog1, wxID_OK, _( + "&OK" ), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton17->SetForegroundColour( wxColour( 196, 0, 0 ) ); + itemBoxSizer15->Add( itemButton17, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); // Set validators - m_FileNameWin->SetValidator( wxTextValidator(wxFILTER_NONE, & m_CurrentSheet->m_FileName) ); - m_SheetNameWin->SetValidator( wxTextValidator(wxFILTER_NONE, & m_CurrentSheet->m_SheetName) ); + m_FileNameWin->SetValidator( wxTextValidator( wxFILTER_NONE, &m_CurrentSheet->m_FileName ) ); + m_SheetNameWin->SetValidator( wxTextValidator( wxFILTER_NONE, &m_CurrentSheet->m_SheetName ) ); + ////@end WinEDA_SheetPropertiesFrame content construction } + /*! * Should we show tooltips? */ @@ -203,6 +239,7 @@ bool WinEDA_SheetPropertiesFrame::ShowToolTips() return true; } + /*! * Get bitmap resources */ @@ -211,11 +248,13 @@ wxBitmap WinEDA_SheetPropertiesFrame::GetBitmapResource( const wxString& name ) { // Bitmap retrieval ////@begin WinEDA_SheetPropertiesFrame bitmap retrieval - wxUnusedVar(name); + wxUnusedVar( name ); return wxNullBitmap; + ////@end WinEDA_SheetPropertiesFrame bitmap retrieval } + /*! * Get icon resources */ @@ -224,340 +263,351 @@ wxIcon WinEDA_SheetPropertiesFrame::GetIconResource( const wxString& name ) { // Icon retrieval ////@begin WinEDA_SheetPropertiesFrame icon retrieval - wxUnusedVar(name); + wxUnusedVar( name ); return wxNullIcon; + ////@end WinEDA_SheetPropertiesFrame icon retrieval } - /*****************************************************************************/ -void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept(wxCommandEvent& event) +void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event ) /*****************************************************************************/ { -wxString FileName, msg; - - FileName = m_FileNameWin->GetValue(); - FileName.Trim(FALSE); FileName.Trim(TRUE); - - if ( FileName.IsEmpty() ) - { - DisplayError(this, _("No Filename! Aborted") ); - EndModal (FALSE); - return; - } + wxString FileName, msg; - ChangeFileNameExt( FileName,g_SchExtBuffer ); - - if ( m_CurrentSheet->m_FileName != FileName ) - { - m_CurrentSheet->m_FileName = FileName; - - if ( wxFileExists(FileName) ) /* do we reload the data from the existing file */ - { - msg.Printf( _("A file named %s exists, load it ?"), FileName.GetData()); - if( IsOK (this,msg) ) - { - m_Parent->LoadOneSheet(m_CurrentSheet, FileName); - } - } - } + FileName = m_FileNameWin->GetValue(); + FileName.Trim( FALSE ); FileName.Trim( TRUE ); - msg = m_FileNameSize->GetValue(); - m_CurrentSheet->m_FileNameSize = - ReturnValueFromString(g_UnitMetric, - msg, m_Parent->m_InternalUnits); + if( FileName.IsEmpty() ) + { + DisplayError( this, _( "No Filename! Aborted" ) ); + EndModal( FALSE ); + return; + } - m_CurrentSheet->m_SheetName = m_SheetNameWin->GetValue(); - msg = m_SheetNameSize->GetValue(); - m_CurrentSheet->m_SheetNameSize = - ReturnValueFromString(g_UnitMetric, - msg, m_Parent->m_InternalUnits); + ChangeFileNameExt( FileName, g_SchExtBuffer ); - if( (m_CurrentSheet->m_SheetName.IsEmpty() ) ) - m_CurrentSheet->m_SheetName = m_CurrentSheet->m_FileName; + if( m_CurrentSheet->m_FileName != FileName ) + { + m_CurrentSheet->m_FileName = FileName; + + if( wxFileExists( FileName ) ) /* do we reload the data from the existing file */ + { + msg.Printf( _( "A file named %s exists, load it ?" ), FileName.GetData() ); + if( IsOK( this, msg ) ) + { + m_Parent->LoadOneSheet( m_CurrentSheet, FileName ); + } + } + } + + msg = m_FileNameSize->GetValue(); + m_CurrentSheet->m_FileNameSize = + ReturnValueFromString( g_UnitMetric, + msg, m_Parent->m_InternalUnits ); + + m_CurrentSheet->m_SheetName = m_SheetNameWin->GetValue(); + msg = m_SheetNameSize->GetValue(); + m_CurrentSheet->m_SheetNameSize = + ReturnValueFromString( g_UnitMetric, + msg, m_Parent->m_InternalUnits ); + + if( ( m_CurrentSheet->m_SheetName.IsEmpty() ) ) + m_CurrentSheet->m_SheetName = m_CurrentSheet->m_FileName; - EndModal(TRUE); + EndModal( TRUE ); } + /*************************************************************************/ -bool WinEDA_SchematicFrame::EditSheet(DrawSheetStruct * Sheet, wxDC * DC) +bool WinEDA_SchematicFrame::EditSheet( DrawSheetStruct* Sheet, wxDC* DC ) /*************************************************************************/ /* Routine to edit the SheetName and the FileName for the sheet "Sheet" */ { -WinEDA_SheetPropertiesFrame * frame; -bool edit = TRUE; + WinEDA_SheetPropertiesFrame* frame; + bool edit = TRUE; - if ( Sheet == NULL ) return FALSE; + if( Sheet == NULL ) + return FALSE; - /* Get the new texts */ - RedrawOneStruct(DrawPanel, DC, Sheet, g_XorMode); + /* Get the new texts */ + RedrawOneStruct( DrawPanel, DC, Sheet, g_XorMode ); DrawPanel->m_IgnoreMouseEvents = TRUE; - frame = new WinEDA_SheetPropertiesFrame(this, Sheet); - edit = frame->ShowModal(); frame->Destroy(); + frame = new WinEDA_SheetPropertiesFrame( this, Sheet ); + edit = frame->ShowModal(); frame->Destroy(); DrawPanel->MouseToCursorSchema(); DrawPanel->m_IgnoreMouseEvents = FALSE; - - RedrawOneStruct(DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE); - return edit; + + RedrawOneStruct( DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE ); + return edit; } #define SHEET_MIN_WIDTH 500 #define SHEET_MIN_HEIGHT 150 /****************************************************************/ -DrawSheetStruct * WinEDA_SchematicFrame::CreateSheet(wxDC * DC) +DrawSheetStruct* WinEDA_SchematicFrame::CreateSheet( wxDC* DC ) /****************************************************************/ /* Routine de Creation d'une feuille de hierarchie (Sheet) */ { - g_ItemToRepeat = NULL; + g_ItemToRepeat = NULL; - DrawSheetStruct * Sheet = new DrawSheetStruct(m_CurrentScreen->m_Curseur); + DrawSheetStruct* Sheet = new DrawSheetStruct( m_CurrentScreen->m_Curseur ); - Sheet->m_Flags = IS_NEW | IS_RESIZED; - Sheet->m_TimeStamp = GetTimeStamp(); - Sheet->m_Parent = m_CurrentScreen; - s_SheetMindx = SHEET_MIN_WIDTH; - s_SheetMindy = SHEET_MIN_HEIGHT; + Sheet->m_Flags = IS_NEW | IS_RESIZED; + Sheet->m_TimeStamp = GetTimeStamp(); + Sheet->m_Parent = m_CurrentScreen; + s_SheetMindx = SHEET_MIN_WIDTH; + s_SheetMindy = SHEET_MIN_HEIGHT; - m_CurrentScreen->m_CurrentItem = Sheet; + m_CurrentScreen->SetCurItem( Sheet ); - DrawPanel->ManageCurseur = DeplaceSheet; - DrawPanel->ForceCloseManageCurseur = ExitSheet; + DrawPanel->ManageCurseur = DeplaceSheet; + DrawPanel->ForceCloseManageCurseur = ExitSheet; - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); - return Sheet; + return Sheet; } /*******************************************************************************/ -void WinEDA_SchematicFrame::ReSizeSheet(DrawSheetStruct * Sheet, wxDC * DC) +void WinEDA_SchematicFrame::ReSizeSheet( DrawSheetStruct* Sheet, wxDC* DC ) /*******************************************************************************/ { -DrawSheetLabelStruct* sheetlabel; + DrawSheetLabelStruct* sheetlabel; - if ( Sheet == NULL ) return; - if( Sheet->m_Flags & IS_NEW) return; + if( Sheet == NULL ) + return; + if( Sheet->m_Flags & IS_NEW ) + return; - if( Sheet->m_StructType != DRAW_SHEET_STRUCT_TYPE) - { - DisplayError(this, wxT("WinEDA_SchematicFrame::ReSizeSheet: Bad SructType")); - return; - } + if( Sheet->m_StructType != DRAW_SHEET_STRUCT_TYPE ) + { + DisplayError( this, wxT( "WinEDA_SchematicFrame::ReSizeSheet: Bad SructType" ) ); + return; + } - GetScreen()->SetModify(); - Sheet->m_Flags |= IS_RESIZED; + GetScreen()->SetModify(); + Sheet->m_Flags |= IS_RESIZED; - /* sauvegarde des anciennes valeurs */ - s_OldPos.x = Sheet->m_Size.x; - s_OldPos.y = Sheet->m_Size.y; + /* sauvegarde des anciennes valeurs */ + s_OldPos.x = Sheet->m_Size.x; + s_OldPos.y = Sheet->m_Size.y; - /* Recalcul des dims min de la sheet */ - s_SheetMindx = SHEET_MIN_WIDTH; - s_SheetMindy = SHEET_MIN_HEIGHT; - sheetlabel = Sheet->m_Label; - while(sheetlabel) - { - s_SheetMindx = MAX(s_SheetMindx, - (int)((sheetlabel->GetLength()+1) * sheetlabel->m_Size.x) ); - s_SheetMindy = MAX(s_SheetMindy,sheetlabel->m_Pos.y - Sheet->m_Pos.y); - sheetlabel = (DrawSheetLabelStruct *) sheetlabel->Pnext; - } - DrawPanel->ManageCurseur = DeplaceSheet ; - DrawPanel->ForceCloseManageCurseur = ExitSheet; - DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); + /* Recalcul des dims min de la sheet */ + s_SheetMindx = SHEET_MIN_WIDTH; + s_SheetMindy = SHEET_MIN_HEIGHT; + sheetlabel = Sheet->m_Label; + while( sheetlabel ) + { + s_SheetMindx = MAX( s_SheetMindx, + (int) ( (sheetlabel->GetLength() + 1) * sheetlabel->m_Size.x ) ); + s_SheetMindy = MAX( s_SheetMindy, sheetlabel->m_Pos.y - Sheet->m_Pos.y ); + sheetlabel = (DrawSheetLabelStruct*) sheetlabel->Pnext; + } + + DrawPanel->ManageCurseur = DeplaceSheet; + DrawPanel->ForceCloseManageCurseur = ExitSheet; + DrawPanel->ManageCurseur( DrawPanel, DC, TRUE ); } /*********************************************************************************/ -void WinEDA_SchematicFrame::StartMoveSheet(DrawSheetStruct* Sheet, wxDC * DC) +void WinEDA_SchematicFrame::StartMoveSheet( DrawSheetStruct* Sheet, wxDC* DC ) /*********************************************************************************/ { - if ( (Sheet == NULL) || ( Sheet->m_StructType != DRAW_SHEET_STRUCT_TYPE) ) - return; + if( (Sheet == NULL) || ( Sheet->m_StructType != DRAW_SHEET_STRUCT_TYPE) ) + return; - DrawPanel->CursorOff(DC); - m_CurrentScreen->m_Curseur = Sheet->m_Pos; - DrawPanel->MouseToCursorSchema(); - - s_OldPos = Sheet->m_Pos; - Sheet->m_Flags |= IS_MOVED; - DrawPanel->ManageCurseur = DeplaceSheet ; - DrawPanel->ForceCloseManageCurseur = ExitSheet; - DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); - - DrawPanel->CursorOn(DC); + DrawPanel->CursorOff( DC ); + m_CurrentScreen->m_Curseur = Sheet->m_Pos; + DrawPanel->MouseToCursorSchema(); + + s_OldPos = Sheet->m_Pos; + Sheet->m_Flags |= IS_MOVED; + DrawPanel->ManageCurseur = DeplaceSheet; + DrawPanel->ForceCloseManageCurseur = ExitSheet; + DrawPanel->ManageCurseur( DrawPanel, DC, TRUE ); + + DrawPanel->CursorOn( DC ); } + /********************************************************/ /*** Routine de deplacement Sheet, lie au curseur. */ /* Appele par GeneralControle grace a ManageCurseur. */ /********************************************************/ -static void DeplaceSheet(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) { -wxPoint move_vector; -DrawSheetLabelStruct * SheetLabel; -BASE_SCREEN * screen = panel->m_Parent->m_CurrentScreen; + wxPoint move_vector; + DrawSheetLabelStruct* SheetLabel; + BASE_SCREEN* screen = panel->m_Parent->m_CurrentScreen; -DrawSheetStruct * Sheet = (DrawSheetStruct *) - screen->m_CurrentItem; + DrawSheetStruct* Sheet = (DrawSheetStruct*) + screen->GetCurItem(); - /* Effacement du composant: tj apres depl curseur */ - if( erase ) - RedrawOneStruct(panel, DC, Sheet, g_XorMode); + /* Effacement du composant: tj apres depl curseur */ + if( erase ) + RedrawOneStruct( panel, DC, Sheet, g_XorMode ); - if( Sheet->m_Flags & IS_RESIZED) - { - Sheet->m_Size.x = MAX(s_SheetMindx, - screen->m_Curseur.x - Sheet->m_Pos.x); - Sheet->m_Size.y = MAX(s_SheetMindy, - screen->m_Curseur.y - Sheet->m_Pos.y); - SheetLabel = Sheet->m_Label; - while(SheetLabel) - { - if( SheetLabel->m_Edge) - SheetLabel->m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x; - SheetLabel = (DrawSheetLabelStruct *) SheetLabel->Pnext; - } - } - else /* Move Sheet */ - { - move_vector.x = screen->m_Curseur.x - Sheet->m_Pos.x; - move_vector.y = screen->m_Curseur.y - Sheet->m_Pos.y; - MoveOneStruct(Sheet, move_vector); - } + if( Sheet->m_Flags & IS_RESIZED ) + { + Sheet->m_Size.x = MAX( s_SheetMindx, + screen->m_Curseur.x - Sheet->m_Pos.x ); + Sheet->m_Size.y = MAX( s_SheetMindy, + screen->m_Curseur.y - Sheet->m_Pos.y ); + SheetLabel = Sheet->m_Label; + while( SheetLabel ) + { + if( SheetLabel->m_Edge ) + SheetLabel->m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x; + SheetLabel = (DrawSheetLabelStruct*) SheetLabel->Pnext; + } + } + else /* Move Sheet */ + { + move_vector.x = screen->m_Curseur.x - Sheet->m_Pos.x; + move_vector.y = screen->m_Curseur.y - Sheet->m_Pos.y; + MoveOneStruct( Sheet, move_vector ); + } - RedrawOneStruct(panel, DC, Sheet, g_XorMode); + RedrawOneStruct( panel, DC, Sheet, g_XorMode ); } /****************************************************************/ -void DrawSheetStruct::Place( WinEDA_DrawFrame * frame, wxDC * DC) +void DrawSheetStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) /****************************************************************/ { - /* Placement en liste des structures si nouveau composant:*/ - if(m_Flags & IS_NEW) - { - if ( ! ((WinEDA_SchematicFrame*)frame)->EditSheet(this, DC) ) - { - frame->m_CurrentScreen->m_CurrentItem = NULL; - frame->DrawPanel->ManageCurseur = NULL; - frame->DrawPanel->ForceCloseManageCurseur = NULL; - RedrawOneStruct(frame->DrawPanel, DC, this, g_XorMode); - delete this; - return; - } + /* Placement en liste des structures si nouveau composant:*/ + if( m_Flags & IS_NEW ) + { + if( !( (WinEDA_SchematicFrame*) frame )->EditSheet( this, DC ) ) + { + frame->m_CurrentScreen->SetCurItem( NULL ); + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; + RedrawOneStruct( frame->DrawPanel, DC, this, g_XorMode ); + delete this; + return; + } - if ( wxFileExists(m_FileName) ) - { - ((WinEDA_SchematicFrame*)frame)->LoadOneSheet( - this, m_FileName); - } - } + if( wxFileExists( m_FileName ) ) + { + ( (WinEDA_SchematicFrame*) frame )->LoadOneSheet( + this, m_FileName ); + } + } - EDA_BaseStruct::Place(frame, DC); + EDA_BaseStruct::Place( frame, DC ); } + /****************************************/ /* Routine de sortie du Menu de Sheet */ /****************************************/ -static void ExitSheet(WinEDA_DrawPanel * Panel, wxDC * DC) +static void ExitSheet( WinEDA_DrawPanel* Panel, wxDC* DC ) { -SCH_SCREEN *Screen = (SCH_SCREEN *) Panel->m_Parent->m_CurrentScreen; -DrawSheetStruct * Sheet = (DrawSheetStruct *) Screen->m_CurrentItem; - - if ( Sheet == NULL) return; + SCH_SCREEN* Screen = (SCH_SCREEN*) Panel->m_Parent->m_CurrentScreen; + DrawSheetStruct* Sheet = (DrawSheetStruct*) Screen->GetCurItem(); - /* Deplacement composant en cours */ - if ( Sheet->m_Flags & IS_NEW ) /* Nouveau Placement en cours, on l'efface */ - { - RedrawOneStruct(Panel, DC, Sheet, g_XorMode); - delete Sheet; - } - else if ( Sheet->m_Flags & IS_RESIZED )/* resize en cours: on l'annule */ - { - RedrawOneStruct(Panel, DC, Sheet, g_XorMode); - Sheet->m_Size.x = s_OldPos.x; - Sheet->m_Size.y = s_OldPos.y; - RedrawOneStruct(Panel, DC, Sheet, GR_DEFAULT_DRAWMODE); - Sheet->m_Flags = 0; - } + if( Sheet == NULL ) + return; - else if ( Sheet->m_Flags & IS_MOVED )/* move en cours: on l'annule */ - { - wxPoint curspos = Screen->m_Curseur; - Panel->m_Parent->m_CurrentScreen->m_Curseur = s_OldPos; - DeplaceSheet(Panel, DC, TRUE); - RedrawOneStruct(Panel, DC, Sheet, GR_DEFAULT_DRAWMODE); - Sheet->m_Flags = 0; - Screen->m_Curseur = curspos; - } + /* Deplacement composant en cours */ + if( Sheet->m_Flags & IS_NEW ) /* Nouveau Placement en cours, on l'efface */ + { + RedrawOneStruct( Panel, DC, Sheet, g_XorMode ); + delete Sheet; + } + else if( Sheet->m_Flags & IS_RESIZED )/* resize en cours: on l'annule */ + { + RedrawOneStruct( Panel, DC, Sheet, g_XorMode ); + Sheet->m_Size.x = s_OldPos.x; + Sheet->m_Size.y = s_OldPos.y; + RedrawOneStruct( Panel, DC, Sheet, GR_DEFAULT_DRAWMODE ); + Sheet->m_Flags = 0; + } + else if( Sheet->m_Flags & IS_MOVED )/* move en cours: on l'annule */ + { + wxPoint curspos = Screen->m_Curseur; + Panel->m_Parent->m_CurrentScreen->m_Curseur = s_OldPos; + DeplaceSheet( Panel, DC, TRUE ); + RedrawOneStruct( Panel, DC, Sheet, GR_DEFAULT_DRAWMODE ); + Sheet->m_Flags = 0; + Screen->m_Curseur = curspos; + } + else + Sheet->m_Flags = 0; - else Sheet->m_Flags = 0; - - Screen->m_CurrentItem = NULL; - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur =NULL; + Screen->SetCurItem( NULL ); + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; } +/********************************************************************/ +void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC ) +/********************************************************************/ -/********************************************************************/ -void DrawSheetStruct::CleanupSheet(WinEDA_SchematicFrame * frame, wxDC *DC) -/********************************************************************/ /* Delete pinsheets which are not corresponding to a Global label - if DC != NULL, redraw Sheet -*/ + * if DC != NULL, redraw Sheet + */ { -DrawSheetLabelStruct* Pinsheet, * NextPinsheet; - - if( ! IsOK(frame, _("Ok to cleanup this sheet") ) ) return; - - Pinsheet = m_Label; - while(Pinsheet) - { - /* Search Glabel corresponding to this Pinsheet */ + DrawSheetLabelStruct* Pinsheet, * NextPinsheet; - EDA_BaseStruct *DrawStruct = EEDrawList; - DrawGlobalLabelStruct * GLabel = NULL; - for (; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) - { - if( DrawStruct->m_StructType != DRAW_GLOBAL_LABEL_STRUCT_TYPE ) - continue; - GLabel = (DrawGlobalLabelStruct *) DrawStruct; - if( Pinsheet->m_Text.CmpNoCase(GLabel->m_Text) == 0 ) - break; // Found! - GLabel = NULL; - } + if( !IsOK( frame, _( "Ok to cleanup this sheet" ) ) ) + return; - NextPinsheet = (DrawSheetLabelStruct *) Pinsheet->Pnext; - if ( GLabel == NULL ) // Glabel not found: delete pinsheet - { - frame->GetScreen()->SetModify(); - frame->DeleteSheetLabel(DC, Pinsheet); - } - Pinsheet = NextPinsheet; - } + Pinsheet = m_Label; + while( Pinsheet ) + { + /* Search Glabel corresponding to this Pinsheet */ + + EDA_BaseStruct* DrawStruct = EEDrawList; + DrawGlobalLabelStruct* GLabel = NULL; + for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) + { + if( DrawStruct->m_StructType != DRAW_GLOBAL_LABEL_STRUCT_TYPE ) + continue; + GLabel = (DrawGlobalLabelStruct*) DrawStruct; + if( Pinsheet->m_Text.CmpNoCase( GLabel->m_Text ) == 0 ) + break; // Found! + GLabel = NULL; + } + + NextPinsheet = (DrawSheetLabelStruct*) Pinsheet->Pnext; + if( GLabel == NULL ) // Glabel not found: delete pinsheet + { + frame->GetScreen()->SetModify(); + frame->DeleteSheetLabel( DC, Pinsheet ); + } + Pinsheet = NextPinsheet; + } } + + /*! * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL */ void WinEDA_SheetPropertiesFrame::OnCancelClick( wxCommandEvent& event ) { - EndModal(0); + EndModal( 0 ); } + /*! * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK */ void WinEDA_SheetPropertiesFrame::OnOkClick( wxCommandEvent& event ) { - SheetPropertiesAccept(event); - EndModal(1); + SheetPropertiesAccept( event ); + EndModal( 1 ); } diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp index f943ad6c38..74a23060e7 100644 --- a/eeschema/sheetlab.cpp +++ b/eeschema/sheetlab.cpp @@ -1,6 +1,6 @@ - /****************************************************************/ - /* sheetlab.cpp module pour creation /editin des Sheet labels */ - /****************************************************************/ +/****************************************************************/ +/* sheetlab.cpp module pour creation /editin des Sheet labels */ +/****************************************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -13,433 +13,456 @@ #include "protos.h" /* Routines Locales */ -static void ExitPinSheet(WinEDA_DrawPanel * Panel, wxDC * DC ); -static void Move_PinSheet(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC ); +static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); /* Variables locales */ static int CurrentTypeLabel = NET_INPUT; -static wxSize NetSheetTextSize(DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT); +static wxSize NetSheetTextSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT ); - /****************************************/ - /* class WinEDA_PinSheetPropertiesFrame */ - /****************************************/ +/****************************************/ +/* class WinEDA_PinSheetPropertiesFrame */ +/****************************************/ #define NBSHAPES 5 static wxString shape_list[NBSHAPES] = { - wxT("Input"), wxT("Output"), wxT("Bidi"), wxT("TriState"), wxT("Passive") + wxT( "Input" ), wxT( "Output" ), wxT( "Bidi" ), wxT( "TriState" ), wxT( "Passive" ) }; -enum id_Textdit -{ - ID_ACCEPT_PINSHEET_PROPERTIES = 1970, - ID_CANCEL_PINSHEET_PROPERTIES +enum id_Textdit { + ID_ACCEPT_PINSHEET_PROPERTIES = 1970, + ID_CANCEL_PINSHEET_PROPERTIES }; /*****************************************************/ -class WinEDA_PinSheetPropertiesFrame: public wxDialog +class WinEDA_PinSheetPropertiesFrame : public wxDialog /*****************************************************/ { private: - WinEDA_SchematicFrame * m_Parent; - DrawSheetLabelStruct * m_CurrentPinSheet; - wxRadioBox * m_PinSheetType; - wxRadioBox * m_PinSheetShape; - WinEDA_GraphicTextCtrl * m_TextWin; + WinEDA_SchematicFrame* m_Parent; + DrawSheetLabelStruct* m_CurrentPinSheet; + wxRadioBox* m_PinSheetType; + wxRadioBox* m_PinSheetShape; + WinEDA_GraphicTextCtrl* m_TextWin; public: - // Constructor and destructor - WinEDA_PinSheetPropertiesFrame(WinEDA_SchematicFrame *parent, - DrawSheetLabelStruct * curr_pinsheet, - const wxPoint & framepos = wxPoint(-1,-1) ); - ~WinEDA_PinSheetPropertiesFrame(void){}; + + // Constructor and destructor + WinEDA_PinSheetPropertiesFrame( WinEDA_SchematicFrame* parent, + DrawSheetLabelStruct* curr_pinsheet, + const wxPoint& framepos = wxPoint( -1, -1 ) ); + ~WinEDA_PinSheetPropertiesFrame( void ) { }; private: - void PinSheetPropertiesAccept(wxCommandEvent& event); - void OnQuit(wxCommandEvent& event); + void PinSheetPropertiesAccept( wxCommandEvent& event ); + void OnQuit( wxCommandEvent& event ); - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() }; -BEGIN_EVENT_TABLE(WinEDA_PinSheetPropertiesFrame, wxDialog) - EVT_BUTTON(ID_ACCEPT_PINSHEET_PROPERTIES, WinEDA_PinSheetPropertiesFrame::PinSheetPropertiesAccept) - EVT_BUTTON(ID_CANCEL_PINSHEET_PROPERTIES, WinEDA_PinSheetPropertiesFrame::OnQuit) +BEGIN_EVENT_TABLE( WinEDA_PinSheetPropertiesFrame, wxDialog ) +EVT_BUTTON( ID_ACCEPT_PINSHEET_PROPERTIES, + WinEDA_PinSheetPropertiesFrame::PinSheetPropertiesAccept ) +EVT_BUTTON( ID_CANCEL_PINSHEET_PROPERTIES, WinEDA_PinSheetPropertiesFrame::OnQuit ) END_EVENT_TABLE() /**********************************************************************************/ WinEDA_PinSheetPropertiesFrame::WinEDA_PinSheetPropertiesFrame( - WinEDA_SchematicFrame *parent, - DrawSheetLabelStruct * curr_pinsheet, - const wxPoint & framepos): - wxDialog(parent, -1, _("PinSheet Properties:"), framepos, wxSize(340, 220), - DIALOG_STYLE) + WinEDA_SchematicFrame* parent, + DrawSheetLabelStruct* curr_pinsheet, + const wxPoint& framepos ) : + wxDialog( parent, -1, _( "PinSheet Properties:" ), framepos, wxSize( 340, 220 ), + DIALOG_STYLE ) /**********************************************************************************/ { -wxPoint pos; -wxString number; -wxButton * Button; + wxPoint pos; + wxString number; + wxButton* Button; - m_Parent = parent; - Centre(); + m_Parent = parent; + Centre(); - wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); - SetSizer(MainBoxSizer); - wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); - wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); - MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); - MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); + SetSizer( MainBoxSizer ); + wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL ); + MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 ); + MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - m_CurrentPinSheet = curr_pinsheet; + m_CurrentPinSheet = curr_pinsheet; - /* Creation des boutons de commande */ - Button = new wxButton(this, ID_ACCEPT_PINSHEET_PROPERTIES, - _("Ok")); - Button->SetForegroundColour(*wxRED); - RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + /* Creation des boutons de commande */ + Button = new wxButton( this, ID_ACCEPT_PINSHEET_PROPERTIES, + _( "Ok" ) ); + Button->SetForegroundColour( *wxRED ); + RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - Button = new wxButton(this, ID_CANCEL_PINSHEET_PROPERTIES, - _("Cancel")); - Button->SetForegroundColour(*wxBLUE); - RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + Button = new wxButton( this, ID_CANCEL_PINSHEET_PROPERTIES, + _( "Cancel" ) ); + Button->SetForegroundColour( *wxBLUE ); + RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - m_TextWin = new WinEDA_GraphicTextCtrl(this, _("Text:"), - m_CurrentPinSheet->m_Text, m_CurrentPinSheet->m_Size.x, - g_UnitMetric , LeftBoxSizer, 200); + m_TextWin = new WinEDA_GraphicTextCtrl( this, _( "Text:" ), + m_CurrentPinSheet->m_Text, m_CurrentPinSheet->m_Size.x, + g_UnitMetric, LeftBoxSizer, 200 ); - // Selection de la forme : - m_PinSheetShape = new wxRadioBox(this, -1, _("PinSheet Shape:"), - wxDefaultPosition, wxSize(-1,-1), - NBSHAPES, shape_list, 1); - m_PinSheetShape->SetSelection( m_CurrentPinSheet->m_Shape ); - LeftBoxSizer->Add(m_PinSheetShape, 0, wxGROW|wxALL, 5); + // Selection de la forme : + m_PinSheetShape = new wxRadioBox( this, -1, _( "PinSheet Shape:" ), + wxDefaultPosition, wxSize( -1, -1 ), + NBSHAPES, shape_list, 1 ); + m_PinSheetShape->SetSelection( m_CurrentPinSheet->m_Shape ); + LeftBoxSizer->Add( m_PinSheetShape, 0, wxGROW | wxALL, 5 ); - GetSizer()->Fit(this); - GetSizer()->SetSizeHints(this); + GetSizer()->Fit( this ); + GetSizer()->SetSizeHints( this ); } /************************************************************************/ -void WinEDA_PinSheetPropertiesFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +void WinEDA_PinSheetPropertiesFrame::OnQuit( wxCommandEvent& WXUNUSED (event) ) /************************************************************************/ { // true is to force the frame to close - Close(true); + Close( true ); } /***********************************************************************************/ -void WinEDA_PinSheetPropertiesFrame::PinSheetPropertiesAccept(wxCommandEvent& event) +void WinEDA_PinSheetPropertiesFrame::PinSheetPropertiesAccept( wxCommandEvent& event ) /***********************************************************************************/ { - m_CurrentPinSheet->m_Text = m_TextWin->GetText(); - m_CurrentPinSheet->m_Size.x = m_CurrentPinSheet->m_Size.y = m_TextWin->GetTextSize(); + m_CurrentPinSheet->m_Text = m_TextWin->GetText(); + m_CurrentPinSheet->m_Size.x = m_CurrentPinSheet->m_Size.y = m_TextWin->GetTextSize(); - m_CurrentPinSheet->m_Shape = m_PinSheetShape->GetSelection(); - Close(TRUE); + m_CurrentPinSheet->m_Shape = m_PinSheetShape->GetSelection(); + Close( TRUE ); } + /*****************************************************************/ -static void ExitPinSheet(WinEDA_DrawPanel * Panel, wxDC * DC) +static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC ) /*****************************************************************/ -/* Routine de sortie du Menu d'Edition Des NETS (Labels) SHEET -*/ + +/* Routine de sortie du Menu d'Edition Des NETS (Labels) SHEET + */ { -DrawSheetLabelStruct * SheetLabel = (DrawSheetLabelStruct *) - Panel->GetScreen()->m_CurrentItem; + DrawSheetLabelStruct* SheetLabel = (DrawSheetLabelStruct*) + Panel->GetScreen()->GetCurItem(); - if ( SheetLabel == NULL ) return; + if( SheetLabel == NULL ) + return; - if ( SheetLabel->m_Flags & IS_NEW ) - { /* Nouveau Placement en cours, on l'efface */ - RedrawOneStruct(Panel, DC, SheetLabel, g_XorMode); - delete SheetLabel; - } - else - { - RedrawOneStruct(Panel, DC, SheetLabel, GR_DEFAULT_DRAWMODE); - SheetLabel->m_Flags = 0; - } + if( SheetLabel->m_Flags & IS_NEW ) + { /* Nouveau Placement en cours, on l'efface */ + RedrawOneStruct( Panel, DC, SheetLabel, g_XorMode ); + delete SheetLabel; + } + else + { + RedrawOneStruct( Panel, DC, SheetLabel, GR_DEFAULT_DRAWMODE ); + SheetLabel->m_Flags = 0; + } - Panel->GetScreen()->m_CurrentItem = NULL; - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; + Panel->GetScreen()->SetCurItem( NULL ); + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; } + /* Cette routine place un nouveau NetSheet ou place un ancien en cours -de deplacement - Si le NetSheet est nouveau, il est pointe par NewSheetLabel -*/ -void DrawSheetLabelStruct::Place( WinEDA_DrawFrame * frame, wxDC * DC) + * de deplacement + * Si le NetSheet est nouveau, il est pointe par NewSheetLabel + */ +void DrawSheetLabelStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) { -DrawSheetStruct * Sheet = (DrawSheetStruct *) m_Parent; + DrawSheetStruct* Sheet = (DrawSheetStruct*) m_Parent; - if( m_Flags & IS_NEW ) /* ajout a la liste des structures */ - { - if(Sheet->m_Label == NULL ) Sheet->m_Label = this; - else - { - DrawSheetLabelStruct * pinsheet = Sheet->m_Label; - while(pinsheet) - { - if( pinsheet->Pnext == NULL ) - { - pinsheet->Pnext = this; - break; - } - pinsheet = (DrawSheetLabelStruct*)pinsheet->Pnext; - } - } - } + if( m_Flags & IS_NEW ) /* ajout a la liste des structures */ + { + if( Sheet->m_Label == NULL ) + Sheet->m_Label = this; + else + { + DrawSheetLabelStruct* pinsheet = Sheet->m_Label; + while( pinsheet ) + { + if( pinsheet->Pnext == NULL ) + { + pinsheet->Pnext = this; + break; + } + pinsheet = (DrawSheetLabelStruct*) pinsheet->Pnext; + } + } + } - m_Flags = 0; - m_Pos.x = Sheet->m_Pos.x; - m_Edge = 0; - if( frame->GetScreen()->m_Curseur.x > (Sheet->m_Pos.x + (Sheet->m_Size.x/2)) ) - { - m_Edge = 1; - m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x; - } + m_Flags = 0; + m_Pos.x = Sheet->m_Pos.x; + m_Edge = 0; + if( frame->GetScreen()->m_Curseur.x > ( Sheet->m_Pos.x + (Sheet->m_Size.x / 2) ) ) + { + m_Edge = 1; + m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x; + } - m_Pos.y = frame->GetScreen()->m_Curseur.y; - if( m_Pos.y < Sheet->m_Pos.y ) m_Pos.y = Sheet->m_Pos.y; - if( m_Pos.y > (Sheet->m_Pos.y+Sheet->m_Size.y) ) - m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y; + m_Pos.y = frame->GetScreen()->m_Curseur.y; + if( m_Pos.y < Sheet->m_Pos.y ) + m_Pos.y = Sheet->m_Pos.y; + if( m_Pos.y > (Sheet->m_Pos.y + Sheet->m_Size.y) ) + m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y; - RedrawOneStruct(frame->DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE); + RedrawOneStruct( frame->DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE ); - frame->DrawPanel->ManageCurseur = NULL; - frame->DrawPanel->ForceCloseManageCurseur = NULL; + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; } /*******************************************************************************/ -void WinEDA_SchematicFrame::StartMove_PinSheet(DrawSheetLabelStruct * SheetLabel, - wxDC * DC) +void WinEDA_SchematicFrame::StartMove_PinSheet( DrawSheetLabelStruct* SheetLabel, + wxDC* DC ) /*******************************************************************************/ /* Initialise un deplacement de NetSheet */ { - NetSheetTextSize = SheetLabel->m_Size; - CurrentTypeLabel = SheetLabel->m_Shape; - SheetLabel->m_Flags |= IS_MOVED; + NetSheetTextSize = SheetLabel->m_Size; + CurrentTypeLabel = SheetLabel->m_Shape; + SheetLabel->m_Flags |= IS_MOVED; - DrawPanel->ManageCurseur = Move_PinSheet; - DrawPanel->ForceCloseManageCurseur = ExitPinSheet; - DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); + DrawPanel->ManageCurseur = Move_PinSheet; + DrawPanel->ForceCloseManageCurseur = ExitPinSheet; + DrawPanel->ManageCurseur( DrawPanel, DC, TRUE ); } + /**********************************************************************/ /* Routine de deplacement du NetSheet actif selon la position souris */ /**********************************************************************/ -static void Move_PinSheet(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) { -DrawSheetLabelStruct * SheetLabel = (DrawSheetLabelStruct *) - panel->m_Parent->GetScreen()->m_CurrentItem; + DrawSheetLabelStruct* SheetLabel = (DrawSheetLabelStruct*) + panel->m_Parent->GetScreen()->GetCurItem(); - if ( SheetLabel == NULL ) return; + if( SheetLabel == NULL ) + return; -DrawSheetStruct * Sheet = (DrawSheetStruct *) SheetLabel->m_Parent; + DrawSheetStruct* Sheet = (DrawSheetStruct*) SheetLabel->m_Parent; - if ( Sheet == NULL ) return; - if( erase ) - RedrawOneStruct(panel, DC, SheetLabel, g_XorMode); + if( Sheet == NULL ) + return; + if( erase ) + RedrawOneStruct( panel, DC, SheetLabel, g_XorMode ); - SheetLabel->m_Edge = 0; - SheetLabel->m_Pos.x = Sheet->m_Pos.x; - if( panel->m_Parent->GetScreen()->m_Curseur.x > (Sheet->m_Pos.x + (Sheet->m_Size.x/2)) ) - { - SheetLabel->m_Edge = 1; - SheetLabel->m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x; - } + SheetLabel->m_Edge = 0; + SheetLabel->m_Pos.x = Sheet->m_Pos.x; + if( panel->m_Parent->GetScreen()->m_Curseur.x > ( Sheet->m_Pos.x + (Sheet->m_Size.x / 2) ) ) + { + SheetLabel->m_Edge = 1; + SheetLabel->m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x; + } - SheetLabel->m_Pos.y = panel->m_Parent->GetScreen()->m_Curseur.y; - if( SheetLabel->m_Pos.y < Sheet->m_Pos.y ) - SheetLabel->m_Pos.y = Sheet->m_Pos.y; - if( SheetLabel->m_Pos.y > (Sheet->m_Pos.y+Sheet->m_Size.y) ) - SheetLabel->m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y; + SheetLabel->m_Pos.y = panel->m_Parent->GetScreen()->m_Curseur.y; + if( SheetLabel->m_Pos.y < Sheet->m_Pos.y ) + SheetLabel->m_Pos.y = Sheet->m_Pos.y; + if( SheetLabel->m_Pos.y > (Sheet->m_Pos.y + Sheet->m_Size.y) ) + SheetLabel->m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y; - RedrawOneStruct(panel, DC, SheetLabel, g_XorMode); + RedrawOneStruct( panel, DC, SheetLabel, g_XorMode ); } /***************************************************************************/ -void WinEDA_SchematicFrame::Edit_PinSheet(DrawSheetLabelStruct * SheetLabel, - wxDC * DC) +void WinEDA_SchematicFrame::Edit_PinSheet( DrawSheetLabelStruct* SheetLabel, + wxDC* DC ) /***************************************************************************/ /* Modification du texte d'un net sheet */ { - if( SheetLabel == NULL) return; + if( SheetLabel == NULL ) + return; - RedrawOneStruct(DrawPanel, DC, SheetLabel, g_XorMode); + RedrawOneStruct( DrawPanel, DC, SheetLabel, g_XorMode ); -WinEDA_PinSheetPropertiesFrame * frame = - new WinEDA_PinSheetPropertiesFrame(this, SheetLabel); + WinEDA_PinSheetPropertiesFrame* frame = + new WinEDA_PinSheetPropertiesFrame( this, SheetLabel ); - frame->ShowModal(); frame->Destroy(); + frame->ShowModal(); frame->Destroy(); - RedrawOneStruct(DrawPanel, DC, SheetLabel, GR_DEFAULT_DRAWMODE); + RedrawOneStruct( DrawPanel, DC, SheetLabel, GR_DEFAULT_DRAWMODE ); } /***************************************************************/ -DrawSheetLabelStruct * WinEDA_SchematicFrame::Create_PinSheet( - DrawSheetStruct * Sheet, wxDC * DC) +DrawSheetLabelStruct* WinEDA_SchematicFrame::Create_PinSheet( + DrawSheetStruct* Sheet, wxDC* DC ) /**************************************************************/ + /* Addition d'un nouveau PinSheet sur la feuille selectionnee, a l'endroit - pointe par la souris -*/ + * pointe par la souris + */ { -wxString Line, Text; -DrawSheetLabelStruct * NewSheetLabel; + wxString Line, Text; + DrawSheetLabelStruct* NewSheetLabel; - switch(CurrentTypeLabel) - { - default: CurrentTypeLabel = NET_INPUT; - case NET_INPUT: Text = wxT("Pin Input: "); - break; + switch( CurrentTypeLabel ) + { + default: + CurrentTypeLabel = NET_INPUT; - case NET_OUTPUT: Text = wxT("Pin Output: "); - break; + case NET_INPUT: + Text = wxT( "Pin Input: " ); + break; - case NET_BIDI: Text = wxT("Pin BiDi: "); - break; + case NET_OUTPUT: + Text = wxT( "Pin Output: " ); + break; - case NET_TRISTATE: Text = wxT("Pin TriStat: "); - break; + case NET_BIDI: + Text = wxT( "Pin BiDi: " ); + break; - case NET_UNSPECIFIED: Text = wxT("Pin Unspec.: "); - break; + case NET_TRISTATE: + Text = wxT( "Pin TriStat: " ); + break; - } + case NET_UNSPECIFIED: + Text = wxT( "Pin Unspec.: " ); + break; + } - Get_Message(Text,Line, this); - if( Line.IsEmpty() ) return NULL; + Get_Message( Text, Line, this ); + if( Line.IsEmpty() ) + return NULL; - GetScreen()->SetModify(); + GetScreen()->SetModify(); - /* Creation en memoire */ - NewSheetLabel = new DrawSheetLabelStruct(Sheet, wxPoint(0,0), Line); - NewSheetLabel->m_Flags = IS_NEW; - NewSheetLabel->m_Size = NetSheetTextSize; - NewSheetLabel->m_Shape = CurrentTypeLabel; + /* Creation en memoire */ + NewSheetLabel = new DrawSheetLabelStruct( Sheet, wxPoint( 0, 0 ), Line ); + NewSheetLabel->m_Flags = IS_NEW; + NewSheetLabel->m_Size = NetSheetTextSize; + NewSheetLabel->m_Shape = CurrentTypeLabel; - GetScreen()->m_CurrentItem = NewSheetLabel; + GetScreen()->SetCurItem( NewSheetLabel ); - DrawPanel->ManageCurseur = Move_PinSheet; - DrawPanel->ForceCloseManageCurseur = ExitPinSheet; - DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); + DrawPanel->ManageCurseur = Move_PinSheet; + DrawPanel->ForceCloseManageCurseur = ExitPinSheet; + DrawPanel->ManageCurseur( DrawPanel, DC, TRUE ); - return NewSheetLabel; + return NewSheetLabel; } /*****************************************************************************/ -DrawSheetLabelStruct * - WinEDA_SchematicFrame::Import_PinSheet(DrawSheetStruct * Sheet, wxDC * DC) +DrawSheetLabelStruct* WinEDA_SchematicFrame::Import_PinSheet( DrawSheetStruct* Sheet, wxDC* DC ) /*****************************************************************************/ + /* Permet de creer automatiquement les Sheet Labels a partir des Labels Globaux -de la feuille de sous hierarchie correspondante -*/ + * de la feuille de sous hierarchie correspondante + */ { -EDA_BaseStruct *DrawStruct; -DrawSheetLabelStruct * NewSheetLabel, * SheetLabel = NULL; -DrawGlobalLabelStruct * GLabel = NULL; + EDA_BaseStruct* DrawStruct; + DrawSheetLabelStruct* NewSheetLabel, * SheetLabel = NULL; + DrawGlobalLabelStruct* GLabel = NULL; - DrawStruct = Sheet->EEDrawList; - GLabel = NULL; - for (; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) - { - if( DrawStruct->m_StructType != DRAW_GLOBAL_LABEL_STRUCT_TYPE ) - continue; - GLabel = (DrawGlobalLabelStruct *) DrawStruct; + DrawStruct = Sheet->EEDrawList; + GLabel = NULL; + for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) + { + if( DrawStruct->m_StructType != DRAW_GLOBAL_LABEL_STRUCT_TYPE ) + continue; + GLabel = (DrawGlobalLabelStruct*) DrawStruct; - /* Ici un G-Label a ete trouve: y a t-il un SheetLabel correspondant */ - SheetLabel = Sheet->m_Label; - for( ;SheetLabel != NULL; SheetLabel = (DrawSheetLabelStruct*) SheetLabel->Pnext ) - { - if( SheetLabel->m_Text.CmpNoCase(GLabel->m_Text) == 0 ) - { - break; - } - } - /* Ici si SheetLabel == NULL le G-Label n'a pas de SheetLabel corresp */ - if( SheetLabel == NULL ) break; - } + /* Ici un G-Label a ete trouve: y a t-il un SheetLabel correspondant */ + SheetLabel = Sheet->m_Label; + for( ; SheetLabel != NULL; SheetLabel = (DrawSheetLabelStruct*) SheetLabel->Pnext ) + { + if( SheetLabel->m_Text.CmpNoCase( GLabel->m_Text ) == 0 ) + { + break; + } + } - if( (GLabel == NULL ) || SheetLabel ) - { - DisplayError(this, _("No New Global Label found"), 10); - return NULL; - } + /* Ici si SheetLabel == NULL le G-Label n'a pas de SheetLabel corresp */ + if( SheetLabel == NULL ) + break; + } - /* Ici G-Label n'a pas de SheetLabel corresp, on va le creer */ + if( (GLabel == NULL ) || SheetLabel ) + { + DisplayError( this, _( "No New Global Label found" ), 10 ); + return NULL; + } - GetScreen()->SetModify(); - /* Creation en memoire */ - NewSheetLabel = new DrawSheetLabelStruct(Sheet, wxPoint(0,0), GLabel->m_Text); - NewSheetLabel->m_Flags = IS_NEW; - NewSheetLabel->m_Size = NetSheetTextSize; - CurrentTypeLabel = NewSheetLabel->m_Shape = GLabel->m_Shape; + /* Ici G-Label n'a pas de SheetLabel corresp, on va le creer */ - GetScreen()->m_CurrentItem = NewSheetLabel; - DrawPanel->ManageCurseur = Move_PinSheet; - DrawPanel->ForceCloseManageCurseur = ExitPinSheet; - Move_PinSheet(DrawPanel, DC, FALSE); + GetScreen()->SetModify(); + /* Creation en memoire */ + NewSheetLabel = new DrawSheetLabelStruct( Sheet, wxPoint( 0, 0 ), GLabel->m_Text ); + NewSheetLabel->m_Flags = IS_NEW; + NewSheetLabel->m_Size = NetSheetTextSize; + CurrentTypeLabel = NewSheetLabel->m_Shape = GLabel->m_Shape; - return NewSheetLabel; + GetScreen()->SetCurItem( NewSheetLabel ); + DrawPanel->ManageCurseur = Move_PinSheet; + DrawPanel->ForceCloseManageCurseur = ExitPinSheet; + Move_PinSheet( DrawPanel, DC, FALSE ); + + return NewSheetLabel; } /**************************************************************/ -void WinEDA_SchematicFrame::DeleteSheetLabel(wxDC * DC, - DrawSheetLabelStruct * SheetLabelToDel) +void WinEDA_SchematicFrame::DeleteSheetLabel( wxDC* DC, + DrawSheetLabelStruct* SheetLabelToDel ) /**************************************************************/ + /* - Routine de suppression de 1 Structure type (DrawSheetLabelStruct. -Cette Structure ne peut etre mise en pile "undelete" car il ne serait pas -possible de la ratacher a la 'DrawSheetStruct' d'origine -si DC != NULL, effacement a l'ecran du dessin -*/ + * Routine de suppression de 1 Structure type (DrawSheetLabelStruct. + * Cette Structure ne peut etre mise en pile "undelete" car il ne serait pas + * possible de la ratacher a la 'DrawSheetStruct' d'origine + * si DC != NULL, effacement a l'ecran du dessin + */ { -EDA_BaseStruct * DrawStruct; -DrawSheetLabelStruct* SheetLabel, *NextLabel; + EDA_BaseStruct* DrawStruct; + DrawSheetLabelStruct* SheetLabel, * NextLabel; - if ( DC ) RedrawOneStruct(DrawPanel, DC, SheetLabelToDel, g_XorMode); + if( DC ) + RedrawOneStruct( DrawPanel, DC, SheetLabelToDel, g_XorMode ); - /* Recherche de la DrawSheetStruct d'origine */ - DrawStruct = SheetLabelToDel->m_Parent; + /* Recherche de la DrawSheetStruct d'origine */ + DrawStruct = SheetLabelToDel->m_Parent; - if (DrawStruct) // Modification du chainage - { - if (DrawStruct->m_StructType != DRAW_SHEET_STRUCT_TYPE) - { - DisplayError(this, wxT("DeleteSheetLabel error: m_Parent != DRAW_SHEET_STRUCT_TYPE")); - return; - } + if( DrawStruct ) // Modification du chainage + { + if( DrawStruct->m_StructType != DRAW_SHEET_STRUCT_TYPE ) + { + DisplayError( this, + wxT( "DeleteSheetLabel error: m_Parent != DRAW_SHEET_STRUCT_TYPE" ) ); + return; + } - /* suppression chainage */ - SheetLabel = ((DrawSheetStruct *) DrawStruct)->m_Label; - if( SheetLabel == SheetLabelToDel ) - ((DrawSheetStruct *) DrawStruct)->m_Label = - (DrawSheetLabelStruct *)SheetLabel->Pnext; + /* suppression chainage */ + SheetLabel = ( (DrawSheetStruct*) DrawStruct )->m_Label; + if( SheetLabel == SheetLabelToDel ) + ( (DrawSheetStruct*) DrawStruct )->m_Label = + (DrawSheetLabelStruct*) SheetLabel->Pnext; - else while( SheetLabel )/* Examen de la liste dependante et suppression chainage */ - { - NextLabel = (DrawSheetLabelStruct *)SheetLabel->Pnext; - if( NextLabel == SheetLabelToDel ) - { - SheetLabel->Pnext = NextLabel->Pnext; - break;; - } - SheetLabel = NextLabel; - } - } + else + while( SheetLabel ) /* Examen de la liste dependante et suppression chainage */ + { + NextLabel = (DrawSheetLabelStruct*) SheetLabel->Pnext; + if( NextLabel == SheetLabelToDel ) + { + SheetLabel->Pnext = NextLabel->Pnext; + break;; + } + SheetLabel = NextLabel; + } - delete SheetLabelToDel; + } + + delete SheetLabelToDel; } - - - diff --git a/gerbview/block.cpp b/gerbview/block.cpp index edcb580e95..8ba5afa36c 100644 --- a/gerbview/block.cpp +++ b/gerbview/block.cpp @@ -1,6 +1,6 @@ - /*****************************************************************/ - /* Operations sur Blocks : deplacement, rotation, effacement ... */ - /*****************************************************************/ +/*****************************************************************/ +/* Operations sur Blocks : deplacement, rotation, effacement ... */ +/*****************************************************************/ #include "fctsys.h" @@ -17,414 +17,423 @@ /* Routines Locales */ -static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); -static TRACK * IsSegmentInBox(DrawBlockStruct & blocklocate, TRACK * PtSegm ); +static TRACK* IsSegmentInBox( DrawBlockStruct& blocklocate, TRACK* PtSegm ); /* Variables locales :*/ /*************************************************/ -int WinEDA_GerberFrame::ReturnBlockCommand(int key) +int WinEDA_GerberFrame::ReturnBlockCommand( int key ) /*************************************************/ + /* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to - the key (ALT, SHIFT ALT ..) -*/ + * the key (ALT, SHIFT ALT ..) + */ { -int cmd = 0; - - switch ( key ) - { - default: - cmd = key & 0x255; - break; + int cmd = 0; - case 0: - cmd = BLOCK_MOVE; - break; + switch( key ) + { + default: + cmd = key & 0x255; + break; - case GR_KB_SHIFT: - break; + case 0: + cmd = BLOCK_MOVE; + break; - case GR_KB_CTRL : - break; + case GR_KB_SHIFT: + break; - case GR_KB_SHIFTCTRL : - cmd = BLOCK_DELETE; - break; + case GR_KB_CTRL: + break; - case GR_KB_ALT : - cmd = BLOCK_COPY; - break; + case GR_KB_SHIFTCTRL: + cmd = BLOCK_DELETE; + break; - case MOUSE_MIDDLE: - cmd = BLOCK_ZOOM; - break; - } + case GR_KB_ALT: + cmd = BLOCK_COPY; + break; - return cmd ; + case MOUSE_MIDDLE: + cmd = BLOCK_ZOOM; + break; + } + + return cmd; } /*****************************************************/ -void WinEDA_GerberFrame::HandleBlockPlace(wxDC * DC) +void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC ) /*****************************************************/ /* Routine to handle the BLOCK PLACE commande */ { -bool err = FALSE; + bool err = FALSE; - if(DrawPanel->ManageCurseur == NULL) - { - err = TRUE; - DisplayError(this, wxT("Error in HandleBlockPLace : ManageCurseur = NULL") ); - } - GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + if( DrawPanel->ManageCurseur == NULL ) + { + err = TRUE; + DisplayError( this, wxT( "Error in HandleBlockPLace : ManageCurseur = NULL" ) ); + } + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; - switch(GetScreen()->BlockLocate.m_Command ) - { - case BLOCK_IDLE: - err = TRUE; - break; + switch( GetScreen()->BlockLocate.m_Command ) + { + case BLOCK_IDLE: + err = TRUE; + break; - case BLOCK_DRAG: /* Drag */ - case BLOCK_MOVE: /* Move */ - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ - if ( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur(DrawPanel,DC, FALSE); - Block_Move(DC); - GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; - break; + case BLOCK_DRAG: /* Drag */ + case BLOCK_MOVE: /* Move */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + Block_Move( DC ); + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + break; - case BLOCK_COPY: /* Copy */ - if ( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - Block_Duplicate(DC); - GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; - break; + case BLOCK_COPY: /* Copy */ + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + Block_Duplicate( DC ); + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + break; - case BLOCK_PASTE: - break; + case BLOCK_PASTE: + break; - case BLOCK_ZOOM: // Handle by HandleBlockEnd() - case BLOCK_ROTATE: - case BLOCK_INVERT: - case BLOCK_DELETE: - case BLOCK_SAVE: - case BLOCK_ABORT: - case BLOCK_SELECT_ITEMS_ONLY: - case BLOCK_MIRROR_X: - case BLOCK_MIRROR_Y: - break; - } + case BLOCK_ZOOM: // Handle by HandleBlockEnd() + case BLOCK_ROTATE: + case BLOCK_INVERT: + case BLOCK_DELETE: + case BLOCK_SAVE: + case BLOCK_ABORT: + case BLOCK_SELECT_ITEMS_ONLY: + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: + break; + } - GetScreen()->SetModify(); + GetScreen()->SetModify(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->BlockLocate.m_Flags = 0; - GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; - GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; - if ( GetScreen()->BlockLocate.m_BlockDrawStruct ) - { - DisplayError(this, wxT("Error in HandleBlockPLace DrawStruct != NULL") ); - GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; - } + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->BlockLocate.m_Flags = 0; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + if( GetScreen()->BlockLocate.m_BlockDrawStruct ) + { + DisplayError( this, wxT( "Error in HandleBlockPLace DrawStruct != NULL" ) ); + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + } - DisplayToolMsg(wxEmptyString); + DisplayToolMsg( wxEmptyString ); } + /**********************************************/ -int WinEDA_GerberFrame::HandleBlockEnd(wxDC * DC) +int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) /**********************************************/ + /* Routine de gestion de la commande BLOCK END - returne : - 0 si aucun compos ant selectionne - 1 sinon - -1 si commande termin�e et composants trouv�s (block delete, block save) -*/ + * returne : + * 0 si aucun compos ant selectionne + * 1 sinon + * -1 si commande termin�e et composants trouv�s (block delete, block save) + */ { -int endcommande = TRUE; -bool zoom_command = FALSE; + int endcommande = TRUE; + bool zoom_command = FALSE; -if(DrawPanel->ManageCurseur ) + if( DrawPanel->ManageCurseur ) - switch( GetScreen()->BlockLocate.m_Command ) - { - case BLOCK_IDLE: - DisplayError(this, wxT("Error in HandleBlockPLace")); - break; + switch( GetScreen()->BlockLocate.m_Command ) + { + case BLOCK_IDLE: + DisplayError( this, wxT( "Error in HandleBlockPLace" ) ); + break; - case BLOCK_DRAG: /* Drag (not used, for future enhancements)*/ - case BLOCK_MOVE: /* Move */ - case BLOCK_COPY: /* Copy */ - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ - GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; - endcommande = FALSE; - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - DrawPanel->ManageCurseur = DrawMovingBlockOutlines; - DrawPanel->ManageCurseur(DrawPanel,DC, FALSE); - break; + case BLOCK_DRAG: /* Drag (not used, for future enhancements)*/ + case BLOCK_MOVE: /* Move */ + case BLOCK_COPY: /* Copy */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; + endcommande = FALSE; + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + break; - case BLOCK_DELETE: /* Delete */ - GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; - DrawPanel->ManageCurseur(DrawPanel,DC, FALSE); - Block_Delete(DC); - break; + case BLOCK_DELETE: /* Delete */ + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + Block_Delete( DC ); + break; - case BLOCK_ROTATE: /* Unused */ - break; + case BLOCK_ROTATE: /* Unused */ + break; - case BLOCK_INVERT: /* Fip */ - break; + case BLOCK_INVERT: /* Fip */ + break; - case BLOCK_SAVE: /* Save (not used)*/ - break; + case BLOCK_SAVE: /* Save (not used)*/ + break; - case BLOCK_PASTE: break; + case BLOCK_PASTE: + break; - case BLOCK_ZOOM: /* Window Zoom */ - zoom_command = TRUE; - break; + case BLOCK_ZOOM: /* Window Zoom */ + zoom_command = TRUE; + break; - case BLOCK_ABORT: - case BLOCK_SELECT_ITEMS_ONLY: - case BLOCK_MIRROR_X: - case BLOCK_MIRROR_Y: - break; - } + case BLOCK_ABORT: + case BLOCK_SELECT_ITEMS_ONLY: + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: + break; + } - if ( endcommande == TRUE ) - { - GetScreen()->BlockLocate.m_Flags = 0; - GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; - GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; - GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - DisplayToolMsg(wxEmptyString); - } + if( endcommande == TRUE ) + { + GetScreen()->BlockLocate.m_Flags = 0; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + DisplayToolMsg( wxEmptyString ); + } - if ( zoom_command ) - Window_Zoom( GetScreen()->BlockLocate ); + if( zoom_command ) + Window_Zoom( GetScreen()->BlockLocate ); - return(endcommande); + return endcommande; } /**************************************************************************/ -static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /**************************************************************************/ + /* Retrace le contour du block de repositionnement des structures a d�placer */ { -int Color; -BASE_SCREEN * screen = panel->GetScreen(); + int Color; + BASE_SCREEN* screen = panel->GetScreen(); - Color = YELLOW; GRSetDrawMode(DC, g_XorMode); + Color = YELLOW; GRSetDrawMode( DC, g_XorMode ); - /* Effacement ancien cadre */ - if( erase ) - { - screen->BlockLocate.Draw(panel, DC); - if ( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y ) - { - screen->BlockLocate.Offset(screen->BlockLocate.m_MoveVector); - screen->BlockLocate.Draw(panel, DC); - screen->BlockLocate.Offset(-screen->BlockLocate.m_MoveVector.x, -screen->BlockLocate.m_MoveVector.y); - } - } + /* Effacement ancien cadre */ + if( erase ) + { + screen->BlockLocate.Draw( panel, DC ); + if( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y ) + { + screen->BlockLocate.Offset( screen->BlockLocate.m_MoveVector ); + screen->BlockLocate.Draw( panel, DC ); + screen->BlockLocate.Offset( -screen->BlockLocate.m_MoveVector.x, + -screen->BlockLocate.m_MoveVector.y ); + } + } - if ( panel->m_Parent->GetScreen()->BlockLocate.m_State != STATE_BLOCK_STOP ) - { - screen->BlockLocate.m_MoveVector.x = screen->m_Curseur.x - screen->BlockLocate.GetRight(); - screen->BlockLocate.m_MoveVector.y = screen->m_Curseur.y - screen->BlockLocate.GetBottom(); - } + if( panel->m_Parent->GetScreen()->BlockLocate.m_State != STATE_BLOCK_STOP ) + { + screen->BlockLocate.m_MoveVector.x = screen->m_Curseur.x - screen->BlockLocate.GetRight(); + screen->BlockLocate.m_MoveVector.y = screen->m_Curseur.y - screen->BlockLocate.GetBottom(); + } - screen->BlockLocate.Draw(panel, DC); - if ( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y ) - { - screen->BlockLocate.Offset(screen->BlockLocate.m_MoveVector); - screen->BlockLocate.Draw(panel, DC); - screen->BlockLocate.Offset(-screen->BlockLocate.m_MoveVector.x, -screen->BlockLocate.m_MoveVector.y); - } -} - - - -/************************************************/ -void WinEDA_BasePcbFrame::Block_Delete(wxDC *DC) -/************************************************/ -/* - routine d'effacement du block deja selectionne -*/ -{ - if ( !IsOK(this, _("Ok to delete block ?") ) ) return; - - GetScreen()->SetModify(); - GetScreen()->BlockLocate.Normalize(); - GetScreen()->m_CurrentItem = NULL; - - /* Effacement des Pistes */ - TRACK * pt_segm, * NextS; - for ( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = NextS) - { - NextS = pt_segm->Next(); - if( IsSegmentInBox(GetScreen()->BlockLocate, pt_segm ) ) - { /* la piste est ici bonne a etre efface */ - pt_segm->Draw(DrawPanel, DC, GR_XOR) ; - DeleteStructure(pt_segm); - } - } - - - /* Effacement des Zones */ - for ( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS) - { - NextS = pt_segm->Next(); - if( IsSegmentInBox(GetScreen()->BlockLocate, pt_segm ) ) - {/* la piste est ici bonne a etre efface */ - pt_segm->Draw(DrawPanel, DC, GR_XOR) ; - DeleteStructure(pt_segm); - } - } - - /* Rafraichissement de l'ecran : */ - RedrawActiveWindow(DC, TRUE); + screen->BlockLocate.Draw( panel, DC ); + if( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y ) + { + screen->BlockLocate.Offset( screen->BlockLocate.m_MoveVector ); + screen->BlockLocate.Draw( panel, DC ); + screen->BlockLocate.Offset( -screen->BlockLocate.m_MoveVector.x, + -screen->BlockLocate.m_MoveVector.y ); + } } /************************************************/ -void WinEDA_BasePcbFrame::Block_Move(wxDC * DC) +void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) /************************************************/ + /* - routine de deplacement des elements du block deja selectionne -*/ + * routine d'effacement du block deja selectionne + */ { -int deltaX, deltaY; -wxPoint oldpos; + if( !IsOK( this, _( "Ok to delete block ?" ) ) ) + return; - oldpos = GetScreen()->m_Curseur; - DrawPanel->ManageCurseur = NULL; + GetScreen()->SetModify(); + GetScreen()->BlockLocate.Normalize(); + GetScreen()->SetCurItem( NULL ); - GetScreen()->m_Curseur = oldpos; - DrawPanel->MouseToCursorSchema(); - GetScreen()->SetModify(); - GetScreen()->BlockLocate.Normalize(); + /* Effacement des Pistes */ + TRACK* pt_segm, * NextS; + for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = NextS ) + { + NextS = pt_segm->Next(); + if( IsSegmentInBox( GetScreen()->BlockLocate, pt_segm ) ) + { /* la piste est ici bonne a etre efface */ + pt_segm->Draw( DrawPanel, DC, GR_XOR ); + DeleteStructure( pt_segm ); + } + } - /* calcul du vecteur de deplacement pour les deplacements suivants */ - deltaX = GetScreen()->BlockLocate.m_MoveVector.x ; - deltaY = GetScreen()->BlockLocate.m_MoveVector.y ; + /* Effacement des Zones */ + for( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS ) + { + NextS = pt_segm->Next(); + if( IsSegmentInBox( GetScreen()->BlockLocate, pt_segm ) ) + { /* la piste est ici bonne a etre efface */ + pt_segm->Draw( DrawPanel, DC, GR_XOR ); + DeleteStructure( pt_segm ); + } + } + + /* Rafraichissement de l'ecran : */ + RedrawActiveWindow( DC, TRUE ); +} + + +/************************************************/ +void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) +/************************************************/ + +/* + * routine de deplacement des elements du block deja selectionne + */ +{ + int deltaX, deltaY; + wxPoint oldpos; + + oldpos = GetScreen()->m_Curseur; + DrawPanel->ManageCurseur = NULL; + + GetScreen()->m_Curseur = oldpos; + DrawPanel->MouseToCursorSchema(); + GetScreen()->SetModify(); + GetScreen()->BlockLocate.Normalize(); + + /* calcul du vecteur de deplacement pour les deplacements suivants */ + deltaX = GetScreen()->BlockLocate.m_MoveVector.x; + deltaY = GetScreen()->BlockLocate.m_MoveVector.y; /* Deplacement des Segments de piste */ - TRACK * track; - track = m_Pcb->m_Track; - while( track ) - { - if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) - { /* la piste est ici bonne a etre deplacee */ - m_Pcb->m_Status_Pcb = 0 ; - track->Draw(DrawPanel, DC, GR_XOR) ; // effacement - track->m_Start.x += deltaX ; track->m_Start.y += deltaY ; - track->m_End.x += deltaX ; track->m_End.y += deltaY ; - track->m_Param += deltaX ; track->m_Sous_Netcode += deltaY ; - track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage - } - track = (TRACK*) track->Pnext; - } + TRACK* track; + track = m_Pcb->m_Track; + while( track ) + { + if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + m_Pcb->m_Status_Pcb = 0; + track->Draw( DrawPanel, DC, GR_XOR ); // effacement + track->m_Start.x += deltaX; track->m_Start.y += deltaY; + track->m_End.x += deltaX; track->m_End.y += deltaY; + track->m_Param += deltaX; track->m_Sous_Netcode += deltaY; + track->Draw( DrawPanel, DC, GR_OR ); // reaffichage + } + track = (TRACK*) track->Pnext; + } - /* Deplacement des Segments de Zone */ - track = (TRACK*)m_Pcb->m_Zone; - while( track ) - { - if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) - { /* la piste est ici bonne a etre deplacee */ - track->Draw(DrawPanel, DC, GR_XOR) ; // effacement - track->m_Start.x += deltaX ; track->m_Start.y += deltaY ; - track->m_End.x += deltaX ; track->m_End.y += deltaY ; - track->m_Param += deltaX ; track->m_Sous_Netcode += deltaY ; - track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage - } - track = (TRACK*) track->Pnext; - } + /* Deplacement des Segments de Zone */ + track = (TRACK*) m_Pcb->m_Zone; + while( track ) + { + if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + track->Draw( DrawPanel, DC, GR_XOR ); // effacement + track->m_Start.x += deltaX; track->m_Start.y += deltaY; + track->m_End.x += deltaX; track->m_End.y += deltaY; + track->m_Param += deltaX; track->m_Sous_Netcode += deltaY; + track->Draw( DrawPanel, DC, GR_OR ); // reaffichage + } + track = (TRACK*) track->Pnext; + } - DrawPanel->Refresh(TRUE); + DrawPanel->Refresh( TRUE ); } /**************************************************/ -void WinEDA_BasePcbFrame::Block_Duplicate(wxDC * DC) +void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) /**************************************************/ + /* - routine de duplication des elements du block deja selectionne -*/ + * routine de duplication des elements du block deja selectionne + */ { -int deltaX, deltaY; -wxPoint oldpos; + int deltaX, deltaY; + wxPoint oldpos; - oldpos = GetScreen()->m_Curseur; - DrawPanel->ManageCurseur = NULL; + oldpos = GetScreen()->m_Curseur; + DrawPanel->ManageCurseur = NULL; - GetScreen()->m_Curseur = oldpos; - DrawPanel->MouseToCursorSchema(); - GetScreen()->SetModify(); - GetScreen()->BlockLocate.Normalize(); + GetScreen()->m_Curseur = oldpos; + DrawPanel->MouseToCursorSchema(); + GetScreen()->SetModify(); + GetScreen()->BlockLocate.Normalize(); - /* calcul du vecteur de deplacement pour les deplacements suivants */ - deltaX = GetScreen()->BlockLocate.m_MoveVector.x ; - deltaY = GetScreen()->BlockLocate.m_MoveVector.y ; + /* calcul du vecteur de deplacement pour les deplacements suivants */ + deltaX = GetScreen()->BlockLocate.m_MoveVector.x; + deltaY = GetScreen()->BlockLocate.m_MoveVector.y; - /* Deplacement des Segments de piste */ - TRACK * track, *next_track, *new_track; + /* Deplacement des Segments de piste */ + TRACK* track, * next_track, * new_track; - track = m_Pcb->m_Track; - while( track ) - { - next_track = track->Next(); - if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) - { /* la piste est ici bonne a etre deplacee */ - m_Pcb->m_Status_Pcb = 0 ; - new_track = track->Copy(1); - new_track->Insert(m_Pcb,NULL); - new_track->m_Start.x += deltaX ; new_track->m_Start.y += deltaY ; - new_track->m_End.x += deltaX ; new_track->m_End.y += deltaY ; - new_track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage - } - track = next_track; - } + track = m_Pcb->m_Track; + while( track ) + { + next_track = track->Next(); + if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + m_Pcb->m_Status_Pcb = 0; + new_track = track->Copy( 1 ); + new_track->Insert( m_Pcb, NULL ); + new_track->m_Start.x += deltaX; new_track->m_Start.y += deltaY; + new_track->m_End.x += deltaX; new_track->m_End.y += deltaY; + new_track->Draw( DrawPanel, DC, GR_OR ); // reaffichage + } + track = next_track; + } - /* Deplacement des Segments de Zone */ - track = (TRACK*)m_Pcb->m_Zone; - while( track ) - { - next_track = track->Next(); - if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) - { /* la piste est ici bonne a etre deplacee */ - new_track = new TRACK(m_Pcb); - new_track = track->Copy(1); - new_track->Insert(m_Pcb,NULL); - new_track->m_Start.x += deltaX ; new_track->m_Start.y += deltaY ; - new_track->m_End.x += deltaX ; new_track->m_End.y += deltaY ; - new_track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage - } - track = next_track; - } + /* Deplacement des Segments de Zone */ + track = (TRACK*) m_Pcb->m_Zone; + while( track ) + { + next_track = track->Next(); + if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + new_track = new TRACK( m_Pcb ); + new_track = track->Copy( 1 ); + new_track->Insert( m_Pcb, NULL ); + new_track->m_Start.x += deltaX; new_track->m_Start.y += deltaY; + new_track->m_End.x += deltaX; new_track->m_End.y += deltaY; + new_track->Draw( DrawPanel, DC, GR_OR ); // reaffichage + } + track = next_track; + } } /**************************************************************************/ -static TRACK * IsSegmentInBox( DrawBlockStruct & blocklocate, TRACK * PtSegm ) +static TRACK* IsSegmentInBox( DrawBlockStruct& blocklocate, TRACK* PtSegm ) /**************************************************************************/ + /* Teste si la structure PtStruct est inscrite dans le block selectionne - Retourne PtSegm si oui - NULL si non -*/ + * Retourne PtSegm si oui + * NULL si non + */ { - if ( blocklocate.Inside(PtSegm->m_Start.x ,PtSegm->m_Start.y) ) - return ( PtSegm ); + if( blocklocate.Inside( PtSegm->m_Start.x, PtSegm->m_Start.y ) ) + return PtSegm; - if ( blocklocate.Inside(PtSegm->m_End.x, PtSegm->m_End.y) ) - return ( PtSegm ); + if( blocklocate.Inside( PtSegm->m_End.x, PtSegm->m_End.y ) ) + return PtSegm; - return ( NULL ); + return NULL; } - diff --git a/gerbview/deltrack.cpp b/gerbview/deltrack.cpp index 90d2da0f4f..671a655205 100644 --- a/gerbview/deltrack.cpp +++ b/gerbview/deltrack.cpp @@ -1,7 +1,7 @@ - /*********************************************/ - /* Edition des pistes: Routines d'effacement */ - /* Effacement de segment, piste, net et zone */ - /*********************************************/ +/*********************************************/ +/* Edition des pistes: Routines d'effacement */ +/* Effacement de segment, piste, net et zone */ +/*********************************************/ #include "fctsys.h" @@ -18,79 +18,82 @@ /****************************************************************************************/ -void WinEDA_GerberFrame::Delete_DCode_Items(wxDC * DC, int dcode_value, int layer_number) +void WinEDA_GerberFrame::Delete_DCode_Items( wxDC* DC, int dcode_value, int layer_number ) /****************************************************************************************/ { - if ( dcode_value < FIRST_DCODE ) // No tool selected - return; -BOARD * Pcb = m_Pcb; -TRACK * track = Pcb->m_Track, * next_track; - for ( ; track != NULL ; track = next_track ) - { - next_track = track->Next(); - if ( dcode_value != track->m_NetCode ) continue; - if ( layer_number >= 0 && layer_number != track->m_Layer ) continue; - Delete_Segment(DC, track); - } - GetScreen()->m_CurrentItem = NULL; + if( dcode_value < FIRST_DCODE ) // No tool selected + return; + BOARD* Pcb = m_Pcb; + TRACK* track = Pcb->m_Track, * next_track; + for( ; track != NULL; track = next_track ) + { + next_track = track->Next(); + if( dcode_value != track->m_NetCode ) + continue; + if( layer_number >= 0 && layer_number != track->m_Layer ) + continue; + Delete_Segment( DC, track ); + } + GetScreen()->SetCurItem( NULL ); } /*****************************************************************/ -TRACK * WinEDA_GerberFrame::Delete_Segment(wxDC * DC, TRACK *Track) +TRACK* WinEDA_GerberFrame::Delete_Segment( wxDC* DC, TRACK* Track ) /*****************************************************************/ + /* Supprime 1 segment de piste. - 2 Cas possibles: - Si On est en trace de nouvelle piste: Effacement du segment en - cours de trace - Sinon : Effacment du segment sous le curseur. -*/ + * 2 Cas possibles: + * Si On est en trace de nouvelle piste: Effacement du segment en + * cours de trace + * Sinon : Effacment du segment sous le curseur. + */ { - if ( Track == NULL ) return NULL; + if( Track == NULL ) + return NULL; - if(Track->m_Flags & IS_NEW) // Trace en cours, on peut effacer le dernier segment - { - if(g_TrackSegmentCount > 0 ) - { - // modification du trace - Track = g_CurrentTrackSegment; g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; - delete Track; g_TrackSegmentCount--; + if( Track->m_Flags & IS_NEW ) // Trace en cours, on peut effacer le dernier segment + { + if( g_TrackSegmentCount > 0 ) + { + // modification du trace + Track = g_CurrentTrackSegment; + g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; + delete Track; g_TrackSegmentCount--; - if( g_TrackSegmentCount && (g_CurrentTrackSegment->m_StructType == TYPEVIA)) - { - Track = g_CurrentTrackSegment; g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; - delete Track; - g_TrackSegmentCount-- ; - } - if( g_CurrentTrackSegment ) g_CurrentTrackSegment->Pnext = NULL; + if( g_TrackSegmentCount && (g_CurrentTrackSegment->m_StructType == TYPEVIA) ) + { + Track = g_CurrentTrackSegment; + g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; + delete Track; + g_TrackSegmentCount--; + } + if( g_CurrentTrackSegment ) + g_CurrentTrackSegment->Pnext = NULL; - Affiche_Status_Box(); - - if(g_TrackSegmentCount == 0 ) - { - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - return NULL; - } - else - { - if(DrawPanel->ManageCurseur) - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - return g_CurrentTrackSegment; - } - } - return NULL; - } // Fin traitement si trace en cours + Affiche_Status_Box(); + + if( g_TrackSegmentCount == 0 ) + { + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + return NULL; + } + else + { + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + return g_CurrentTrackSegment; + } + } + return NULL; + } // Fin traitement si trace en cours - Trace_Segment(DrawPanel, DC, Track,GR_XOR) ; + Trace_Segment( DrawPanel, DC, Track, GR_XOR ); - SaveItemEfface( Track, 1); - GetScreen()->SetModify(); - return NULL; + SaveItemEfface( Track, 1 ); + GetScreen()->SetModify(); + return NULL; } - - - - diff --git a/gerbview/edit.cpp b/gerbview/edit.cpp index 4f118c6a94..b8d39e3d49 100644 --- a/gerbview/edit.cpp +++ b/gerbview/edit.cpp @@ -1,6 +1,6 @@ - /******************************************************/ - /* edit.cpp: fonctions generales de l'edition du PCB */ - /******************************************************/ +/******************************************************/ +/* edit.cpp: fonctions generales de l'edition du PCB */ +/******************************************************/ #include "fctsys.h" @@ -12,344 +12,357 @@ #include "protos.h" -static void Process_Move_Item(WinEDA_GerberFrame * frame, - EDA_BaseStruct *DrawStruct, wxDC * DC); +static void Process_Move_Item( WinEDA_GerberFrame* frame, + EDA_BaseStruct* DrawStruct, wxDC* DC ); /************************************************************************/ -void WinEDA_GerberFrame::OnLeftClick(wxDC * DC, const wxPoint& MousePos) +void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) /************************************************************************/ + /* Traite les commandes declench�e par le bouton gauche de la souris, - quand un outil est deja selectionn� -*/ + * quand un outil est deja selectionn� + */ { -EDA_BaseStruct * DrawStruct = GetScreen()->m_CurrentItem; -wxString msg; + EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem(); + wxString msg; - if ( m_ID_current_state == 0 ) - { - if ( DrawStruct && DrawStruct->m_Flags ) // Commande "POPUP" en cours - { - switch (DrawStruct->m_StructType ) - { - default: - msg.Printf( - wxT("WinEDA_GerberFrame::ProcessCommand err: Struct %d, m_Flags = %X"), - (unsigned) DrawStruct->m_StructType, - (unsigned) DrawStruct->m_Flags); - DisplayError(this, msg ); - } - } - else - { - GetScreen()->m_CurrentItem = - DrawStruct = GerberGeneralLocateAndDisplay(); - } - } + if( m_ID_current_state == 0 ) + { + if( DrawStruct && DrawStruct->m_Flags ) // Commande "POPUP" en cours + { + switch( DrawStruct->m_StructType ) + { + default: + msg.Printf( + wxT( "WinEDA_GerberFrame::ProcessCommand err: Struct %d, m_Flags = %X" ), + (unsigned) DrawStruct->m_StructType, + (unsigned) DrawStruct->m_Flags ); + DisplayError( this, msg ); + } + } + else + { + DrawStruct = GerberGeneralLocateAndDisplay(); + GetScreen()->SetCurItem( DrawStruct ); + } + } - switch ( m_ID_current_state ) - { - case 0: - break; + switch( m_ID_current_state ) + { + case 0: + break; - case ID_NO_SELECT_BUTT: - break; + case ID_NO_SELECT_BUTT: + break; - case ID_PCB_DELETE_ITEM_BUTT: - DrawStruct = GerberGeneralLocateAndDisplay(); - if ( DrawStruct == NULL ) break; - if ( DrawStruct->m_StructType == TYPETRACK ) - { - Delete_Segment(DC, (TRACK *) DrawStruct ); - GetScreen()->m_CurrentItem = NULL; - GetScreen()->SetModify(); - } - break; + case ID_PCB_DELETE_ITEM_BUTT: + DrawStruct = GerberGeneralLocateAndDisplay(); + if( DrawStruct == NULL ) + break; + if( DrawStruct->m_StructType == TYPETRACK ) + { + Delete_Segment( DC, (TRACK*) DrawStruct ); + GetScreen()->SetCurItem( NULL ); + GetScreen()->SetModify(); + } + break; - default : - DisplayError(this, wxT("WinEDA_GerberFrame::ProcessCommand error")); - SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); - break; - } + default: + DisplayError( this, wxT( "WinEDA_GerberFrame::ProcessCommand error" ) ); + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); + break; + } } /********************************************************************************/ -void WinEDA_GerberFrame::Process_Special_Functions(wxCommandEvent& event) +void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) /********************************************************************************/ + /* Traite les selections d'outils et les commandes appelees du menu POPUP -*/ + */ { -int id = event.GetId(); -int layer = GetScreen()->m_Active_Layer; -GERBER_Descr * gerber_layer = g_GERBER_Descr_List[layer]; -wxPoint pos; -wxClientDC dc(DrawPanel); + int id = event.GetId(); + int layer = GetScreen()->m_Active_Layer; + GERBER_Descr* gerber_layer = g_GERBER_Descr_List[layer]; + wxPoint pos; + wxClientDC dc( DrawPanel ); - DrawPanel->PrepareGraphicContext(&dc); + DrawPanel->PrepareGraphicContext( &dc ); - wxGetMousePosition(&pos.x, &pos.y); + wxGetMousePosition( &pos.x, &pos.y ); - pos.y += 20; + pos.y += 20; - switch ( id ) // Arret eventuel de la commande de d�placement en cours - { - case wxID_CUT: - case wxID_COPY: - case ID_POPUP_DELETE_BLOCK: - case ID_POPUP_PLACE_BLOCK: - case ID_POPUP_ZOOM_BLOCK: - case ID_POPUP_INVERT_BLOCK: - case ID_POPUP_ROTATE_BLOCK: - case ID_POPUP_COPY_BLOCK: - break; + switch( id ) // Arret eventuel de la commande de d�placement en cours + { + case wxID_CUT: + case wxID_COPY: + case ID_POPUP_DELETE_BLOCK: + case ID_POPUP_PLACE_BLOCK: + case ID_POPUP_ZOOM_BLOCK: + case ID_POPUP_INVERT_BLOCK: + case ID_POPUP_ROTATE_BLOCK: + case ID_POPUP_COPY_BLOCK: + break; - case ID_POPUP_CANCEL_CURRENT_COMMAND: - if( DrawPanel->ManageCurseur && - DrawPanel->ForceCloseManageCurseur ) - { - DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); - } - /* ne devrait pas etre execute, sauf bug */ - if (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE) - { - m_CurrentScreen->BlockLocate.m_Command = BLOCK_IDLE; - m_CurrentScreen->BlockLocate.m_State = STATE_NO_BLOCK; - m_CurrentScreen->BlockLocate.m_BlockDrawStruct = NULL; - } - if (m_ID_current_state == 0 ) - SetToolID(0, wxCURSOR_ARROW, wxEmptyString); - else SetCursor(DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor); - break; + case ID_POPUP_CANCEL_CURRENT_COMMAND: + if( DrawPanel->ManageCurseur + && DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); + } + /* ne devrait pas etre execute, sauf bug */ + if( m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE ) + { + m_CurrentScreen->BlockLocate.m_Command = BLOCK_IDLE; + m_CurrentScreen->BlockLocate.m_State = STATE_NO_BLOCK; + m_CurrentScreen->BlockLocate.m_BlockDrawStruct = NULL; + } + if( m_ID_current_state == 0 ) + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); + else + SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor ); + break; - default: // Arret dea commande de d�placement en cours - if( DrawPanel->ManageCurseur && - DrawPanel->ForceCloseManageCurseur ) - { - DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); - } - SetToolID(0, wxCURSOR_ARROW, wxEmptyString); - break; - } + default: // Arret dea commande de d�placement en cours + if( DrawPanel->ManageCurseur + && DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); + } + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); + break; + } - switch ( id ) // Traitement des commandes - { - case ID_EXIT : - Close(TRUE); - break; + switch( id ) // Traitement des commandes + { + case ID_EXIT: + Close( TRUE ); + break; - case ID_NEW_PROJECT: - case ID_LOAD_PROJECT: - Files_io(event); - break; + case ID_NEW_PROJECT: + case ID_LOAD_PROJECT: + Files_io( event ); + break; - case ID_PCB_GLOBAL_DELETE: - Erase_Current_Layer(&dc, TRUE); - break; + case ID_PCB_GLOBAL_DELETE: + Erase_Current_Layer( &dc, TRUE ); + break; - case wxID_CUT: - break; + case wxID_CUT: + break; - case wxID_COPY: - break; + case wxID_COPY: + break; + + case wxID_PASTE: - case wxID_PASTE: // HandleBlockBegin(&dc, BLOCK_PASTE); - break; + break; - case ID_UNDO_BUTT: - UnDeleteItem(&dc); - break; + case ID_UNDO_BUTT: + UnDeleteItem( &dc ); + break; + + case ID_GET_TOOLS: - case ID_GET_TOOLS: // InstallToolsFrame(this, wxPoint(-1,-1) ); - break; + break; + + case ID_FIND_ITEMS: - case ID_FIND_ITEMS: // InstallFindFrame(this, pos); - break; + break; - case ID_BUS_BUTT: - SetToolID( id, wxCURSOR_PENCIL, wxT("Add Tracks")); - break; + case ID_BUS_BUTT: + SetToolID( id, wxCURSOR_PENCIL, wxT( "Add Tracks" ) ); + break; - case ID_LINE_COMMENT_BUTT: - SetToolID( id, wxCURSOR_PENCIL, wxT("Add Drawing")); - break; + case ID_LINE_COMMENT_BUTT: + SetToolID( id, wxCURSOR_PENCIL, wxT( "Add Drawing" ) ); + break; - case ID_TEXT_COMMENT_BUTT: - SetToolID( id, wxCURSOR_PENCIL, wxT("Add Text")); - break; + case ID_TEXT_COMMENT_BUTT: + SetToolID( id, wxCURSOR_PENCIL, wxT( "Add Text" ) ); + break; - case ID_NO_SELECT_BUTT: - SetToolID( 0, 0, wxEmptyString); - break; + case ID_NO_SELECT_BUTT: + SetToolID( 0, 0, wxEmptyString ); + break; - case ID_POPUP_CLOSE_CURRENT_TOOL: - SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); - break; + case ID_POPUP_CLOSE_CURRENT_TOOL: + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); + break; - case ID_POPUP_CANCEL_CURRENT_COMMAND: - break; + case ID_POPUP_CANCEL_CURRENT_COMMAND: + break; + + case ID_POPUP_END_LINE: + DrawPanel->MouseToCursorSchema(); - case ID_POPUP_END_LINE: - DrawPanel->MouseToCursorSchema(); // EndSegment(&dc); - break; + break; - case ID_POPUP_PCB_DELETE_TRACKSEG: - DrawPanel->MouseToCursorSchema(); - if ( GetScreen()->m_CurrentItem == NULL) break; - Delete_Segment(&dc, (TRACK*)GetScreen()->m_CurrentItem); - GetScreen()->m_CurrentItem = NULL; - GetScreen()->SetModify(); - break; + case ID_POPUP_PCB_DELETE_TRACKSEG: + DrawPanel->MouseToCursorSchema(); + if( GetScreen()->GetCurItem() == NULL ) + break; + Delete_Segment( &dc, (TRACK*) GetScreen()->GetCurItem() ); + GetScreen()->SetCurItem( NULL ); + GetScreen()->SetModify(); + break; - case ID_PCB_DELETE_ITEM_BUTT: - SetToolID( id, wxCURSOR_PENCIL, wxT("Delete item")); - break; + case ID_PCB_DELETE_ITEM_BUTT: + SetToolID( id, wxCURSOR_PENCIL, wxT( "Delete item" ) ); + break; - case ID_POPUP_SCH_MOVE_ITEM_REQUEST: - DrawPanel->MouseToCursorSchema(); - Process_Move_Item(this, GetScreen()->m_CurrentItem, &dc); - break; + case ID_POPUP_SCH_MOVE_ITEM_REQUEST: + DrawPanel->MouseToCursorSchema(); + Process_Move_Item( this, GetScreen()->GetCurItem(), &dc ); + break; - case ID_TOOLBARH_PCB_SELECT_LAYER: - { - GetScreen()->m_Active_Layer = m_SelLayerBox->GetChoice(); - DrawPanel->Refresh(TRUE); - break; - } + case ID_TOOLBARH_PCB_SELECT_LAYER: + { + GetScreen()->m_Active_Layer = m_SelLayerBox->GetChoice(); + DrawPanel->Refresh( TRUE ); + break; + } - case ID_TOOLBARH_GERBER_SELECT_TOOL: - if ( gerber_layer ) - { - int tool = m_SelLayerTool->GetChoice(); - if ( tool > 0 ) tool = tool - 1 + FIRST_DCODE; - else tool = 0; - gerber_layer->m_Selected_Tool = tool; - DrawPanel->Refresh(TRUE); - } - else DisplayError(this, _("No layer selected") ); - break; + case ID_TOOLBARH_GERBER_SELECT_TOOL: + if( gerber_layer ) + { + int tool = m_SelLayerTool->GetChoice(); + if( tool > 0 ) + tool = tool - 1 + FIRST_DCODE; + else + tool = 0; + gerber_layer->m_Selected_Tool = tool; + DrawPanel->Refresh( TRUE ); + } + else + DisplayError( this, _( "No layer selected" ) ); + break; - case ID_GERBVIEW_SHOW_LIST_DCODES: - Liste_D_Codes(&dc); - break; + case ID_GERBVIEW_SHOW_LIST_DCODES: + Liste_D_Codes( &dc ); + break; - case ID_GERBVIEW_SHOW_SOURCE: - if ( gerber_layer ) - { - wxString editorname = GetEditorName(); - if ( ! editorname.IsEmpty() ) - ExecuteFile(this, editorname, gerber_layer->m_FileName); - } - break; + case ID_GERBVIEW_SHOW_SOURCE: + if( gerber_layer ) + { + wxString editorname = GetEditorName(); + if( !editorname.IsEmpty() ) + ExecuteFile( this, editorname, gerber_layer->m_FileName ); + } + break; - case ID_POPUP_PLACE_BLOCK: - GetScreen()->BlockLocate.m_Command = BLOCK_MOVE; - DrawPanel->m_AutoPAN_Request = FALSE; - HandleBlockPlace(&dc); - break; + case ID_POPUP_PLACE_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_MOVE; + DrawPanel->m_AutoPAN_Request = FALSE; + HandleBlockPlace( &dc ); + break; - case ID_POPUP_COPY_BLOCK: - GetScreen()->BlockLocate.m_Command = BLOCK_COPY; - m_CurrentScreen->BlockLocate.SetMessageBlock(this); - DrawPanel->m_AutoPAN_Request = FALSE; - HandleBlockEnd(&dc); - break; + case ID_POPUP_COPY_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_COPY; + m_CurrentScreen->BlockLocate.SetMessageBlock( this ); + DrawPanel->m_AutoPAN_Request = FALSE; + HandleBlockEnd( &dc ); + break; - case ID_POPUP_ZOOM_BLOCK: - GetScreen()->BlockLocate.m_Command = BLOCK_ZOOM; - m_CurrentScreen->BlockLocate.SetMessageBlock(this); - m_CurrentScreen->BlockLocate.SetMessageBlock(this); - HandleBlockEnd(&dc); - break; + case ID_POPUP_ZOOM_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_ZOOM; + m_CurrentScreen->BlockLocate.SetMessageBlock( this ); + m_CurrentScreen->BlockLocate.SetMessageBlock( this ); + HandleBlockEnd( &dc ); + break; - case ID_POPUP_DELETE_BLOCK: - GetScreen()->BlockLocate.m_Command = BLOCK_DELETE; - m_CurrentScreen->BlockLocate.SetMessageBlock(this); - HandleBlockEnd(&dc); - break; + case ID_POPUP_DELETE_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_DELETE; + m_CurrentScreen->BlockLocate.SetMessageBlock( this ); + HandleBlockEnd( &dc ); + break; - case ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS: - if ( gerber_layer ) - Delete_DCode_Items(&dc, gerber_layer->m_Selected_Tool, GetScreen()->m_Active_Layer); - break; + case ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS: + if( gerber_layer ) + Delete_DCode_Items( &dc, gerber_layer->m_Selected_Tool, GetScreen()->m_Active_Layer ); + break; - default: - wxMessageBox( wxT("WinEDA_GerberFrame::Process_Special_Functions error")); - break; - } + default: + wxMessageBox( wxT( "WinEDA_GerberFrame::Process_Special_Functions error" ) ); + break; + } - SetToolbars(); + SetToolbars(); } /****************************************************************/ -static void Process_Move_Item(WinEDA_GerberFrame * frame, - EDA_BaseStruct *DrawStruct, wxDC * DC) +static void Process_Move_Item( WinEDA_GerberFrame* frame, + EDA_BaseStruct* DrawStruct, wxDC* DC ) /****************************************************************/ { + if( DrawStruct == NULL ) + return; - if ( DrawStruct == NULL ) return; + frame->DrawPanel->MouseToCursorSchema(); - frame->DrawPanel->MouseToCursorSchema(); - switch ( DrawStruct->m_StructType ) - { - - default: - wxString msg; - msg.Printf( - wxT("WinEDA_LibeditFrame::Move_Item Error: Bad DrawType %d"), - DrawStruct->m_StructType); - DisplayError(frame, msg ); - break; - } + switch( DrawStruct->m_StructType ) + { + default: + wxString msg; + msg.Printf( + wxT( "WinEDA_LibeditFrame::Move_Item Error: Bad DrawType %d" ), + DrawStruct->m_StructType ); + DisplayError( frame, msg ); + break; + } } /**************************************************************************/ -void WinEDA_GerberFrame::OnLeftDClick(wxDC * DC, const wxPoint& MousePos) +void WinEDA_GerberFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) /**************************************************************************/ + /* Appel� sur un double click: - pour un �l�ment editable (textes, composant): - appel de l'editeur correspondant. - pour une connexion en cours: - termine la connexion -*/ + * pour un �l�ment editable (textes, composant): + * appel de l'editeur correspondant. + * pour une connexion en cours: + * termine la connexion + */ { -EDA_BaseStruct * DrawStruct = GetScreen()->m_CurrentItem; -wxClientDC dc(DrawPanel); + EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem(); + wxClientDC dc( DrawPanel ); - DrawPanel->PrepareGraphicContext(&dc); + DrawPanel->PrepareGraphicContext( &dc ); - switch ( m_ID_current_state ) - { - case 0: - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - DrawStruct = GerberGeneralLocateAndDisplay(); - } + switch( m_ID_current_state ) + { + case 0: + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + DrawStruct = GerberGeneralLocateAndDisplay(); + } - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) ) - break; + if( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) ) + break; - // Element localis� - switch ( DrawStruct->m_StructType ) - { - default: - break; - } - break; // end case 0 + // Element localis� + switch( DrawStruct->m_StructType ) + { + default: + break; + } + + break; // end case 0 + + case ID_BUS_BUTT: + case ID_WIRE_BUTT: - case ID_BUS_BUTT: - case ID_WIRE_BUTT: // if ( DrawStruct && (DrawStruct->m_Flags & IS_NEW) ) - // EndSegment(DC); - break; - } +// EndSegment(DC); + break; + } } - - diff --git a/gerbview/onrightclick.cpp b/gerbview/onrightclick.cpp index fafe8b1646..fb4eeb1843 100644 --- a/gerbview/onrightclick.cpp +++ b/gerbview/onrightclick.cpp @@ -1,6 +1,6 @@ - /******************************************************/ - /* edit.cpp: fonctions generales de l'edition du PCB */ - /******************************************************/ +/******************************************************/ +/* edit.cpp: fonctions generales de l'edition du PCB */ +/******************************************************/ #include "fctsys.h" @@ -13,77 +13,81 @@ #include "protos.h" /********************************************************************************/ -void WinEDA_GerberFrame::OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu) +void WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) /********************************************************************************/ + /* Prepare le menu PullUp affich� par un click sur le bouton droit -de la souris. - Ce menu est ensuite compl�t� par la liste des commandes de ZOOM -*/ + * de la souris. + * Ce menu est ensuite compl�t� par la liste des commandes de ZOOM + */ { -EDA_BaseStruct *DrawStruct = GetScreen()->m_CurrentItem; -wxString msg; -bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE); + EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem(); + wxString msg; + bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE); - DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu + DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu - // Simple localisation des elements si possible - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - DrawStruct = GerberGeneralLocateAndDisplay(); - } + // Simple localisation des elements si possible + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + DrawStruct = GerberGeneralLocateAndDisplay(); + } - // Si commande en cours: affichage fin de commande - if ( m_ID_current_state ) - { - if ( DrawStruct && DrawStruct->m_Flags ) - PopMenu->Append(ID_POPUP_CANCEL_CURRENT_COMMAND, _("Cancel")); - else PopMenu->Append(ID_POPUP_CLOSE_CURRENT_TOOL, _("End Tool")); - PopMenu->AppendSeparator(); - } + // Si commande en cours: affichage fin de commande + if( m_ID_current_state ) + { + if( DrawStruct && DrawStruct->m_Flags ) + PopMenu->Append( ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ) ); + else + PopMenu->Append( ID_POPUP_CLOSE_CURRENT_TOOL, _( "End Tool" ) ); + PopMenu->AppendSeparator(); + } + else + { + if( (DrawStruct && DrawStruct->m_Flags) || BlockActive ) + { + if( BlockActive ) + { + PopMenu->Append( ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ) ); + PopMenu->Append( ID_POPUP_ZOOM_BLOCK, _( "Zoom Block (Midd butt drag)" ) ); + PopMenu->AppendSeparator(); + PopMenu->Append( ID_POPUP_PLACE_BLOCK, _( "Place Block" ) ); + PopMenu->Append( ID_POPUP_COPY_BLOCK, _( "Copy Block (shift mouse)" ) ); + PopMenu->Append( ID_POPUP_DELETE_BLOCK, _( "Delete Block (ctrl + drag mouse)" ) ); + } + else + PopMenu->Append( ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ) ); + PopMenu->AppendSeparator(); + } + } - else - { - if ( (DrawStruct && DrawStruct->m_Flags) || BlockActive ) - { - if ( BlockActive ) - { - PopMenu->Append(ID_POPUP_CANCEL_CURRENT_COMMAND, _("Cancel Block") ); - PopMenu->Append(ID_POPUP_ZOOM_BLOCK, _("Zoom Block (Midd butt drag)") ); - PopMenu->AppendSeparator(); - PopMenu->Append(ID_POPUP_PLACE_BLOCK, _("Place Block") ); - PopMenu->Append(ID_POPUP_COPY_BLOCK, _("Copy Block (shift mouse)") ); - PopMenu->Append(ID_POPUP_DELETE_BLOCK, _("Delete Block (ctrl + drag mouse)") ); - } - else PopMenu->Append(ID_POPUP_CANCEL_CURRENT_COMMAND, _("Cancel")); - PopMenu->AppendSeparator(); - } - } + if( BlockActive ) + return; - if ( BlockActive ) return; + PopMenu->Append( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, _( "Delete Dcode items" ) ); - PopMenu->Append(ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, _("Delete Dcode items")); + if( DrawStruct == NULL ) + return; - if ( DrawStruct == NULL ) return; + GetScreen()->SetCurItem( DrawStruct ); - GetScreen()->m_CurrentItem = DrawStruct; + switch( DrawStruct->m_StructType ) + { + case TYPETRACK: - switch ( DrawStruct->m_StructType ) - { - - case TYPETRACK: // PopMenu->AppendSeparator(); // PopMenu->Append(ID_POPUP_PCB_EDIT_TRACK, _("Edit")); // PopMenu->Append(ID_POPUP_PCB_DELETE_TRACKSEG, _("Delete")); - break; + break; - default: - msg.Printf( - wxT("WinEDA_GerberFrame::OnRightClick Error: illegal or unknown DrawType %d"), - DrawStruct->m_StructType); - DisplayError(this, msg ); - break; - } - PopMenu->AppendSeparator(); + default: + msg.Printf( + wxT( "WinEDA_GerberFrame::OnRightClick Error: illegal or unknown DrawType %d" ), + DrawStruct->m_StructType ); + DisplayError( this, msg ); + break; + } + + PopMenu->AppendSeparator(); } - diff --git a/include/base_struct.h b/include/base_struct.h index 17803292a8..b8d8e2f1be 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -5,6 +5,8 @@ #ifndef BASE_STRUCT_H #define BASE_STRUCT_H +#include <vector> + #if defined(DEBUG) #include <iostream> // needed for Show() @@ -95,9 +97,54 @@ class EDA_BaseStruct; */ class INSPECTOR { +private: + /// A place to hold collected objects without taking ownership of their memory. + std::vector<EDA_BaseStruct*> list; + + public: - virtual ~INSPECTOR() {} + virtual ~INSPECTOR() + { + // empty the list so that ~list() does not try and delete all + // the objects that it holds. list is not the owner of such objects. + Empty(); + } + + /** + * Function GetCount + * returns the number of objects in the list + */ + int GetCount() const + { + return list.size(); + } + + + /** + * Function Empty + * sets the list to empty + */ + void Empty() + { + list.clear(); + } + + + /** + * Function operator[] + * is used for read only access and returns the object at index ndx. + * @param ndx The index into the list. + * @return EDA_BaseStruct* - or something derived from it, or NULL. + */ + EDA_BaseStruct* operator[]( int ndx ) const + { + if( (unsigned)ndx < (unsigned)GetCount() ) + return list[ndx]; + return NULL; + } + + /** * Function Inspect * is the examining function within the INSPECTOR which is passed to the @@ -112,9 +159,6 @@ public: */ SEARCH_RESULT virtual Inspect( EDA_BaseStruct* testItem, const void* testData ) = 0; - - // derived classes add more functions for collecting and subsequent - // retrieval here. }; diff --git a/include/drawpanel_wxstruct.h b/include/drawpanel_wxstruct.h index 4530ee0f9f..8a7bf8810a 100644 --- a/include/drawpanel_wxstruct.h +++ b/include/drawpanel_wxstruct.h @@ -141,8 +141,8 @@ typedef enum { } CmdBlockType; -class DrawBlockStruct : public EDA_BaseStruct - , public EDA_Rect + +class DrawBlockStruct : public EDA_BaseStruct, public EDA_Rect { public: BlockState m_State; /* Etat (enum BlockState) du block */ @@ -192,7 +192,6 @@ public: EDA_BaseStruct* m_UndoList; /* Object list for the undo command (old data) */ EDA_BaseStruct* m_RedoList; /* Object list for the redo command (old data) */ int m_UndoRedoCountMax; /* undo/Redo command Max depth */ - EDA_BaseStruct* m_CurrentItem; /* Current selected object */ /* block control */ DrawBlockStruct BlockLocate; /* Bock description for block commands */ @@ -213,9 +212,10 @@ public: private: /* indicateurs divers */ - char m_FlagRefreshReq; /* indique que l'ecran doit redessine */ - char m_FlagModified; // indique modif du PCB,utilise pour eviter une sortie sans sauvegarde - char m_FlagSave; // indique sauvegarde auto faite + char m_FlagRefreshReq; /* indique que l'ecran doit redessine */ + char m_FlagModified; // indique modif du PCB,utilise pour eviter une sortie sans sauvegarde + char m_FlagSave; // indique sauvegarde auto faite + EDA_BaseStruct* m_CurrentItem; /* Current selected object */ /* Valeurs du pas de grille et du zoom */ public: @@ -246,16 +246,28 @@ public: virtual EDA_BaseStruct* GetItemFromRedoList( void ); /* Manipulation des flags */ - void SetRefreshReq( void ) { m_FlagRefreshReq = 1; } - void ClrRefreshReq( void ) { m_FlagRefreshReq = 0; } - void SetModify( void ) { m_FlagModified = 1; m_FlagSave = 0; } - void ClrModify( void ) { m_FlagModified = 0; m_FlagSave = 1; } - void SetSave( void ) { m_FlagSave = 1; } - void ClrSave( void ) { m_FlagSave = 0; } - int IsModify( void ) { return m_FlagModified & 1; } - int IsRefreshReq( void ) { return m_FlagRefreshReq & 1; } - int IsSave( void ) { return m_FlagSave & 1; } + void SetRefreshReq( void ) { m_FlagRefreshReq = 1; } + void ClrRefreshReq( void ) { m_FlagRefreshReq = 0; } + void SetModify( void ) { m_FlagModified = 1; m_FlagSave = 0; } + void ClrModify( void ) { m_FlagModified = 0; m_FlagSave = 1; } + void SetSave( void ) { m_FlagSave = 1; } + void ClrSave( void ) { m_FlagSave = 0; } + int IsModify( void ) { return m_FlagModified & 1; } + int IsRefreshReq( void ) { return m_FlagRefreshReq & 1; } + int IsSave( void ) { return m_FlagSave & 1; } + + /** + * Function SetCurItem + * sets the currently selected object, m_CurrentItem. + * This intentionally not inlined so we can set breakpoints on the + * activity easier in base_screen.cpp. + * @param current Any object derived from EDA_BaseStruct + */ + void SetCurItem( EDA_BaseStruct* current ); + EDA_BaseStruct* GetCurItem(); + + /* fonctions relatives au zoom */ int GetZoom( void ); /* retourne le coeff de zoom */ void SetZoom( int coeff ); /* ajuste le coeff de zoom a coeff */ diff --git a/include/wxstruct.h b/include/wxstruct.h index 544a4a041e..2e5b9837f3 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -11,6 +11,8 @@ #define eda_global extern #endif +#include <vector> + #include <wx/socket.h> #include "wx/log.h" #include "wx/config.h" @@ -352,7 +354,7 @@ public: virtual void OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) = 0; virtual void ReCreateMenuBar( void ); - PCB_SCREEN* GetScreen( void ) { return (PCB_SCREEN*) m_CurrentScreen; } + PCB_SCREEN* GetScreen( void ) { return (PCB_SCREEN*) m_CurrentScreen; } int BestZoom( void ); // Retourne le meilleur zoom void Show3D_Frame( wxCommandEvent& event ); @@ -502,6 +504,7 @@ public: /*****************************************************/ class WinEDA_PcbFrame : public WinEDA_BasePcbFrame { + public: WinEDAChoiceBox* m_SelLayerBox; WinEDAChoiceBox* m_SelTrackWidthBox; @@ -512,6 +515,13 @@ private: bool m_SelViaSizeBox_Changed; wxMenu* m_FilesMenu; +#if defined(DEBUG) + class COLLECTOR; + COLLECTOR* m_GeneralCollector; ///< while arrow icon tool + COLLECTOR* m_RatsModuleCollector; ///< while find1rats icon tool +#endif + + public: WinEDA_PcbFrame( wxWindow* father, WinEDA_App* parent, const wxString& title, const wxPoint& pos, const wxSize& size ); diff --git a/pcbnew/affiche.cpp b/pcbnew/affiche.cpp index 179fa62816..fe7d111605 100644 --- a/pcbnew/affiche.cpp +++ b/pcbnew/affiche.cpp @@ -1,6 +1,6 @@ - /**********************************************************/ - /* Routines d'affichage de parametres et caracteristiques */ - /**********************************************************/ +/**********************************************************/ +/* Routines d'affichage de parametres et caracteristiques */ +/**********************************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -15,361 +15,397 @@ /* Routines locales */ /*****************************************************************************/ -void Affiche_Infos_PCB_Texte(WinEDA_BasePcbFrame * frame, TEXTE_PCB* pt_texte) +void Affiche_Infos_PCB_Texte( WinEDA_BasePcbFrame* frame, TEXTE_PCB* pt_texte ) /*****************************************************************************/ + /* Affiche en bas d'ecran les caract du texte sur PCB - Entree : - pointeur de la description du texte -*/ + * Entree : + * pointeur de la description du texte + */ { -wxString msg; - - frame->MsgPanel->EraseMsgBox(); - if ( pt_texte == NULL ) return; + wxString msg; - if( pt_texte->m_StructType == TYPECOTATION ) - Affiche_1_Parametre(frame, 1,_("COTATION"),pt_texte->m_Text, DARKGREEN); + frame->MsgPanel->EraseMsgBox(); + if( pt_texte == NULL ) + return; - else - Affiche_1_Parametre(frame, 1,_("PCB Text"),pt_texte->m_Text, DARKGREEN); + if( pt_texte->m_StructType == TYPECOTATION ) + Affiche_1_Parametre( frame, 1, _( "COTATION" ), pt_texte->m_Text, DARKGREEN ); - Affiche_1_Parametre(frame, 28,_("Layer"), - ReturnPcbLayerName(pt_texte->m_Layer), - g_DesignSettings.m_LayerColor[pt_texte->m_Layer] & MASKCOLOR); + else + Affiche_1_Parametre( frame, 1, _( "PCB Text" ), pt_texte->m_Text, DARKGREEN ); - Affiche_1_Parametre(frame, 36,_("Mirror"),wxEmptyString,GREEN) ; - if( (pt_texte->m_Miroir & 1) ) - Affiche_1_Parametre(frame, -1,wxEmptyString,_("No"), DARKGREEN) ; - else Affiche_1_Parametre(frame, -1,wxEmptyString,_("Yes"), DARKGREEN) ; + Affiche_1_Parametre( frame, 28, _( "Layer" ), + ReturnPcbLayerName( pt_texte->m_Layer ), + g_DesignSettings.m_LayerColor[pt_texte->m_Layer] & MASKCOLOR ); + Affiche_1_Parametre( frame, 36, _( "Mirror" ), wxEmptyString, GREEN ); + if( (pt_texte->m_Miroir & 1) ) + Affiche_1_Parametre( frame, -1, wxEmptyString, _( "No" ), DARKGREEN ); + else + Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Yes" ), DARKGREEN ); - msg.Printf( wxT("%.1f"),(float)pt_texte->m_Orient/10 ); - Affiche_1_Parametre(frame, 43,_("Orient"),msg, DARKGREEN) ; + msg.Printf( wxT( "%.1f" ), (float) pt_texte->m_Orient / 10 ); + Affiche_1_Parametre( frame, 43, _( "Orient" ), msg, DARKGREEN ); - valeur_param(pt_texte->m_Width, msg) ; - Affiche_1_Parametre(frame, 50,_("Width"),msg,MAGENTA) ; + valeur_param( pt_texte->m_Width, msg ); + Affiche_1_Parametre( frame, 50, _( "Width" ), msg, MAGENTA ); - valeur_param(pt_texte->m_Size.x, msg) ; - Affiche_1_Parametre(frame, 60, _("H Size"),msg,RED) ; + valeur_param( pt_texte->m_Size.x, msg ); + Affiche_1_Parametre( frame, 60, _( "H Size" ), msg, RED ); - valeur_param(pt_texte->m_Size.y, msg); - Affiche_1_Parametre(frame, 70,_("V Size"),msg,RED) ; + valeur_param( pt_texte->m_Size.y, msg ); + Affiche_1_Parametre( frame, 70, _( "V Size" ), msg, RED ); } + /************************************************************************/ -void Affiche_Infos_E_Texte(WinEDA_BasePcbFrame * frame, MODULE* Module, - TEXTE_MODULE* pt_texte) +void Affiche_Infos_E_Texte( WinEDA_BasePcbFrame* frame, MODULE* Module, + TEXTE_MODULE* pt_texte ) /************************************************************************/ + /* Affiche en bas d'ecran les caract du texte sur empreinte - Entree : - pointeur de description sur le module - pointeur de la description du texte -*/ + * Entree : + * pointeur de description sur le module + * pointeur de la description du texte + */ { -wxString text_type_msg[3] = {_("Ref."),_("Value"),_("Text")}; -wxString msg, Line; -int ii; + wxString msg, Line; + int ii; - frame->MsgPanel->EraseMsgBox(); + static const wxString text_type_msg[3] = { + _( "Ref." ), _( "Value" ), _( "Text" ) }; + + frame->MsgPanel->EraseMsgBox(); - Line = Module->m_Reference->m_Text; - Affiche_1_Parametre(frame, 1, _("Module"), Line, DARKCYAN) ; + Line = Module->m_Reference->m_Text; + Affiche_1_Parametre( frame, 1, _( "Module" ), Line, DARKCYAN ); - Line = pt_texte->m_Text; - Affiche_1_Parametre(frame, 10,_("Text"),Line,YELLOW) ; + Line = pt_texte->m_Text; + Affiche_1_Parametre( frame, 10, _( "Text" ), Line, YELLOW ); - ii = pt_texte->m_Type; if (ii > 2) ii = 2; - Affiche_1_Parametre(frame, 20,_("Type"),text_type_msg[ii], DARKGREEN) ; + ii = pt_texte->m_Type; + if( ii > 2 ) + ii = 2; + + Affiche_1_Parametre( frame, 20, _( "Type" ), text_type_msg[ii], DARKGREEN ); - Affiche_1_Parametre(frame, 25,_("Display"),wxEmptyString, DARKGREEN); - if(pt_texte->m_NoShow) - Affiche_1_Parametre(frame, -1,wxEmptyString, _("No"), DARKGREEN); - else Affiche_1_Parametre(frame, -1,wxEmptyString, _("Yes"), DARKGREEN); + Affiche_1_Parametre( frame, 25, _( "Display" ), wxEmptyString, DARKGREEN ); + if( pt_texte->m_NoShow ) + Affiche_1_Parametre( frame, -1, wxEmptyString, _( "No" ), DARKGREEN ); + else + Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Yes" ), DARKGREEN ); - ii = pt_texte->m_Layer; - if ( ii <= 28) - Affiche_1_Parametre(frame, 28,_("Layer"),ReturnPcbLayerName(ii), DARKGREEN); - else - { - msg.Printf( wxT("%d"), ii); - Affiche_1_Parametre(frame, 28,_("Layer"), msg, DARKGREEN) ; - } + ii = pt_texte->m_Layer; + if( ii <= 28 ) + Affiche_1_Parametre( frame, 28, _( "Layer" ), ReturnPcbLayerName( ii ), DARKGREEN ); + else + { + msg.Printf( wxT( "%d" ), ii ); + Affiche_1_Parametre( frame, 28, _( "Layer" ), msg, DARKGREEN ); + } - msg = wxT(" Yes"); - if( (pt_texte->m_Miroir & 1) ) msg = wxT(" No"); - Affiche_1_Parametre(frame, 36,_("Mirror"),msg, DARKGREEN) ; + msg = wxT( " Yes" ); + if( pt_texte->m_Miroir & 1 ) + msg = wxT( " No" ); + + Affiche_1_Parametre( frame, 36, _( "Mirror" ), msg, DARKGREEN ); - msg.Printf( wxT("%.1f"),(float)pt_texte->m_Orient / 10 ); - Affiche_1_Parametre(frame, 42,_("Orient"),msg, DARKGREEN) ; + msg.Printf( wxT( "%.1f" ), (float) pt_texte->m_Orient / 10 ); + Affiche_1_Parametre( frame, 42, _( "Orient" ), msg, DARKGREEN ); - valeur_param(pt_texte->m_Width, msg) ; - Affiche_1_Parametre(frame, 48,_("Width"),msg, DARKGREEN) ; + valeur_param( pt_texte->m_Width, msg ); + Affiche_1_Parametre( frame, 48, _( "Width" ), msg, DARKGREEN ); - valeur_param(pt_texte->m_Size.x,msg) ; - Affiche_1_Parametre(frame, 56,_("H Size"),msg,RED) ; - - valeur_param(pt_texte->m_Size.y,msg); - Affiche_1_Parametre(frame, 64,_("V Size"),msg,RED) ; + valeur_param( pt_texte->m_Size.x, msg ); + Affiche_1_Parametre( frame, 56, _( "H Size" ), msg, RED ); + valeur_param( pt_texte->m_Size.y, msg ); + Affiche_1_Parametre( frame, 64, _( "V Size" ), msg, RED ); } - /*********************************************************************/ -void Affiche_Infos_Piste(WinEDA_BasePcbFrame * frame, TRACK * pt_piste) +void Affiche_Infos_Piste( WinEDA_BasePcbFrame* frame, TRACK* pt_piste ) /********************************************************************/ + /* Affiche les caract principales d'un segment de piste en bas d'ecran -*/ + */ { -wxString msg; -int text_pos; - - frame->MsgPanel->EraseMsgBox(); + wxString msg; + int text_pos; - switch(pt_piste->m_StructType) - { - case TYPEVIA: - msg = g_ViaType_Name[pt_piste->m_Shape & 255]; - break; + frame->MsgPanel->EraseMsgBox(); - case TYPETRACK: - msg = _("Track") ; - break; + switch( pt_piste->m_StructType ) + { + case TYPEVIA: + msg = g_ViaType_Name[pt_piste->m_Shape & 255]; + break; - case TYPEZONE: - msg = _("Zone"); break; + case TYPETRACK: + msg = _( "Track" ); + break; - default: - msg = wxT("????"); break; - } - text_pos = 1; - Affiche_1_Parametre(frame, text_pos,_("Type"),msg, DARKCYAN); + case TYPEZONE: + msg = _( "Zone" ); break; - /* Affiche NetName pour les segments de piste type cuivre */ - text_pos += 15; - if( ( pt_piste->m_StructType == TYPETRACK ) || - ( pt_piste->m_StructType == TYPEZONE ) || - ( pt_piste->m_StructType == TYPEVIA ) ) - { - EQUIPOT * equipot = GetEquipot( frame->m_Pcb, pt_piste->m_NetCode); - if ( equipot ) - { - msg = equipot->m_Netname; - } - else msg = wxT("<noname>"); - Affiche_1_Parametre(frame, text_pos,_("NetName"),msg,RED) ; + default: + msg = wxT( "????" ); break; + } - /* Affiche net code :*/ - msg.Printf( wxT("%d .%d"),pt_piste->m_NetCode, pt_piste->m_Sous_Netcode); - text_pos += 18; - Affiche_1_Parametre(frame, text_pos,_("NetCode"),msg,RED) ; - } + text_pos = 1; + Affiche_1_Parametre( frame, text_pos, _( "Type" ), msg, DARKCYAN ); - else - { - Affiche_1_Parametre(frame, text_pos, _("Segment"),wxEmptyString,RED) ; - if(pt_piste->m_Shape == S_CIRCLE) - Affiche_1_Parametre(frame, -1,wxEmptyString,_("Circle"),RED) ; - else Affiche_1_Parametre(frame, -1,wxEmptyString,_("Standard"),RED) ; - } + /* Affiche NetName pour les segments de piste type cuivre */ + text_pos += 15; + if( ( pt_piste->m_StructType == TYPETRACK ) + || ( pt_piste->m_StructType == TYPEZONE ) + || ( pt_piste->m_StructType == TYPEVIA ) ) + { + EQUIPOT* equipot = GetEquipot( frame->m_Pcb, pt_piste->m_NetCode ); + if( equipot ) + { + msg = equipot->m_Netname; + } + else + msg = wxT( "<noname>" ); + Affiche_1_Parametre( frame, text_pos, _( "NetName" ), msg, RED ); + + /* Affiche net code :*/ + msg.Printf( wxT( "%d .%d" ), pt_piste->m_NetCode, pt_piste->m_Sous_Netcode ); + text_pos += 18; + Affiche_1_Parametre( frame, text_pos, _( "NetCode" ), msg, RED ); + } + else + { + Affiche_1_Parametre( frame, text_pos, _( "Segment" ), wxEmptyString, RED ); + if( pt_piste->m_Shape == S_CIRCLE ) + Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Circle" ), RED ); + else + Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Standard" ), RED ); + } - /* Affiche les flags Status piste */ - msg = wxT(". . "); - if(pt_piste->GetState(SEGM_FIXE) ) msg[0] = 'F'; - if(pt_piste->GetState(SEGM_AR) ) msg[2] = 'A'; - text_pos = 42; - Affiche_1_Parametre(frame, text_pos,_("Stat"), msg,MAGENTA); + /* Affiche les flags Status piste */ + msg = wxT( ". . " ); + if( pt_piste->GetState( SEGM_FIXE ) ) + msg[0] = 'F'; + + if( pt_piste->GetState( SEGM_AR ) ) + msg[2] = 'A'; + + text_pos = 42; + Affiche_1_Parametre( frame, text_pos, _( "Stat" ), msg, MAGENTA ); - /* Affiche Layer(s) */ - if ( pt_piste->m_StructType == TYPEVIA) - { - SEGVIA * Via = (SEGVIA *) pt_piste; - int top_layer, bottom_layer; - Via->ReturnLayerPair(&top_layer, &bottom_layer); - msg = ReturnPcbLayerName(top_layer, TRUE) + wxT("/") + ReturnPcbLayerName(bottom_layer, TRUE); - } - else msg = ReturnPcbLayerName(pt_piste->m_Layer); + /* Affiche Layer(s) */ + if( pt_piste->m_StructType == TYPEVIA ) + { + SEGVIA* Via = (SEGVIA*) pt_piste; + int top_layer, bottom_layer; + + Via->ReturnLayerPair( &top_layer, &bottom_layer ); + msg = ReturnPcbLayerName( top_layer, TRUE ) + wxT( "/" ) + + ReturnPcbLayerName( bottom_layer, TRUE ); + } + else + msg = ReturnPcbLayerName( pt_piste->m_Layer ); - text_pos += 5; - Affiche_1_Parametre(frame, text_pos, _("Layer"), msg, BROWN) ; + text_pos += 5; + Affiche_1_Parametre( frame, text_pos, _( "Layer" ), msg, BROWN ); - /* Affiche Epaisseur */ - valeur_param((unsigned)(pt_piste->m_Width), msg) ; - text_pos += 11; - if (pt_piste->m_StructType == TYPEVIA ) // Display Diam and Drill values - { - Affiche_1_Parametre(frame, text_pos,_("Diam"), msg, DARKCYAN); + /* Affiche Epaisseur */ + valeur_param( (unsigned) (pt_piste->m_Width), msg ); + text_pos += 11; + + if( pt_piste->m_StructType == TYPEVIA ) // Display Diam and Drill values + { + Affiche_1_Parametre( frame, text_pos, _( "Diam" ), msg, DARKCYAN ); - int drill_value = (pt_piste->m_Drill >= 0 ) ? - pt_piste->m_Drill : g_DesignSettings.m_ViaDrill; - valeur_param((unsigned)drill_value, msg); - text_pos += 8; - wxString title = _("Drill"); - if ( g_DesignSettings.m_ViaDrill >= 0 ) title += wxT("*"); - Affiche_1_Parametre(frame, text_pos,_("Drill"),msg, RED); - } - else Affiche_1_Parametre(frame, text_pos,_("Width"),msg, DARKCYAN) ; + int drill_value = (pt_piste->m_Drill >= 0 ) ? + pt_piste->m_Drill : g_DesignSettings.m_ViaDrill; + valeur_param( (unsigned) drill_value, msg ); + + text_pos += 8; + wxString title = _( "Drill" ); + + if( g_DesignSettings.m_ViaDrill >= 0 ) + title += wxT( "*" ); + + Affiche_1_Parametre( frame, text_pos, _( "Drill" ), msg, RED ); + } + else + Affiche_1_Parametre( frame, text_pos, _( "Width" ), msg, DARKCYAN ); } + /************************************************************/ -void Affiche_Infos_DrawSegment(WinEDA_BasePcbFrame * frame, - DRAWSEGMENT * DrawSegment) +void Affiche_Infos_DrawSegment( WinEDA_BasePcbFrame* frame, + DRAWSEGMENT* DrawSegment ) /************************************************************/ /* Affiche les caract principales d'un segment type drawind PCB en bas d'ecran */ { -int itype; -wxString msg; - - frame->MsgPanel->EraseMsgBox(); + int itype; + wxString msg; - itype = DrawSegment->m_Type & 0x0F; + frame->MsgPanel->EraseMsgBox(); - msg = wxT("DRAWING"); - if( DrawSegment->m_StructType == TYPECOTATION ) msg = wxT("COTATION"); + itype = DrawSegment->m_Type & 0x0F; - Affiche_1_Parametre(frame, 1,_("Type"),msg, DARKCYAN) ; + msg = wxT( "DRAWING" ); + if( DrawSegment->m_StructType == TYPECOTATION ) + msg = wxT( "COTATION" ); - Affiche_1_Parametre(frame, 16,_("Shape"),wxEmptyString,RED) ; - if(DrawSegment->m_Shape == S_CIRCLE) - Affiche_1_Parametre(frame, -1,wxEmptyString,_("Circle"),RED) ; - else if (DrawSegment->m_Shape == S_ARC) - { - Affiche_1_Parametre(frame, -1,wxEmptyString, _(" Arc "),RED) ; - msg.Printf( wxT("%d"),DrawSegment->m_Angle); - Affiche_1_Parametre(frame, 32, wxT(" l.arc "), msg,RED) ; - } - else Affiche_1_Parametre(frame, -1, wxEmptyString, _("Segment"),RED) ; + Affiche_1_Parametre( frame, 1, _( "Type" ), msg, DARKCYAN ); - Affiche_1_Parametre(frame, 48, _("Layer"),ReturnPcbLayerName(DrawSegment->m_Layer),BROWN) ; + Affiche_1_Parametre( frame, 16, _( "Shape" ), wxEmptyString, RED ); + + if( DrawSegment->m_Shape == S_CIRCLE ) + Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Circle" ), RED ); + + else if( DrawSegment->m_Shape == S_ARC ) + { + Affiche_1_Parametre( frame, -1, wxEmptyString, _( " Arc " ), RED ); + msg.Printf( wxT( "%d" ), DrawSegment->m_Angle ); + Affiche_1_Parametre( frame, 32, wxT( " l.arc " ), msg, RED ); + } + else + Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Segment" ), RED ); - /* Affiche Epaisseur */ - valeur_param((unsigned)(DrawSegment->m_Width), msg) ; - Affiche_1_Parametre(frame, 60,_("Width"), msg, DARKCYAN) ; + Affiche_1_Parametre( frame, 48, _( "Layer" ), ReturnPcbLayerName( + DrawSegment->m_Layer ), BROWN ); + + /* Affiche Epaisseur */ + valeur_param( (unsigned) (DrawSegment->m_Width), msg ); + Affiche_1_Parametre( frame, 60, _( "Width" ), msg, DARKCYAN ); } /*****************************************************************************/ -void Affiche_Infos_Segment_Module(WinEDA_BasePcbFrame * frame, - MODULE* Module,EDGE_MODULE* pt_edge) +void Affiche_Infos_Segment_Module( WinEDA_BasePcbFrame* frame, + MODULE* Module, EDGE_MODULE* pt_edge ) /*****************************************************************************/ + /* Affiche en bas d'ecran les caract du Segment contour d'un module - Les parametres du module doivent etre a jour*/ + * Les parametres du module doivent etre a jour*/ { -wxString bufcar; + wxString bufcar; - if(Module == NULL) return; + if( Module == NULL ) + return; - frame->MsgPanel->EraseMsgBox(); + frame->MsgPanel->EraseMsgBox(); - Affiche_1_Parametre(frame, 1,_("Seg"),wxEmptyString, DARKCYAN) ; - Affiche_1_Parametre(frame, 5 ,_("Module"),Module->m_Reference->m_Text, DARKCYAN) ; + Affiche_1_Parametre( frame, 1, _( "Seg" ), wxEmptyString, DARKCYAN ); + Affiche_1_Parametre( frame, 5, _( "Module" ), Module->m_Reference->m_Text, DARKCYAN ); - Affiche_1_Parametre(frame, 14,_("Value"),Module->m_Value->m_Text, BLUE) ; + Affiche_1_Parametre( frame, 14, _( "Value" ), Module->m_Value->m_Text, BLUE ); - bufcar.Printf( wxT("%8.8lX"), Module->m_TimeStamp) ; - Affiche_1_Parametre(frame, 24,_("TimeStamp"),bufcar,BROWN) ; + bufcar.Printf( wxT( "%8.8lX" ), Module->m_TimeStamp ); + Affiche_1_Parametre( frame, 24, _( "TimeStamp" ), bufcar, BROWN ); - Affiche_1_Parametre(frame, 34,_("Mod Layer"),ReturnPcbLayerName(Module->m_Layer),RED); + Affiche_1_Parametre( frame, 34, _( "Mod Layer" ), ReturnPcbLayerName( Module->m_Layer ), RED ); - Affiche_1_Parametre(frame, 44,_("Seg Layer"), - ReturnPcbLayerName(Module->m_Layer),RED) ; + Affiche_1_Parametre( frame, 44, _( "Seg Layer" ), + ReturnPcbLayerName( Module->m_Layer ), RED ); - valeur_param(pt_edge->m_Width,bufcar); - Affiche_1_Parametre(frame, 54,_("Width"), bufcar,BLUE); + valeur_param( pt_edge->m_Width, bufcar ); + Affiche_1_Parametre( frame, 54, _( "Width" ), bufcar, BLUE ); } /*********************************************************/ -void Affiche_Infos_Status_Pcb(WinEDA_BasePcbFrame * frame) +void Affiche_Infos_Status_Pcb( WinEDA_BasePcbFrame* frame ) /*********************************************************/ /* Affiche l'etat du PCB : nb de pads, nets , connexions.. */ -#define POS_AFF_NBPADS 1 -#define POS_AFF_NBVIAS 8 -#define POS_AFF_NBNODES 16 -#define POS_AFF_NBLINKS 24 -#define POS_AFF_NBNETS 32 -#define POS_AFF_NBCONNECT 40 +#define POS_AFF_NBPADS 1 +#define POS_AFF_NBVIAS 8 +#define POS_AFF_NBNODES 16 +#define POS_AFF_NBLINKS 24 +#define POS_AFF_NBNETS 32 +#define POS_AFF_NBCONNECT 40 #define POS_AFF_NBNOCONNECT 48 { -int nb_vias = 0, ii; -EDA_BaseStruct * Struct; -wxString txt; + int nb_vias = 0, ii; + EDA_BaseStruct* Struct; + wxString txt; - frame->MsgPanel->EraseMsgBox(); + frame->MsgPanel->EraseMsgBox(); - txt.Printf( wxT("%d"),frame->m_Pcb->m_NbPads); - Affiche_1_Parametre(frame, POS_AFF_NBPADS,_("Pads"),txt, DARKGREEN) ; + txt.Printf( wxT( "%d" ), frame->m_Pcb->m_NbPads ); + Affiche_1_Parametre( frame, POS_AFF_NBPADS, _( "Pads" ), txt, DARKGREEN ); - for( ii= 0, Struct = frame->m_Pcb->m_Track; Struct != NULL; Struct = Struct->Pnext) - { - ii++; - if(Struct->m_StructType == TYPEVIA) nb_vias++ ; - } + for( ii = 0, Struct = frame->m_Pcb->m_Track; Struct != NULL; Struct = Struct->Pnext ) + { + ii++; + if( Struct->m_StructType == TYPEVIA ) + nb_vias++; + } - txt.Printf( wxT("%d"),nb_vias); - Affiche_1_Parametre(frame, POS_AFF_NBVIAS,_("Vias"),txt, DARKGREEN) ; + txt.Printf( wxT( "%d" ), nb_vias ); + Affiche_1_Parametre( frame, POS_AFF_NBVIAS, _( "Vias" ), txt, DARKGREEN ); - txt.Printf( wxT("%d"),frame->m_Pcb->GetNumNodes() ); - Affiche_1_Parametre(frame, POS_AFF_NBNODES,_("Nodes"),txt, DARKCYAN) ; + txt.Printf( wxT( "%d" ), frame->m_Pcb->GetNumNodes() ); + Affiche_1_Parametre( frame, POS_AFF_NBNODES, _( "Nodes" ), txt, DARKCYAN ); - txt.Printf( wxT("%d"),frame->m_Pcb->m_NbLinks); - Affiche_1_Parametre(frame, POS_AFF_NBLINKS,_("Links"),txt, DARKGREEN) ; + txt.Printf( wxT( "%d" ), frame->m_Pcb->m_NbLinks ); + Affiche_1_Parametre( frame, POS_AFF_NBLINKS, _( "Links" ), txt, DARKGREEN ); - txt.Printf( wxT("%d"),frame->m_Pcb->m_NbNets); - Affiche_1_Parametre(frame, POS_AFF_NBNETS,_("Nets"),txt,RED) ; + txt.Printf( wxT( "%d" ), frame->m_Pcb->m_NbNets ); + Affiche_1_Parametre( frame, POS_AFF_NBNETS, _( "Nets" ), txt, RED ); - txt.Printf( wxT("%d"),frame->m_Pcb->m_NbLinks - frame->m_Pcb->GetNumNoconnect()); - Affiche_1_Parametre(frame, POS_AFF_NBCONNECT,_("Connect"),txt, DARKGREEN) ; + txt.Printf( wxT( "%d" ), frame->m_Pcb->m_NbLinks - frame->m_Pcb->GetNumNoconnect() ); + Affiche_1_Parametre( frame, POS_AFF_NBCONNECT, _( "Connect" ), txt, DARKGREEN ); - txt.Printf( wxT("%d"),frame->m_Pcb->GetNumNoconnect()); - Affiche_1_Parametre(frame, POS_AFF_NBNOCONNECT,_("NoConn"),txt,BLUE) ; + txt.Printf( wxT( "%d" ), frame->m_Pcb->GetNumNoconnect() ); + Affiche_1_Parametre( frame, POS_AFF_NBNOCONNECT, _( "NoConn" ), txt, BLUE ); } + /*******************************************************************/ -void Affiche_Infos_Equipot(int netcode, WinEDA_BasePcbFrame * frame) +void Affiche_Infos_Equipot( int netcode, WinEDA_BasePcbFrame* frame ) /*******************************************************************/ /* Affiche les infos relatives a une equipot: nb de pads, nets , connexions.. */ { -int nb_vias = 0, ii; -EDA_BaseStruct * Struct; -wxString txt; -MODULE * module; -D_PAD * pad; -EQUIPOT * equipot; + int nb_vias = 0, ii; + EDA_BaseStruct* Struct; + wxString txt; + MODULE* module; + D_PAD* pad; + EQUIPOT* equipot; - frame->MsgPanel->EraseMsgBox(); + frame->MsgPanel->EraseMsgBox(); - equipot = GetEquipot(frame->m_Pcb, netcode); - if ( equipot ) - Affiche_1_Parametre(frame, 1,_("Net Name"),equipot->m_Netname,RED) ; - else - Affiche_1_Parametre(frame, 1,_("No Net (not connected)"), wxEmptyString, RED) ; + equipot = GetEquipot( frame->m_Pcb, netcode ); + if( equipot ) + Affiche_1_Parametre( frame, 1, _( "Net Name" ), equipot->m_Netname, RED ); + else + Affiche_1_Parametre( frame, 1, _( "No Net (not connected)" ), wxEmptyString, RED ); - txt.Printf( wxT("%d"), netcode); - Affiche_1_Parametre(frame, 30,_("Net Code"),txt,RED) ; + txt.Printf( wxT( "%d" ), netcode ); + Affiche_1_Parametre( frame, 30, _( "Net Code" ), txt, RED ); - for ( ii = 0, module = frame->m_Pcb->m_Modules; module != 0; - module = (MODULE*)module->Pnext) - { - for ( pad = module->m_Pads;pad != 0; pad = (D_PAD*) pad->Pnext) - { - if ( pad->m_NetCode == netcode ) ii++; - } - } + for( ii = 0, module = frame->m_Pcb->m_Modules; module != 0; + module = (MODULE*) module->Pnext ) + { + for( pad = module->m_Pads; pad != 0; pad = (D_PAD*) pad->Pnext ) + { + if( pad->m_NetCode == netcode ) + ii++; + } + } - txt.Printf( wxT("%d"),ii); - Affiche_1_Parametre(frame, 40,_("Pads"),txt, DARKGREEN) ; + txt.Printf( wxT( "%d" ), ii ); + Affiche_1_Parametre( frame, 40, _( "Pads" ), txt, DARKGREEN ); - for( ii= 0, Struct = frame->m_Pcb->m_Track; Struct != NULL; Struct = Struct->Pnext) - { - ii++; - if( Struct->m_StructType == TYPEVIA ) - if ( ((SEGVIA*)Struct)->m_NetCode == netcode ) nb_vias++ ; - } + for( ii = 0, Struct = frame->m_Pcb->m_Track; Struct != NULL; Struct = Struct->Pnext ) + { + ii++; + if( Struct->m_StructType == TYPEVIA ) + if( ( (SEGVIA*) Struct )->m_NetCode == netcode ) + nb_vias++; + } - txt.Printf( wxT("%d"),nb_vias); - Affiche_1_Parametre(frame, 50,_("Vias"),txt, BLUE) ; + txt.Printf( wxT( "%d" ), nb_vias ); + Affiche_1_Parametre( frame, 50, _( "Vias" ), txt, BLUE ); } - - diff --git a/pcbnew/attribut.cpp b/pcbnew/attribut.cpp index 46feacfb55..4a5f8c78ad 100644 --- a/pcbnew/attribut.cpp +++ b/pcbnew/attribut.cpp @@ -1,6 +1,6 @@ - /******************************************/ - /* Track editing: attribute flags edition */ - /******************************************/ +/******************************************/ +/* Track editing: attribute flags edition */ +/******************************************/ #include "fctsys.h" @@ -12,79 +12,86 @@ /*****************************************************************************/ -void WinEDA_PcbFrame::Attribut_Segment(TRACK * track, wxDC * DC, bool Flag_On) +void WinEDA_PcbFrame::Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On ) /*****************************************************************************/ + /* Attribute change for 1 track segment. -Attributes are -SEGM_FIXE protection against global delete -SEGM_AR AutoRouted segment -*/ + * Attributes are + * SEGM_FIXE protection against global delete + * SEGM_AR AutoRouted segment + */ { - if ( track == NULL ) return; - - GetScreen()->SetModify(); - DrawPanel->CursorOff(DC); // Erase cursor shape - track->SetState(SEGM_FIXE, Flag_On); - track->Draw(DrawPanel, DC, GR_OR | GR_SURBRILL) ; - DrawPanel->CursorOn(DC); // Display cursor shape - Affiche_Infos_Piste(this, track); + if( track == NULL ) + return; + + GetScreen()->SetModify(); + DrawPanel->CursorOff( DC ); // Erase cursor shape + track->SetState( SEGM_FIXE, Flag_On ); + track->Draw( DrawPanel, DC, GR_OR | GR_SURBRILL ); + DrawPanel->CursorOn( DC ); // Display cursor shape + Affiche_Infos_Piste( this, track ); } /***************************************************************************/ -void WinEDA_PcbFrame::Attribut_Track(TRACK * track, wxDC * DC, bool Flag_On) +void WinEDA_PcbFrame::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On ) /***************************************************************************/ /* Attribute change for an entire track */ { -TRACK *Track ; -int nb_segm; + TRACK* Track; + int nb_segm; - if( (track == NULL ) || (track->m_StructType == TYPEZONE) ) return; + if( (track == NULL ) || (track->m_StructType == TYPEZONE) ) + return; - DrawPanel->CursorOff(DC); // Erase cursor shape - Track = Marque_Une_Piste(this, DC, track, & nb_segm, GR_OR | GR_SURBRILL) ; + DrawPanel->CursorOff( DC ); // Erase cursor shape + Track = Marque_Une_Piste( this, DC, track, &nb_segm, GR_OR | GR_SURBRILL ); - for( ; (Track != NULL) && (nb_segm > 0) ; nb_segm-- ) - { - Track->SetState(SEGM_FIXE, Flag_On); - Track->SetState(BUSY,OFF); - Track = (TRACK*)Track->Pnext; - } - DrawPanel->CursorOn(DC); // Display cursor shape + for( ; (Track != NULL) && (nb_segm > 0); nb_segm-- ) + { + Track->SetState( SEGM_FIXE, Flag_On ); + Track->SetState( BUSY, OFF ); + Track = (TRACK*) Track->Pnext; + } - GetScreen()->SetModify(); + DrawPanel->CursorOn( DC ); // Display cursor shape + + GetScreen()->SetModify(); } + /***********************************************************************/ -void WinEDA_PcbFrame::Attribut_net(wxDC * DC, int net_code, bool Flag_On) +void WinEDA_PcbFrame::Attribut_net( wxDC* DC, int net_code, bool Flag_On ) /***********************************************************************/ + /* Modify the flag SEGM_FIXE according to Flag_On value, - for all the segments related to net_code. - if net_code < 0 all the segments are modified. -*/ + * for all the segments related to net_code. + * if net_code < 0 all the segments are modified. + */ { -TRACK *Track = m_Pcb->m_Track; + TRACK* Track = m_Pcb->m_Track; - /* search the first segment for the selected net_code */ - if ( net_code >= 0 ) - { - for ( ;Track != NULL; Track = (TRACK*) Track->Pnext ) - { - if ( net_code == Track->m_NetCode ) break; - } - } + /* search the first segment for the selected net_code */ + if( net_code >= 0 ) + { + for( ; Track != NULL; Track = (TRACK*) Track->Pnext ) + { + if( net_code == Track->m_NetCode ) + break; + } + } - DrawPanel->CursorOff(DC); // Erase cursor shape - while ( Track ) /* Flag change */ - { - if ( (net_code >= 0 ) && (net_code != Track->m_NetCode) ) break; - GetScreen()->SetModify(); - Track->SetState(SEGM_FIXE, Flag_On); - Track->Draw(DrawPanel, DC, GR_OR | GR_SURBRILL); - Track = Track->Next(); - } - DrawPanel->CursorOn(DC); // Display cursor shape - GetScreen()->SetModify(); + DrawPanel->CursorOff( DC ); // Erase cursor shape + while( Track ) /* Flag change */ + { + if( (net_code >= 0 ) && (net_code != Track->m_NetCode) ) + break; + GetScreen()->SetModify(); + Track->SetState( SEGM_FIXE, Flag_On ); + Track->Draw( DrawPanel, DC, GR_OR | GR_SURBRILL ); + Track = Track->Next(); + } + + DrawPanel->CursorOn( DC ); // Display cursor shape + GetScreen()->SetModify(); } - - diff --git a/pcbnew/automove.cpp b/pcbnew/automove.cpp index d62ef2d0ea..02f86b229b 100644 --- a/pcbnew/automove.cpp +++ b/pcbnew/automove.cpp @@ -1,9 +1,9 @@ - /****************************************************************/ - /* Routines de deplacement automatique et rotation des MODULES */ - /* routines et menu d'autoplacement */ - /****************************************************************/ +/****************************************************************/ +/* Routines de deplacement automatique et rotation des MODULES */ +/* routines et menu d'autoplacement */ +/****************************************************************/ - /* Fichier automove.cpp */ +/* Fichier automove.cpp */ #include "fctsys.h" #include "gr_basic.h" @@ -19,387 +19,414 @@ /* variables locales */ typedef enum { - FIXE_MODULE, - FREE_MODULE, - FIXE_ALL_MODULES, - FREE_ALL_MODULES - } SelectFixeFct; + FIXE_MODULE, + FREE_MODULE, + FIXE_ALL_MODULES, + FREE_ALL_MODULES +} SelectFixeFct; /* Fonctions locales */ -static int tri_modules(MODULE ** pt_ref, MODULE ** pt_compare); +static int tri_modules( MODULE** pt_ref, MODULE** pt_compare ); /* Variables locales */ -wxString ModulesMaskSelection = wxT("*"); -int ModulesNewOrient; +wxString ModulesMaskSelection = wxT( "*" ); +int ModulesNewOrient; /******************************************************/ -void WinEDA_PcbFrame::AutoPlace(wxCommandEvent& event) +void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event ) /******************************************************/ + /* Traite les selections d'outils et les commandes appelees du menu POPUP -*/ + */ { -int id = event.GetId(); -wxPoint pos; -wxClientDC dc(DrawPanel); -bool on_state; + int id = event.GetId(); + wxPoint pos; + wxClientDC dc( DrawPanel ); + bool on_state; - if ( m_HToolBar == NULL ) return; + if( m_HToolBar == NULL ) + return; - DrawPanel->PrepareGraphicContext(&dc); + DrawPanel->PrepareGraphicContext( &dc ); - wxGetMousePosition(&pos.x, &pos.y); + wxGetMousePosition( &pos.x, &pos.y ); - switch ( id ) // Arret eventuel de la commande de d�placement en cours - { - case ID_POPUP_CANCEL_CURRENT_COMMAND: - if( DrawPanel->ManageCurseur && - DrawPanel->ForceCloseManageCurseur ) - { - DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); - } - break; + switch( id ) // Arret eventuel de la commande de d�placement en cours + { + case ID_POPUP_CANCEL_CURRENT_COMMAND: + if( DrawPanel->ManageCurseur + && DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); + } + break; - default: // Arret de la commande de d�placement en cours - if( DrawPanel->ManageCurseur && - DrawPanel->ForceCloseManageCurseur ) - { - DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); - } - m_ID_current_state = 0; - DisplayToolMsg(wxEmptyString); - DrawPanel->SetCursor(wxCursor(wxCURSOR_ARROW) ); - break; - } + default: // Arret de la commande de d�placement en cours + if( DrawPanel->ManageCurseur + && DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); + } + m_ID_current_state = 0; + DisplayToolMsg( wxEmptyString ); + DrawPanel->SetCursor( wxCursor( wxCURSOR_ARROW ) ); + break; + } - /* Erase rastnest if needed */ - if(g_Show_Ratsnest) DrawGeneralRatsnest(&dc); - m_Pcb->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST; + /* Erase rastnest if needed */ + if( g_Show_Ratsnest ) + DrawGeneralRatsnest( &dc ); + m_Pcb->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST; - switch ( id ) // Traitement des commandes - { - case ID_TOOLBARH_PCB_AUTOPLACE: - on_state = m_HToolBar->GetToolState(ID_TOOLBARH_PCB_AUTOPLACE); - if ( on_state ) - { - m_HToolBar->ToggleTool(ID_TOOLBARH_PCB_AUTOROUTE, FALSE); - m_HTOOL_current_state = ID_TOOLBARH_PCB_AUTOPLACE; - } - else m_HTOOL_current_state = 0; - break; + switch( id ) // Traitement des commandes + { + case ID_TOOLBARH_PCB_AUTOPLACE: + on_state = m_HToolBar->GetToolState( ID_TOOLBARH_PCB_AUTOPLACE ); + if( on_state ) + { + m_HToolBar->ToggleTool( ID_TOOLBARH_PCB_AUTOROUTE, FALSE ); + m_HTOOL_current_state = ID_TOOLBARH_PCB_AUTOPLACE; + } + else + m_HTOOL_current_state = 0; + break; - case ID_TOOLBARH_PCB_AUTOROUTE: - on_state = m_HToolBar->GetToolState(ID_TOOLBARH_PCB_AUTOROUTE); - if ( on_state ) - { - m_HToolBar->ToggleTool(ID_TOOLBARH_PCB_AUTOPLACE, FALSE); - m_HTOOL_current_state = ID_TOOLBARH_PCB_AUTOROUTE; - } - else m_HTOOL_current_state = 0; - break; + case ID_TOOLBARH_PCB_AUTOROUTE: + on_state = m_HToolBar->GetToolState( ID_TOOLBARH_PCB_AUTOROUTE ); + if( on_state ) + { + m_HToolBar->ToggleTool( ID_TOOLBARH_PCB_AUTOPLACE, FALSE ); + m_HTOOL_current_state = ID_TOOLBARH_PCB_AUTOROUTE; + } + else + m_HTOOL_current_state = 0; + break; - case ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE: - FixeModule((MODULE *) m_CurrentScreen->m_CurrentItem, TRUE); - break; + case ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE: + FixeModule( (MODULE*) m_CurrentScreen->GetCurItem(), TRUE ); + break; - case ID_POPUP_PCB_AUTOPLACE_FREE_MODULE: - FixeModule((MODULE *) m_CurrentScreen->m_CurrentItem, FALSE); - break; + case ID_POPUP_PCB_AUTOPLACE_FREE_MODULE: + FixeModule( (MODULE*) m_CurrentScreen->GetCurItem(), FALSE ); + break; - case ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES: - FixeModule(NULL, FALSE); - break; + case ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES: + FixeModule( NULL, FALSE ); + break; - case ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES: - FixeModule(NULL, TRUE); - break; + case ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES: + FixeModule( NULL, TRUE ); + break; - case ID_POPUP_PCB_AUTOPLACE_CURRENT_MODULE: - AutoPlaceModule((MODULE *) m_CurrentScreen->m_CurrentItem, - PLACE_1_MODULE, &dc); - break; + case ID_POPUP_PCB_AUTOPLACE_CURRENT_MODULE: + AutoPlaceModule( (MODULE*) m_CurrentScreen->GetCurItem(), + PLACE_1_MODULE, &dc ); + break; - case ID_POPUP_PCB_AUTOPLACE_ALL_MODULES: - AutoPlaceModule(NULL, PLACE_ALL, &dc); - break; + case ID_POPUP_PCB_AUTOPLACE_ALL_MODULES: + AutoPlaceModule( NULL, PLACE_ALL, &dc ); + break; - case ID_POPUP_PCB_AUTOPLACE_NEW_MODULES: - AutoPlaceModule(NULL, PLACE_OUT_OF_BOARD, &dc); - break; + case ID_POPUP_PCB_AUTOPLACE_NEW_MODULES: + AutoPlaceModule( NULL, PLACE_OUT_OF_BOARD, &dc ); + break; - case ID_POPUP_PCB_AUTOPLACE_NEXT_MODULE: - AutoPlaceModule(NULL, PLACE_INCREMENTAL, &dc); - break; + case ID_POPUP_PCB_AUTOPLACE_NEXT_MODULE: + AutoPlaceModule( NULL, PLACE_INCREMENTAL, &dc ); + break; - case ID_POPUP_PCB_AUTOMOVE_ALL_MODULES: - AutoMoveModulesOnPcb(&dc, FALSE); - break; + case ID_POPUP_PCB_AUTOMOVE_ALL_MODULES: + AutoMoveModulesOnPcb( &dc, FALSE ); + break; - case ID_POPUP_PCB_AUTOMOVE_NEW_MODULES: - AutoMoveModulesOnPcb(&dc, TRUE); - break; + case ID_POPUP_PCB_AUTOMOVE_NEW_MODULES: + AutoMoveModulesOnPcb( &dc, TRUE ); + break; - case ID_POPUP_PCB_REORIENT_ALL_MODULES: - ReOrientModules(ModulesMaskSelection, ModulesNewOrient, FALSE, &dc); - break; + case ID_POPUP_PCB_REORIENT_ALL_MODULES: + ReOrientModules( ModulesMaskSelection, ModulesNewOrient, FALSE, &dc ); + break; - case ID_POPUP_PCB_AUTOROUTE_ALL_MODULES: - Autoroute(&dc, ROUTE_ALL); - break; + case ID_POPUP_PCB_AUTOROUTE_ALL_MODULES: + Autoroute( &dc, ROUTE_ALL ); + break; - case ID_POPUP_PCB_AUTOROUTE_MODULE: - Autoroute(&dc, ROUTE_MODULE); - break; + case ID_POPUP_PCB_AUTOROUTE_MODULE: + Autoroute( &dc, ROUTE_MODULE ); + break; - case ID_POPUP_PCB_AUTOROUTE_PAD: - Autoroute(&dc, ROUTE_PAD); - break; + case ID_POPUP_PCB_AUTOROUTE_PAD: + Autoroute( &dc, ROUTE_PAD ); + break; - case ID_POPUP_PCB_AUTOROUTE_NET: - Autoroute(&dc, ROUTE_NET); - break; + case ID_POPUP_PCB_AUTOROUTE_NET: + Autoroute( &dc, ROUTE_NET ); + break; - case ID_POPUP_PCB_AUTOROUTE_RESET_UNROUTED: - Reset_Noroutable(&dc); - break; + case ID_POPUP_PCB_AUTOROUTE_RESET_UNROUTED: + Reset_Noroutable( &dc ); + break; - case ID_POPUP_PCB_AUTOROUTE_SELECT_LAYERS: - break; + case ID_POPUP_PCB_AUTOROUTE_SELECT_LAYERS: + break; - default: - DisplayError(this, wxT("AutoPlace command error") ); - break; - } - m_Pcb->m_Status_Pcb &= ~DO_NOT_SHOW_GENERAL_RASTNEST; - ReCompile_Ratsnest_After_Changes( &dc ); - SetToolbars(); + default: + DisplayError( this, wxT( "AutoPlace command error" ) ); + break; + } + + m_Pcb->m_Status_Pcb &= ~DO_NOT_SHOW_GENERAL_RASTNEST; + ReCompile_Ratsnest_After_Changes( &dc ); + SetToolbars(); } + /*****************************************************************************/ -void WinEDA_PcbFrame::AutoMoveModulesOnPcb(wxDC * DC, bool PlaceModulesHorsPcb) +void WinEDA_PcbFrame::AutoMoveModulesOnPcb( wxDC* DC, bool PlaceModulesHorsPcb ) /*****************************************************************************/ + /* Routine de repartition des composants dans un rectangle de format 4 / 3, - partant du curseur souris - Les composants ayant le status FIXE ne sont normalement pas bouges - Selon les flags: - Tous les modules (non fixes) seront repartis - Seuls les modules Hors PCB seront repartis -*/ + * partant du curseur souris + * Les composants ayant le status FIXE ne sont normalement pas bouges + * Selon les flags: + * Tous les modules (non fixes) seront repartis + * Seuls les modules Hors PCB seront repartis + */ { -MODULE ** pt_Dmod, ** BaseListeModules; -MODULE * Module; -wxPoint start, current; -int Ymax_size, Xsize_allowed; -int pas_grille = m_CurrentScreen->GetGrid().x; -bool EdgeExists; -float surface; + MODULE** pt_Dmod, ** BaseListeModules; + MODULE* Module; + wxPoint start, current; + int Ymax_size, Xsize_allowed; + int pas_grille = m_CurrentScreen->GetGrid().x; + bool EdgeExists; + float surface; - if( m_Pcb->m_Modules == NULL ) - { - DisplayError(this, _("No Modules!"), 10);return; - } + if( m_Pcb->m_Modules == NULL ) + { + DisplayError( this, _( "No Modules!" ), 10 ); return; + } - /* Confirmation */ - if( ! IsOK(this, _("Move Modules ?") ) ) return; + /* Confirmation */ + if( !IsOK( this, _( "Move Modules ?" ) ) ) + return; - EdgeExists = SetBoardBoundaryBoxFromEdgesOnly(); + EdgeExists = SetBoardBoundaryBoxFromEdgesOnly(); - if( PlaceModulesHorsPcb && ! EdgeExists ) - { - DisplayError(this, - _("Autoplace modules: No boad edges detected, unable to place modules"), 20); - return; - } + if( PlaceModulesHorsPcb && !EdgeExists ) + { + DisplayError( this, + _( + "Autoplace modules: No boad edges detected, unable to place modules" ), + 20 ); + return; + } - Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*)Module->Pnext) // remise a jour du rect d'encadrement - { - Module->Set_Rectangle_Encadrement(); - Module->SetRectangleExinscrit(); - } - BaseListeModules = GenListeModules(m_Pcb, NULL); + Module = m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) // remise a jour du rect d'encadrement + { + Module->Set_Rectangle_Encadrement(); + Module->SetRectangleExinscrit(); + } - /* Si repartition de modules Hors PCB, le curseur est mis au dessous - du PCB, pour eviter de placer des composants dans la zone PCB - */ - if( PlaceModulesHorsPcb && EdgeExists ) - { - if( m_CurrentScreen->m_Curseur.y < (m_Pcb->m_BoundaryBox.GetBottom() + 2000) ) - m_CurrentScreen->m_Curseur.y = m_Pcb->m_BoundaryBox.GetBottom() + 2000; - } + BaseListeModules = GenListeModules( m_Pcb, NULL ); - /* calcul de la surface occupee par les circuits */ - surface = 0.0; - for( pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++) - { - Module = *pt_Dmod; - if( PlaceModulesHorsPcb && EdgeExists ) - { - if( m_Pcb->m_BoundaryBox.Inside(Module->m_Pos) ) - continue; - } - surface += Module->m_Surface; - } - Xsize_allowed = (int)(sqrt(surface) * 4.0 /3.0); + /* Si repartition de modules Hors PCB, le curseur est mis au dessous + * du PCB, pour eviter de placer des composants dans la zone PCB + */ + if( PlaceModulesHorsPcb && EdgeExists ) + { + if( m_CurrentScreen->m_Curseur.y < (m_Pcb->m_BoundaryBox.GetBottom() + 2000) ) + m_CurrentScreen->m_Curseur.y = m_Pcb->m_BoundaryBox.GetBottom() + 2000; + } - /* Placement des modules */ - start = current = m_CurrentScreen->m_Curseur; - Ymax_size = 0; + /* calcul de la surface occupee par les circuits */ + surface = 0.0; + for( pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++ ) + { + Module = *pt_Dmod; + if( PlaceModulesHorsPcb && EdgeExists ) + { + if( m_Pcb->m_BoundaryBox.Inside( Module->m_Pos ) ) + continue; + } + surface += Module->m_Surface; + } - for( pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++) - { - Module = *pt_Dmod; - if( Module->m_ModuleStatus & MODULE_is_LOCKED ) continue; + Xsize_allowed = (int) (sqrt( surface ) * 4.0 / 3.0); - if( PlaceModulesHorsPcb && EdgeExists ) - { - if( m_Pcb->m_BoundaryBox.Inside(Module->m_Pos) ) - continue; - } + /* Placement des modules */ + start = current = m_CurrentScreen->m_Curseur; + Ymax_size = 0; - if( current.x > (Xsize_allowed + start.x) ) - { - current.x = start.x; - current.y += Ymax_size + pas_grille; - Ymax_size = 0; - } + for( pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++ ) + { + Module = *pt_Dmod; + if( Module->m_ModuleStatus & MODULE_is_LOCKED ) + continue; - m_CurrentScreen->m_Curseur.x = - current.x + Module->m_Pos.x - Module->m_RealBoundaryBox.GetX(); - m_CurrentScreen->m_Curseur.y = - current.y + Module->m_Pos.y - Module->m_RealBoundaryBox.GetY(); - Ymax_size = MAX(Ymax_size, Module->m_RealBoundaryBox.GetHeight()); + if( PlaceModulesHorsPcb && EdgeExists ) + { + if( m_Pcb->m_BoundaryBox.Inside( Module->m_Pos ) ) + continue; + } - PutOnGrid(&m_CurrentScreen->m_Curseur); + if( current.x > (Xsize_allowed + start.x) ) + { + current.x = start.x; + current.y += Ymax_size + pas_grille; + Ymax_size = 0; + } - Module->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); - Place_Module(Module, DC); /* positionne Module et recalcule cadre */ + m_CurrentScreen->m_Curseur.x = + current.x + Module->m_Pos.x - Module->m_RealBoundaryBox.GetX(); + m_CurrentScreen->m_Curseur.y = + current.y + Module->m_Pos.y - Module->m_RealBoundaryBox.GetY(); + Ymax_size = MAX( Ymax_size, Module->m_RealBoundaryBox.GetHeight() ); - current.x += Module->m_RealBoundaryBox.GetWidth ()+ pas_grille; - } + PutOnGrid( &m_CurrentScreen->m_Curseur ); - MyFree( BaseListeModules); - m_CurrentScreen->SetRefreshReq(); + Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + Place_Module( Module, DC ); /* positionne Module et recalcule cadre */ + + current.x += Module->m_RealBoundaryBox.GetWidth() + pas_grille; + } + + MyFree( BaseListeModules ); + m_CurrentScreen->SetRefreshReq(); } /***********************************************************/ -void WinEDA_PcbFrame::FixeModule(MODULE * Module, bool Fixe) +void WinEDA_PcbFrame::FixeModule( MODULE* Module, bool Fixe ) /***********************************************************/ + /* Met a jour (FALSE ou TRUE) l'attribut FIXE sur le module Module, -ou sur tous les modules si Modulle == NULL -*/ + * ou sur tous les modules si Modulle == NULL + */ { - if ( Module) /* Traitement du module */ - { - if ( Fixe ) Module->m_ModuleStatus |= MODULE_is_LOCKED; - else Module->m_ModuleStatus &= ~MODULE_is_LOCKED; - Module->Display_Infos(this); - GetScreen()->SetModify(); - } - - else - { - Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*)Module->Pnext) - { - if( WildCompareString(ModulesMaskSelection, Module->m_Reference->m_Text) ) - { - if ( Fixe ) Module->m_ModuleStatus |= MODULE_is_LOCKED; - else Module->m_ModuleStatus &= ~MODULE_is_LOCKED; - GetScreen()->SetModify(); - } - } - } + if( Module ) /* Traitement du module */ + { + if( Fixe ) + Module->m_ModuleStatus |= MODULE_is_LOCKED; + else + Module->m_ModuleStatus &= ~MODULE_is_LOCKED; + Module->Display_Infos( this ); + GetScreen()->SetModify(); + } + else + { + Module = m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + if( WildCompareString( ModulesMaskSelection, Module->m_Reference->m_Text ) ) + { + if( Fixe ) + Module->m_ModuleStatus |= MODULE_is_LOCKED; + else + Module->m_ModuleStatus &= ~MODULE_is_LOCKED; + GetScreen()->SetModify(); + } + } + } } + /*******************************************************************/ -void WinEDA_PcbFrame::ReOrientModules(const wxString & ModuleMask, - int Orient, bool include_fixe, wxDC * DC) +void WinEDA_PcbFrame::ReOrientModules( const wxString& ModuleMask, + int Orient, bool include_fixe, wxDC* DC ) /*******************************************************************/ + /* - Reoriente tous les modules selon masque et attribut, avec la nouvelle - orientation selectionnee -*/ + * Reoriente tous les modules selon masque et attribut, avec la nouvelle + * orientation selectionnee + */ { -MODULE * Module; -wxString line; + MODULE* Module; + wxString line; - line.Printf( _("Ok to set module orientation to %d degrees ?"), Orient/10); - if( !IsOK(this, line ) )return; + line.Printf( _( "Ok to set module orientation to %d degrees ?" ), Orient / 10 ); + if( !IsOK( this, line ) ) + return; - Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*)Module->Pnext) - { - if( (Module->m_ModuleStatus & MODULE_is_LOCKED ) && ! include_fixe ) - continue; + Module = m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + if( (Module->m_ModuleStatus & MODULE_is_LOCKED ) && !include_fixe ) + continue; - if( WildCompareString(ModuleMask, Module->m_Reference->m_Text, FALSE ) ) - { - m_CurrentScreen->SetModify(); - Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); - Rotate_Module( NULL, Module, Orient, FALSE ); - Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); - } - } + if( WildCompareString( ModuleMask, Module->m_Reference->m_Text, FALSE ) ) + { + m_CurrentScreen->SetModify(); + Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + Rotate_Module( NULL, Module, Orient, FALSE ); + Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + } + } } /*********************************************************/ -MODULE ** GenListeModules( BOARD * Pcb, int * NbModules ) +MODULE** GenListeModules( BOARD* Pcb, int* NbModules ) /*********************************************************/ + /* Cree par allocation memoire la liste ordonnee des structures D_MODULES - decrivant les modules a deplacer - la fin de la liste est signalee par NULL - Retourne egalement le nombre de modules par *NbModules - Penser a desallouer la memoire apres usage -*/ + * decrivant les modules a deplacer + * la fin de la liste est signalee par NULL + * Retourne egalement le nombre de modules par *NbModules + * Penser a desallouer la memoire apres usage + */ { -MODULE * Module; -MODULE ** ListeMod, ** PtList; -int NbMod; + MODULE* Module; + MODULE** ListeMod, ** PtList; + int NbMod; - /* Reservation de la memoire pour description des modules que l'on - peut deplacer */ - Module = Pcb->m_Modules; - NbMod = 0; - for( ; Module != NULL; Module = (MODULE*)Module->Pnext) NbMod++; + /* Reservation de la memoire pour description des modules que l'on + * peut deplacer */ + Module = Pcb->m_Modules; + NbMod = 0; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + NbMod++; - ListeMod = (MODULE**) MyZMalloc( (NbMod+1) * sizeof(MODULE*) ); - if(ListeMod == NULL ) - { - if( NbModules != NULL ) *NbModules = 0; - return(NULL); - } + ListeMod = (MODULE**) MyZMalloc( (NbMod + 1) * sizeof(MODULE *) ); + if( ListeMod == NULL ) + { + if( NbModules != NULL ) + *NbModules = 0; + return NULL; + } - PtList = ListeMod; - Module = Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*)Module->Pnext) - { - *PtList = Module; PtList++; - Module->SetRectangleExinscrit(); - } + PtList = ListeMod; + Module = Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + *PtList = Module; PtList++; + Module->SetRectangleExinscrit(); + } - /* Tri par surface decroissante des modules ( on place les plus gros en 1er) */ - qsort(ListeMod, NbMod, sizeof(MODULE**), - (int(*)(const void *, const void * ))tri_modules); + /* Tri par surface decroissante des modules ( on place les plus gros en 1er) */ + qsort( ListeMod, NbMod, sizeof(MODULE * *), + ( int( * ) ( const void*, const void* ) )tri_modules ); - if( NbModules != NULL ) *NbModules = NbMod; - return( ListeMod ); + if( NbModules != NULL ) + *NbModules = NbMod; + return ListeMod; } - /**************************************************/ - /* Routine de tri de modules, utilisee par qsort: */ - /**************************************************/ -static int tri_modules(MODULE ** pt_ref, MODULE ** pt_compare) +/**************************************************/ +/* Routine de tri de modules, utilisee par qsort: */ +/**************************************************/ + +static int tri_modules( MODULE** pt_ref, MODULE** pt_compare ) { -float ff ; + float ff; - ff = (*pt_ref)->m_Surface - (*pt_compare)->m_Surface ; - if( ff < 0 ) return(1) ; - if( ff > 0 ) return(-1) ; - return( 0 ); + ff = (*pt_ref)->m_Surface - (*pt_compare)->m_Surface; + if( ff < 0 ) + return 1; + if( ff > 0 ) + return -1; + return 0; } - diff --git a/pcbnew/autorout.cpp b/pcbnew/autorout.cpp index 7e9d477377..1f671f3998 100644 --- a/pcbnew/autorout.cpp +++ b/pcbnew/autorout.cpp @@ -34,12 +34,12 @@ wxString msg; switch ( mode ) { case ROUTE_NET: - if ( GetScreen()->m_CurrentItem ) + if ( GetScreen()->GetCurItem() ) { - switch ( GetScreen()->m_CurrentItem->m_StructType ) + switch ( GetScreen()->GetCurItem()->m_StructType ) { case TYPEPAD: - Pad = (D_PAD*) GetScreen()->m_CurrentItem; + Pad = (D_PAD*) GetScreen()->GetCurItem(); autoroute_net_code = Pad->m_NetCode; break; @@ -54,7 +54,7 @@ wxString msg; break; case ROUTE_MODULE: - Module = (MODULE*) GetScreen()->m_CurrentItem; + Module = (MODULE*) GetScreen()->GetCurItem(); if( (Module == NULL) || (Module->m_StructType != TYPEMODULE) ) { DisplayError(this, _("Module not selected") ); return; @@ -62,7 +62,7 @@ wxString msg; break; case ROUTE_PAD: - Pad = (D_PAD*) GetScreen()->m_CurrentItem; + Pad = (D_PAD*) GetScreen()->GetCurItem(); if( (Pad == NULL) || (Pad->m_StructType != TYPEPAD) ) { DisplayError(this, _("Pad not selected") ); return; diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp index 5b10b8e923..5f7d021bb7 100644 --- a/pcbnew/block.cpp +++ b/pcbnew/block.cpp @@ -1,6 +1,6 @@ - /*****************************************************************/ - /* Operations sur Blocks : deplacement, rotation, effacement ... */ - /*****************************************************************/ +/*****************************************************************/ +/* Operations sur Blocks : deplacement, rotation, effacement ... */ +/*****************************************************************/ #include "fctsys.h" @@ -19,1391 +19,1494 @@ /* Routines Locales */ -static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); -static EDA_BaseStruct * IsStructInBox(DrawBlockStruct &blocklocate, EDA_BaseStruct * PtStruct ); -static TRACK * IsSegmentInBox(DrawBlockStruct & blocklocate, TRACK * PtSegm ); -static MODULE * IsModuleInBox(DrawBlockStruct& blocklocate, MODULE * Module ); +static EDA_BaseStruct* IsStructInBox( DrawBlockStruct& blocklocate, EDA_BaseStruct* PtStruct ); +static TRACK* IsSegmentInBox( DrawBlockStruct& blocklocate, TRACK* PtSegm ); +static MODULE* IsModuleInBox( DrawBlockStruct& blocklocate, MODULE* Module ); /* Variables locales :*/ -static bool Block_Include_Modules = TRUE; -static bool Block_Include_Tracks = TRUE; -static bool Block_Include_Zones = TRUE; -static bool Block_Include_Draw_Items = TRUE; +static bool Block_Include_Modules = TRUE; +static bool Block_Include_Tracks = TRUE; +static bool Block_Include_Zones = TRUE; +static bool Block_Include_Draw_Items = TRUE; static bool Block_Include_Edges_Items = TRUE; -static bool Block_Include_PcbTextes = TRUE; +static bool Block_Include_PcbTextes = TRUE; -enum id_block_cmd -{ - ID_ACCEPT_BLOCK_COMMAND = 8000, - ID_CANCEL_BLOCK_COMMAND +enum id_block_cmd { + ID_ACCEPT_BLOCK_COMMAND = 8000, + ID_CANCEL_BLOCK_COMMAND }; - /************************************/ - /* class WinEDA_ExecBlockCmdFrame */ - /************************************/ +/************************************/ +/* class WinEDA_ExecBlockCmdFrame */ +/************************************/ -class WinEDA_ExecBlockCmdFrame: public wxDialog +class WinEDA_ExecBlockCmdFrame : public wxDialog { private: - WinEDA_BasePcbFrame * m_Parent; - wxCheckBox * m_Include_Modules; - wxCheckBox * m_Include_Tracks; - wxCheckBox * m_Include_Zones; - wxCheckBox * m_Include_Draw_Items; - wxCheckBox * m_Include_Edges_Items; - wxCheckBox * m_Include_PcbTextes; + WinEDA_BasePcbFrame* m_Parent; + wxCheckBox* m_Include_Modules; + wxCheckBox* m_Include_Tracks; + wxCheckBox* m_Include_Zones; + wxCheckBox* m_Include_Draw_Items; + wxCheckBox* m_Include_Edges_Items; + wxCheckBox* m_Include_PcbTextes; public: - // Constructor and destructor - WinEDA_ExecBlockCmdFrame(WinEDA_BasePcbFrame *parent, - const wxString & title); - ~WinEDA_ExecBlockCmdFrame(void) - { - } + + // Constructor and destructor + WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent, + const wxString& title ); + ~WinEDA_ExecBlockCmdFrame( void ) + { + } + private: - void ExecuteCommand(wxCommandEvent& event); - void Cancel(wxCommandEvent& event); + void ExecuteCommand( wxCommandEvent& event ); + void Cancel( wxCommandEvent& event ); - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() }; -BEGIN_EVENT_TABLE(WinEDA_ExecBlockCmdFrame, wxDialog) - EVT_BUTTON(ID_ACCEPT_BLOCK_COMMAND, WinEDA_ExecBlockCmdFrame::ExecuteCommand) - EVT_BUTTON(ID_CANCEL_BLOCK_COMMAND, WinEDA_ExecBlockCmdFrame::Cancel) +BEGIN_EVENT_TABLE( WinEDA_ExecBlockCmdFrame, wxDialog ) +EVT_BUTTON( ID_ACCEPT_BLOCK_COMMAND, WinEDA_ExecBlockCmdFrame::ExecuteCommand ) +EVT_BUTTON( ID_CANCEL_BLOCK_COMMAND, WinEDA_ExecBlockCmdFrame::Cancel ) END_EVENT_TABLE() /**************************************************************/ -static bool InstallBlockCmdFrame(WinEDA_BasePcbFrame * parent, - const wxString & title) +static bool InstallBlockCmdFrame( WinEDA_BasePcbFrame* parent, + const wxString& title ) /**************************************************************/ { -int nocmd; -wxPoint oldpos = parent->GetScreen()->m_Curseur; + int nocmd; + wxPoint oldpos = parent->GetScreen()->m_Curseur; - parent->DrawPanel->m_IgnoreMouseEvents = TRUE; - WinEDA_ExecBlockCmdFrame * frame = new WinEDA_ExecBlockCmdFrame(parent, title); - nocmd = frame->ShowModal(); frame->Destroy(); - parent->GetScreen()->m_Curseur = oldpos; - parent->DrawPanel->MouseToCursorSchema(); - parent->DrawPanel->m_IgnoreMouseEvents = FALSE; + parent->DrawPanel->m_IgnoreMouseEvents = TRUE; + WinEDA_ExecBlockCmdFrame* frame = new WinEDA_ExecBlockCmdFrame( parent, title ); + nocmd = frame->ShowModal(); frame->Destroy(); + parent->GetScreen()-> m_Curseur = oldpos; + parent->DrawPanel->MouseToCursorSchema(); + parent->DrawPanel->m_IgnoreMouseEvents = FALSE; - parent->DrawPanel->SetCursor(parent->DrawPanel->m_PanelCursor = parent->DrawPanel->m_PanelDefaultCursor); + parent->DrawPanel->SetCursor( + parent->DrawPanel->m_PanelCursor = parent->DrawPanel->m_PanelDefaultCursor ); - return ( nocmd ? FALSE : TRUE ); + return nocmd ? FALSE : TRUE; } /******************************************************************************/ -WinEDA_ExecBlockCmdFrame::WinEDA_ExecBlockCmdFrame(WinEDA_BasePcbFrame *parent, - const wxString & title): - wxDialog(parent, -1, title, wxPoint(-1,-1), wxSize(280, 220), - DIALOG_STYLE) +WinEDA_ExecBlockCmdFrame::WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent, + const wxString& title ) : + wxDialog( parent, -1, title, wxPoint( -1, -1 ), wxSize( 280, 220 ), + DIALOG_STYLE ) /******************************************************************************/ { -wxPoint pos; -wxButton * Button; + wxPoint pos; + wxButton* Button; - m_Parent = parent; - SetFont(*g_DialogFont); - Centre(); + m_Parent = parent; + SetFont( *g_DialogFont ); + Centre(); - /* Creation des boutons de commande */ - pos.x = 170; pos.y = 10; - Button = new wxButton(this, ID_ACCEPT_BLOCK_COMMAND, - _("Ok"), pos); - Button->SetForegroundColour(*wxRED); + /* Creation des boutons de commande */ + pos.x = 170; pos.y = 10; + Button = new wxButton( this, ID_ACCEPT_BLOCK_COMMAND, + _( "Ok" ), pos ); + Button->SetForegroundColour( *wxRED ); - pos.y += Button->GetDefaultSize().y + 20; - Button = new wxButton(this, ID_CANCEL_BLOCK_COMMAND, - _("Cancel"), pos); - Button->SetForegroundColour(*wxBLUE); + pos.y += Button->GetDefaultSize().y + 20; + Button = new wxButton( this, ID_CANCEL_BLOCK_COMMAND, + _( "Cancel" ), pos ); + Button->SetForegroundColour( *wxBLUE ); - pos.x = 5; pos.y = 20; + pos.x = 5; pos.y = 20; - // Selection des options : - m_Include_Modules = new wxCheckBox(this, -1, _("Include Modules"), pos); - m_Include_Modules->SetValue(Block_Include_Modules); + // Selection des options : + m_Include_Modules = new wxCheckBox( this, -1, _( "Include Modules" ), pos ); + m_Include_Modules->SetValue( Block_Include_Modules ); - pos.y += 20; - m_Include_Tracks = new wxCheckBox(this, -1, _("Include tracks"), pos); - m_Include_Tracks->SetValue(Block_Include_Tracks); + pos.y += 20; + m_Include_Tracks = new wxCheckBox( this, -1, _( "Include tracks" ), pos ); + m_Include_Tracks->SetValue( Block_Include_Tracks ); - pos.y += 20; - m_Include_Zones = new wxCheckBox(this, -1, _("Include zones"), pos); - m_Include_Zones->SetValue(Block_Include_Zones); + pos.y += 20; + m_Include_Zones = new wxCheckBox( this, -1, _( "Include zones" ), pos ); + m_Include_Zones->SetValue( Block_Include_Zones ); - pos.y += 20; - m_Include_PcbTextes = new wxCheckBox(this, -1, - _("Include Text on copper layers"), pos); - m_Include_PcbTextes->SetValue(Block_Include_PcbTextes); + pos.y += 20; + m_Include_PcbTextes = new wxCheckBox( this, -1, + _( "Include Text on copper layers" ), pos ); + m_Include_PcbTextes->SetValue( Block_Include_PcbTextes ); - pos.y += 20; - m_Include_Draw_Items = new wxCheckBox(this, -1, _("Include drawings"), pos); - m_Include_Draw_Items->SetValue(Block_Include_Draw_Items); + pos.y += 20; + m_Include_Draw_Items = new wxCheckBox( this, -1, _( "Include drawings" ), pos ); + m_Include_Draw_Items->SetValue( Block_Include_Draw_Items ); - pos.y += 20; - m_Include_Edges_Items = new wxCheckBox(this, -1, _("Include egde layer"), pos); - m_Include_Edges_Items->SetValue(Block_Include_Edges_Items); - -} - -/**********************************************************************/ -void WinEDA_ExecBlockCmdFrame::Cancel(wxCommandEvent& WXUNUSED(event)) -/**********************************************************************/ -{ - EndModal(1); + pos.y += 20; + m_Include_Edges_Items = new wxCheckBox( this, -1, _( "Include egde layer" ), pos ); + m_Include_Edges_Items->SetValue( Block_Include_Edges_Items ); } +/**********************************************************************/ +void WinEDA_ExecBlockCmdFrame::Cancel( wxCommandEvent& WXUNUSED (event) ) +/**********************************************************************/ +{ + EndModal( 1 ); +} + /*******************************************************************/ -void WinEDA_ExecBlockCmdFrame::ExecuteCommand(wxCommandEvent& event) +void WinEDA_ExecBlockCmdFrame::ExecuteCommand( wxCommandEvent& event ) /*******************************************************************/ { - Block_Include_Modules = m_Include_Modules->GetValue(); - Block_Include_Tracks = m_Include_Tracks->GetValue(); - Block_Include_Zones = m_Include_Zones->GetValue(); - Block_Include_Draw_Items = m_Include_Draw_Items->GetValue(); - Block_Include_Edges_Items = m_Include_Edges_Items->GetValue(); - Block_Include_PcbTextes = m_Include_PcbTextes->GetValue(); + Block_Include_Modules = m_Include_Modules->GetValue(); + Block_Include_Tracks = m_Include_Tracks->GetValue(); + Block_Include_Zones = m_Include_Zones->GetValue(); + Block_Include_Draw_Items = m_Include_Draw_Items->GetValue(); + Block_Include_Edges_Items = m_Include_Edges_Items->GetValue(); + Block_Include_PcbTextes = m_Include_PcbTextes->GetValue(); - EndModal(0); + EndModal( 0 ); } /*************************************************/ -int WinEDA_PcbFrame::ReturnBlockCommand(int key) +int WinEDA_PcbFrame::ReturnBlockCommand( int key ) /*************************************************/ + /* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to - the key (ALT, SHIFT ALT ..) -*/ + * the key (ALT, SHIFT ALT ..) + */ { -int cmd = 0; + int cmd = 0; - switch ( key ) - { - default: - cmd = key & 0x255; - break; + switch( key ) + { + default: + cmd = key & 0x255; + break; - case 0: - cmd = BLOCK_MOVE; - break; + case 0: + cmd = BLOCK_MOVE; + break; - case GR_KB_SHIFT: - cmd = BLOCK_COPY; - break; + case GR_KB_SHIFT: + cmd = BLOCK_COPY; + break; - case GR_KB_CTRL : - cmd = BLOCK_ROTATE; - break; + case GR_KB_CTRL: + cmd = BLOCK_ROTATE; + break; - case GR_KB_SHIFTCTRL : - cmd = BLOCK_DELETE; - break; + case GR_KB_SHIFTCTRL: + cmd = BLOCK_DELETE; + break; - case GR_KB_ALT : - cmd = BLOCK_INVERT; - break; + case GR_KB_ALT: + cmd = BLOCK_INVERT; + break; - case MOUSE_MIDDLE: - cmd = BLOCK_ZOOM; - break; - } + case MOUSE_MIDDLE: + cmd = BLOCK_ZOOM; + break; + } - return cmd ; + return cmd; } /*****************************************************/ -void WinEDA_PcbFrame::HandleBlockPlace(wxDC * DC) +void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC ) /*****************************************************/ /* Routine to handle the BLOCK PLACE commande */ { -bool err = FALSE; + bool err = FALSE; - if(DrawPanel->ManageCurseur == NULL) - { - err = TRUE; - DisplayError(this, wxT("Error in HandleBlockPLace : ManageCurseur = NULL") ); - } - GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + if( DrawPanel->ManageCurseur == NULL ) + { + err = TRUE; + DisplayError( this, wxT( "Error in HandleBlockPLace : ManageCurseur = NULL" ) ); + } + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; - switch(GetScreen()->BlockLocate.m_Command ) - { - case BLOCK_IDLE: - err = TRUE; - break; + switch( GetScreen()->BlockLocate.m_Command ) + { + case BLOCK_IDLE: + err = TRUE; + break; - case BLOCK_DRAG: /* Drag */ - case BLOCK_MOVE: /* Move */ - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ - if ( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - Block_Move(DC); - GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; - break; + case BLOCK_DRAG: /* Drag */ + case BLOCK_MOVE: /* Move */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + Block_Move( DC ); + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + break; - case BLOCK_COPY: /* Copy */ - if ( DrawPanel->ManageCurseur ) - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - Block_Duplicate(DC); - GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; - break; + case BLOCK_COPY: /* Copy */ + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + Block_Duplicate( DC ); + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + break; - case BLOCK_PASTE: - break; + case BLOCK_PASTE: + break; - case BLOCK_ZOOM: // Handled by HandleBlockEnd() - default: - break; - } + case BLOCK_ZOOM: // Handled by HandleBlockEnd() + default: + break; + } - GetScreen()->SetModify(); + GetScreen()->SetModify(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->BlockLocate.m_Flags = 0; - GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; - GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; - if ( GetScreen()->BlockLocate.m_BlockDrawStruct ) - { - DisplayError(this, wxT("Error in HandleBlockPLace DrawStruct != NULL") ); - GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; - } + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->BlockLocate.m_Flags = 0; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + if( GetScreen()->BlockLocate.m_BlockDrawStruct ) + { + DisplayError( this, wxT( "Error in HandleBlockPLace DrawStruct != NULL" ) ); + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + } - DisplayToolMsg(wxEmptyString); + DisplayToolMsg( wxEmptyString ); } + /**********************************************/ -int WinEDA_PcbFrame::HandleBlockEnd(wxDC * DC) +int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) /**********************************************/ + /* Routine de gestion de la commande BLOCK END - returne : - 0 si aucun compos ant selectionne - 1 sinon - -1 si commande termin�e et composants trouv�s (block delete, block save) -*/ + * returne : + * 0 si aucun compos ant selectionne + * 1 sinon + * -1 si commande termin�e et composants trouv�s (block delete, block save) + */ { -int endcommande = TRUE; + int endcommande = TRUE; - if(DrawPanel->ManageCurseur ) - switch( GetScreen()->BlockLocate.m_Command ) - { - case BLOCK_IDLE: - DisplayError(this, wxT("Error in HandleBlockPLace") ); - break; + if( DrawPanel->ManageCurseur ) + switch( GetScreen()->BlockLocate.m_Command ) + { + case BLOCK_IDLE: + DisplayError( this, wxT( "Error in HandleBlockPLace" ) ); + break; - case BLOCK_DRAG: /* Drag (not used, for future enhancements)*/ - case BLOCK_MOVE: /* Move */ - case BLOCK_COPY: /* Copy */ - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ - GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; - endcommande = FALSE; - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - DrawPanel->ManageCurseur = DrawMovingBlockOutlines; - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - break; + case BLOCK_DRAG: /* Drag (not used, for future enhancements)*/ + case BLOCK_MOVE: /* Move */ + case BLOCK_COPY: /* Copy */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; + endcommande = FALSE; + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + break; - case BLOCK_DELETE: /* Delete */ - // Turn off the block rectangle now so it is not redisplayed - DrawPanel->ManageCurseur = NULL; - GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; - DrawAndSizingBlockOutlines(DrawPanel, DC, FALSE); - Block_Delete(DC); - break; + case BLOCK_DELETE: /* Delete */ - case BLOCK_ROTATE: /* Rotation */ - // Turn off the block rectangle now so it is not redisplayed - DrawPanel->ManageCurseur = NULL; - GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; - DrawAndSizingBlockOutlines(DrawPanel, DC, FALSE); - Block_Rotate(DC); - break; + // Turn off the block rectangle now so it is not redisplayed + DrawPanel->ManageCurseur = NULL; + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); + Block_Delete( DC ); + break; - case BLOCK_INVERT: /* Flip */ - // Turn off the block rectangle now so it is not redisplayed - DrawPanel->ManageCurseur = NULL; - GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; - DrawAndSizingBlockOutlines(DrawPanel, DC, FALSE); - Block_Invert(DC); - break; + case BLOCK_ROTATE: /* Rotation */ + + // Turn off the block rectangle now so it is not redisplayed + DrawPanel->ManageCurseur = NULL; + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); + Block_Rotate( DC ); + break; + + case BLOCK_INVERT: /* Flip */ + + // Turn off the block rectangle now so it is not redisplayed + DrawPanel->ManageCurseur = NULL; + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); + Block_Invert( DC ); + break; + + case BLOCK_SAVE: /* Save (not used, for future enhancements)*/ + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + if( GetScreen()->BlockLocate.m_BlockDrawStruct != NULL ) + { + DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); - case BLOCK_SAVE: /* Save (not used, for future enhancements)*/ - GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; - if( GetScreen()->BlockLocate.m_BlockDrawStruct != NULL) - { - DrawAndSizingBlockOutlines(DrawPanel, DC, FALSE); // SaveStruct(GetScreen()->BlockLocate.m_BlockDrawStruct); - } - break; + } + break; - case BLOCK_PASTE: break; + case BLOCK_PASTE: + break; - case BLOCK_ZOOM: /* Window Zoom */ - //Turn off the redraw block routine now so it is not displayed - // with one corner at the new center of the screen - DrawPanel->ManageCurseur = NULL; - Window_Zoom( GetScreen()->BlockLocate ); - break; + case BLOCK_ZOOM: /* Window Zoom */ - default: - break; - } + //Turn off the redraw block routine now so it is not displayed + // with one corner at the new center of the screen + DrawPanel->ManageCurseur = NULL; + Window_Zoom( GetScreen()->BlockLocate ); + break; - if ( endcommande == TRUE ) - { - GetScreen()->BlockLocate.m_Flags = 0; - GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; - GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; - GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - DisplayToolMsg(wxEmptyString); - } + default: + break; + } - return(endcommande); + if( endcommande == TRUE ) + { + GetScreen()->BlockLocate.m_Flags = 0; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + DisplayToolMsg( wxEmptyString ); + } + + return endcommande; } +/**************************************************************************/ +static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) +/**************************************************************************/ -/**************************************************************************/ -static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) -/**************************************************************************/ /* Retrace le contour du block de repositionnement des structures a d�placer */ { -int Color; -BASE_SCREEN * screen = panel->GetScreen(); + int Color; + BASE_SCREEN* screen = panel->GetScreen(); - Color = YELLOW; GRSetDrawMode(DC, g_XorMode); + Color = YELLOW; GRSetDrawMode( DC, g_XorMode ); - /* Effacement ancien cadre */ - if( erase ) - { - screen->BlockLocate.Draw(panel, DC); - if ( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y ) - { - screen->BlockLocate.Offset(screen->BlockLocate.m_MoveVector); - screen->BlockLocate.Draw(panel, DC); - screen->BlockLocate.Offset(-screen->BlockLocate.m_MoveVector.x, -screen->BlockLocate.m_MoveVector.y); - } - } + /* Effacement ancien cadre */ + if( erase ) + { + screen->BlockLocate.Draw( panel, DC ); + if( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y ) + { + screen->BlockLocate.Offset( screen->BlockLocate.m_MoveVector ); + screen->BlockLocate.Draw( panel, DC ); + screen->BlockLocate.Offset( -screen->BlockLocate.m_MoveVector.x, + -screen->BlockLocate.m_MoveVector.y ); + } + } - if ( panel->m_Parent->GetScreen()->BlockLocate.m_State != STATE_BLOCK_STOP ) - { - screen->BlockLocate.m_MoveVector.x = screen->m_Curseur.x - screen->BlockLocate.GetRight(); - screen->BlockLocate.m_MoveVector.y = screen->m_Curseur.y - screen->BlockLocate.GetBottom(); - } + if( panel->m_Parent->GetScreen()->BlockLocate.m_State != STATE_BLOCK_STOP ) + { + screen->BlockLocate.m_MoveVector.x = screen->m_Curseur.x - screen->BlockLocate.GetRight(); + screen->BlockLocate.m_MoveVector.y = screen->m_Curseur.y - screen->BlockLocate.GetBottom(); + } - screen->BlockLocate.Draw(panel, DC); - if ( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y ) - { - screen->BlockLocate.Offset(screen->BlockLocate.m_MoveVector); - screen->BlockLocate.Draw(panel, DC); - screen->BlockLocate.Offset(-screen->BlockLocate.m_MoveVector.x, -screen->BlockLocate.m_MoveVector.y); - } + screen->BlockLocate.Draw( panel, DC ); + if( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y ) + { + screen->BlockLocate.Offset( screen->BlockLocate.m_MoveVector ); + screen->BlockLocate.Draw( panel, DC ); + screen->BlockLocate.Offset( -screen->BlockLocate.m_MoveVector.x, + -screen->BlockLocate.m_MoveVector.y ); + } } /************************************************/ -void WinEDA_BasePcbFrame::Block_Delete(wxDC *DC) +void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) /************************************************/ + /* - routine d'effacement du block deja selectionne -*/ + * routine d'effacement du block deja selectionne + */ { -EDA_BaseStruct * PtStruct, * NextS; -int masque_layer; + EDA_BaseStruct* PtStruct, * NextS; + int masque_layer; - if( ! InstallBlockCmdFrame(this, _("Delete Block")) ) return ; + if( !InstallBlockCmdFrame( this, _( "Delete Block" ) ) ) + return; - GetScreen()->SetModify(); - GetScreen()->BlockLocate.Normalize(); - GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetModify(); + GetScreen()->BlockLocate.Normalize(); + GetScreen()->SetCurItem( NULL ); - /* Effacement des modules */ - if ( Block_Include_Modules ) - { - MODULE * module; - Affiche_Message( _("Delete Footprints") ) ; - module = m_Pcb->m_Modules; - for ( ; module != NULL; module = (MODULE*) NextS) - { - NextS = module->Pnext; - if( IsModuleInBox(GetScreen()->BlockLocate, module) == NULL ) continue; - /* le module est ici bon a etre efface */ - module->m_Flags = 0; - module->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR) ; - DeleteStructure(module); - m_Pcb->m_Status_Pcb = 0 ; - } - } + /* Effacement des modules */ + if( Block_Include_Modules ) + { + MODULE* module; + Affiche_Message( _( "Delete Footprints" ) ); + module = m_Pcb->m_Modules; + for( ; module != NULL; module = (MODULE*) NextS ) + { + NextS = module->Pnext; + if( IsModuleInBox( GetScreen()->BlockLocate, module ) == NULL ) + continue; + /* le module est ici bon a etre efface */ + module->m_Flags = 0; + module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + DeleteStructure( module ); + m_Pcb->m_Status_Pcb = 0; + } + } - /* Effacement des Pistes */ - if( Block_Include_Tracks ) - { - TRACK * pt_segm; + /* Effacement des Pistes */ + if( Block_Include_Tracks ) + { + TRACK* pt_segm; - Affiche_Message( _("Delete tracks" )) ; - for ( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) NextS) - { - NextS = pt_segm->Pnext; - if( IsSegmentInBox(GetScreen()->BlockLocate, pt_segm ) ) - { /* la piste est ici bonne a etre efface */ - pt_segm->Draw(DrawPanel, DC, GR_XOR) ; - DeleteStructure(pt_segm); - } - } - } + Affiche_Message( _( "Delete tracks" ) ); + for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) NextS ) + { + NextS = pt_segm->Pnext; + if( IsSegmentInBox( GetScreen()->BlockLocate, pt_segm ) ) + { /* la piste est ici bonne a etre efface */ + pt_segm->Draw( DrawPanel, DC, GR_XOR ); + DeleteStructure( pt_segm ); + } + } + } - /* Effacement des Elements De Dessin */ - masque_layer = EDGE_LAYER; - if( Block_Include_Draw_Items ) masque_layer = ALL_LAYERS; - if( ! Block_Include_Edges_Items ) masque_layer &= ~EDGE_LAYER; + /* Effacement des Elements De Dessin */ + masque_layer = EDGE_LAYER; + if( Block_Include_Draw_Items ) + masque_layer = ALL_LAYERS; + if( !Block_Include_Edges_Items ) + masque_layer &= ~EDGE_LAYER; - Affiche_Message( _("Delete draw layers") ); - PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = NextS ) - { - NextS = PtStruct->Pnext; - switch( PtStruct->m_StructType ) - { - case TYPEDRAWSEGMENT: - #undef STRUCT - #define STRUCT ((DRAWSEGMENT*)PtStruct) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* l'element est ici bon a etre efface */ - Trace_DrawSegmentPcb(DrawPanel, DC, (DRAWSEGMENT*)PtStruct,GR_XOR) ; - DeleteStructure(PtStruct); - break; + Affiche_Message( _( "Delete draw layers" ) ); + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = NextS ) + { + NextS = PtStruct->Pnext; - case TYPETEXTE: - if( ! Block_Include_PcbTextes ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* le texte est ici bon a etre efface */ - ((TEXTE_PCB*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); - /* Suppression du texte en Memoire*/ - DeleteStructure(PtStruct); - break; + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + #undef STRUCT + #define STRUCT ( (DRAWSEGMENT*) PtStruct ) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* l'element est ici bon a etre efface */ + Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) PtStruct, GR_XOR ); + DeleteStructure( PtStruct ); + break; - case TYPEMIRE: - #undef STRUCT - #define STRUCT ((MIREPCB*) PtStruct) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* l'element est ici bon a etre efface */ - ((MIREPCB*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR) ; - DeleteStructure(PtStruct); - break; + case TYPETEXTE: + if( !Block_Include_PcbTextes ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* le texte est ici bon a etre efface */ + ( (TEXTE_PCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + /* Suppression du texte en Memoire*/ + DeleteStructure( PtStruct ); + break; - case TYPECOTATION: - #undef STRUCT - #define STRUCT ((COTATION*) PtStruct) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* l'element est ici bon a etre efface */ - ((COTATION*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR) ; - DeleteStructure(PtStruct); - break; + case TYPEMIRE: + #undef STRUCT + #define STRUCT ( (MIREPCB*) PtStruct ) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* l'element est ici bon a etre efface */ + ( (MIREPCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + DeleteStructure( PtStruct ); + break; - default: break; - } - } + case TYPECOTATION: + #undef STRUCT + #define STRUCT ( (COTATION*) PtStruct ) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* l'element est ici bon a etre efface */ + ( (COTATION*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + DeleteStructure( PtStruct ); + break; - /* Effacement des Zones */ - if(Block_Include_Zones) - { - TRACK * pt_segm; + default: + break; + } + } - Affiche_Message( _("Delete zones") ); - for ( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = (TRACK*) NextS) - { - NextS = pt_segm->Pnext; - if( IsSegmentInBox(GetScreen()->BlockLocate, pt_segm ) ) - {/* la piste est ici bonne a etre efface */ - pt_segm->Draw(DrawPanel, DC, GR_XOR) ; - DeleteStructure(pt_segm); - } - } - } + /* Effacement des Zones */ + if( Block_Include_Zones ) + { + TRACK* pt_segm; - /* Rafraichissement de l'ecran : */ - RedrawActiveWindow(DC, TRUE); - if ( g_Show_Ratsnest ) Compile_Ratsnest( DC, TRUE ); + Affiche_Message( _( "Delete zones" ) ); + for( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = (TRACK*) NextS ) + { + NextS = pt_segm->Pnext; + if( IsSegmentInBox( GetScreen()->BlockLocate, pt_segm ) ) + { /* la piste est ici bonne a etre efface */ + pt_segm->Draw( DrawPanel, DC, GR_XOR ); + DeleteStructure( pt_segm ); + } + } + } + + /* Rafraichissement de l'ecran : */ + RedrawActiveWindow( DC, TRUE ); + if( g_Show_Ratsnest ) + Compile_Ratsnest( DC, TRUE ); } /****************************************************/ -void WinEDA_BasePcbFrame::Block_Rotate(wxDC *DC) +void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) /****************************************************/ + /* - routine de Rotation de 90 deg du block deja selectionne - les elements sont tournes autour du centre du block -*/ + * routine de Rotation de 90 deg du block deja selectionne + * les elements sont tournes autour du centre du block + */ { -MODULE * module; -EDA_BaseStruct * PtStruct; -int masque_layer; -wxPoint oldpos; -int Nx, Ny, centerX, centerY; /* centre de rotation de l'ensemble des elements */ + MODULE* module; + EDA_BaseStruct* PtStruct; + int masque_layer; + wxPoint oldpos; + int Nx, Ny, centerX, centerY; /* centre de rotation de l'ensemble des elements */ - if( ! InstallBlockCmdFrame(this, _("Rotate Block") ) ) return ; + if( !InstallBlockCmdFrame( this, _( "Rotate Block" ) ) ) + return; - oldpos = GetScreen()->m_Curseur; - GetScreen()->BlockLocate.Normalize(); + oldpos = GetScreen()->m_Curseur; + GetScreen()->BlockLocate.Normalize(); - /* calcul du centre de Rotation */ - centerX = GetScreen()->BlockLocate.Centre().x; - centerY = GetScreen()->BlockLocate.Centre().y; + /* calcul du centre de Rotation */ + centerX = GetScreen()->BlockLocate.Centre().x; + centerY = GetScreen()->BlockLocate.Centre().y; - GetScreen()->SetModify(); + GetScreen()->SetModify(); - /* Rotation des modules */ - if ( Block_Include_Modules ) - { - Affiche_Message( _("Footprint rotation") ); - bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false; - int Angle_Rot_Module = 900; - module = m_Pcb->m_Modules; - for ( ; module != NULL; module = (MODULE*) module->Pnext) - { - if( IsModuleInBox(GetScreen()->BlockLocate, module) == NULL ) continue; - /* le module est ici bon a etre modifie */ - m_Pcb->m_Status_Pcb = 0 ; - module->m_Flags = 0; - module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ; + /* Rotation des modules */ + if( Block_Include_Modules ) + { + Affiche_Message( _( "Footprint rotation" ) ); + bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false; + int Angle_Rot_Module = 900; + module = m_Pcb->m_Modules; + for( ; module != NULL; module = (MODULE*) module->Pnext ) + { + if( IsModuleInBox( GetScreen()->BlockLocate, module ) == NULL ) + continue; + /* le module est ici bon a etre modifie */ + m_Pcb->m_Status_Pcb = 0; + module->m_Flags = 0; + module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); - /* calcul de la nouvelle position du Module */ - Nx = module->m_Pos.x; Ny = module->m_Pos.y; - RotatePoint(&Nx, &Ny, centerX, centerY, 900 ); - GetScreen()->m_Curseur.x = Nx ; - GetScreen()->m_Curseur.y = Ny ; - Place_Module(module, DC); + /* calcul de la nouvelle position du Module */ + Nx = module->m_Pos.x; Ny = module->m_Pos.y; + RotatePoint( &Nx, &Ny, centerX, centerY, 900 ); + GetScreen()->m_Curseur.x = Nx; + GetScreen()->m_Curseur.y = Ny; + Place_Module( module, DC ); - /* Rotation du module autour de son ancre */ - Rotate_Module(DC, module, Angle_Rot_Module, TRUE); + /* Rotation du module autour de son ancre */ + Rotate_Module( DC, module, Angle_Rot_Module, TRUE ); + } - } - /* regeneration des valeurs originelles */ - GetScreen()->m_Curseur = oldpos; - g_Show_Ratsnest = Show_Ratsnest_tmp; - } + /* regeneration des valeurs originelles */ + GetScreen()->m_Curseur = oldpos; + g_Show_Ratsnest = Show_Ratsnest_tmp; + } - /* Deplacement des Segments de piste */ - if(Block_Include_Tracks ) - { - TRACK * track; + /* Deplacement des Segments de piste */ + if( Block_Include_Tracks ) + { + TRACK* track; - Affiche_Message( _("Track rotation") ); - track = m_Pcb->m_Track; - while( track ) - { - if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) - { /* la piste est ici bonne a etre deplacee */ - m_Pcb->m_Status_Pcb = 0 ; - track->Draw(DrawPanel, DC, GR_XOR) ; // effacement - RotatePoint( &track->m_Start.x, &track->m_Start.y, centerX, centerY, 900); - RotatePoint( &track->m_End.x, &track->m_End.y, centerX, centerY, 900); - track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage - } - track = track->Next(); - } - } + Affiche_Message( _( "Track rotation" ) ); + track = m_Pcb->m_Track; + while( track ) + { + if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + m_Pcb->m_Status_Pcb = 0; + track->Draw( DrawPanel, DC, GR_XOR ); // effacement + RotatePoint( &track->m_Start.x, &track->m_Start.y, centerX, centerY, 900 ); + RotatePoint( &track->m_End.x, &track->m_End.y, centerX, centerY, 900 ); + track->Draw( DrawPanel, DC, GR_OR ); // reaffichage + } + track = track->Next(); + } + } - /* Deplacement des Segments de Zone */ - if( Block_Include_Zones ) - { - TRACK * track; + /* Deplacement des Segments de Zone */ + if( Block_Include_Zones ) + { + TRACK* track; - Affiche_Message( _("Zone rotation") ); - track = (TRACK*) m_Pcb->m_Zone; - while( track ) - { - if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) - { /* la piste est ici bonne a etre deplacee */ - track->Draw(DrawPanel, DC, GR_XOR) ; // effacement - RotatePoint( &track->m_Start.x, &track->m_Start.y, centerX, centerY, 900); - RotatePoint( &track->m_End.x, &track->m_End.y, centerX, centerY, 900); - track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage - } - track = track->Next(); - } - } + Affiche_Message( _( "Zone rotation" ) ); + track = (TRACK*) m_Pcb->m_Zone; + while( track ) + { + if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + track->Draw( DrawPanel, DC, GR_XOR ); // effacement + RotatePoint( &track->m_Start.x, &track->m_Start.y, centerX, centerY, 900 ); + RotatePoint( &track->m_End.x, &track->m_End.y, centerX, centerY, 900 ); + track->Draw( DrawPanel, DC, GR_OR ); // reaffichage + } + track = track->Next(); + } + } - masque_layer = EDGE_LAYER; - if( Block_Include_Draw_Items ) masque_layer = ALL_LAYERS; - if( ! Block_Include_Edges_Items ) masque_layer &= ~EDGE_LAYER; + masque_layer = EDGE_LAYER; + if( Block_Include_Draw_Items ) + masque_layer = ALL_LAYERS; + if( !Block_Include_Edges_Items ) + masque_layer &= ~EDGE_LAYER; - Affiche_Message( _("Draw layers rotation") ); - PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) - { - switch( PtStruct->m_StructType ) - { - case TYPEDRAWSEGMENT: - #undef STRUCT - #define STRUCT ((DRAWSEGMENT*)PtStruct) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* l'element est ici bon a etre efface */ - Trace_DrawSegmentPcb(DrawPanel, DC, (DRAWSEGMENT*)PtStruct,GR_XOR) ; - RotatePoint( &STRUCT->m_Start.x, &STRUCT->m_Start.y, centerX, centerY, 900); - RotatePoint( &STRUCT->m_End.x, &STRUCT->m_End.y, centerX, centerY, 900); - Trace_DrawSegmentPcb(DrawPanel, DC, (DRAWSEGMENT*)PtStruct,GR_OR) ; - break; + Affiche_Message( _( "Draw layers rotation" ) ); + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + #undef STRUCT + #define STRUCT ( (DRAWSEGMENT*) PtStruct ) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* l'element est ici bon a etre efface */ + Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) PtStruct, GR_XOR ); + RotatePoint( &STRUCT->m_Start.x, &STRUCT->m_Start.y, centerX, centerY, 900 ); + RotatePoint( &STRUCT->m_End.x, &STRUCT->m_End.y, centerX, centerY, 900 ); + Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) PtStruct, GR_OR ); + break; - case TYPETEXTE: - #undef STRUCT - #define STRUCT ((TEXTE_PCB*) PtStruct) - if( ! Block_Include_PcbTextes ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* le texte est ici bon a etre deplace */ - ((TEXTE_PCB*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); - /* Redessin du Texte */ - RotatePoint( &STRUCT->m_Pos.x, &STRUCT->m_Pos.y, centerX, centerY, 900); - STRUCT->m_Orient += 900; - if( STRUCT->m_Orient >= 3600) STRUCT->m_Orient -= 3600; + case TYPETEXTE: + #undef STRUCT + #define STRUCT ( (TEXTE_PCB*) PtStruct ) + if( !Block_Include_PcbTextes ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* le texte est ici bon a etre deplace */ + ( (TEXTE_PCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + /* Redessin du Texte */ + RotatePoint( &STRUCT->m_Pos.x, &STRUCT->m_Pos.y, centerX, centerY, 900 ); + STRUCT->m_Orient += 900; + if( STRUCT->m_Orient >= 3600 ) + STRUCT->m_Orient -= 3600; - STRUCT->CreateDrawData(); - ((TEXTE_PCB*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR); - break; + STRUCT->CreateDrawData(); + ( (TEXTE_PCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + break; - case TYPEMIRE: - #undef STRUCT - #define STRUCT ((MIREPCB*) PtStruct) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* l'element est ici bon a etre modifie */ - ((MIREPCB*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR) ; - RotatePoint(&STRUCT->m_Pos.x, &STRUCT->m_Pos.y, centerX, centerY, 900 ); - ((MIREPCB*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_OR) ; - break; + case TYPEMIRE: + #undef STRUCT + #define STRUCT ( (MIREPCB*) PtStruct ) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* l'element est ici bon a etre modifie */ + ( (MIREPCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + RotatePoint( &STRUCT->m_Pos.x, &STRUCT->m_Pos.y, centerX, centerY, 900 ); + ( (MIREPCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + break; - case TYPECOTATION: - #undef STRUCT - #define STRUCT ((COTATION*) PtStruct) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* l'element est ici bon a etre modifie */ - ((COTATION*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR) ; + case TYPECOTATION: + #undef STRUCT + #define STRUCT ( (COTATION*) PtStruct ) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* l'element est ici bon a etre modifie */ + ( (COTATION*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); - RotatePoint(&STRUCT->m_Pos.x, &STRUCT->m_Pos.y, centerX, centerY, 900 ); + RotatePoint( &STRUCT->m_Pos.x, &STRUCT->m_Pos.y, centerX, centerY, 900 ); - RotatePoint(&STRUCT->m_Text->m_Pos.x, &STRUCT->m_Text->m_Pos.y, - centerX, centerY, 900 ); - STRUCT->m_Text->m_Orient += 900; - if( STRUCT->m_Text->m_Orient >= 3600 ) - STRUCT->m_Text->m_Orient -= 3600; - if( (STRUCT->m_Text->m_Orient > 900) && - (STRUCT->m_Text->m_Orient <2700) ) - STRUCT->m_Text->m_Orient -= 1800; + RotatePoint( &STRUCT->m_Text->m_Pos.x, &STRUCT->m_Text->m_Pos.y, + centerX, centerY, 900 ); + STRUCT->m_Text->m_Orient += 900; + if( STRUCT->m_Text->m_Orient >= 3600 ) + STRUCT->m_Text->m_Orient -= 3600; + if( (STRUCT->m_Text->m_Orient > 900) + && (STRUCT->m_Text->m_Orient <2700) ) + STRUCT->m_Text->m_Orient -= 1800; - RotatePoint(&STRUCT->Barre_ox, &STRUCT->Barre_oy, centerX, centerY, 900 ); - RotatePoint(&STRUCT->Barre_fx, &STRUCT->Barre_fy, centerX, centerY, 900 ); - RotatePoint(&STRUCT->TraitG_ox, &STRUCT->TraitG_oy, centerX, centerY, 900 ); - RotatePoint(&STRUCT->TraitG_fx, &STRUCT->TraitG_fy, centerX, centerY, 900 ); - RotatePoint(&STRUCT->TraitD_ox, &STRUCT->TraitD_oy, centerX, centerY, 900 ); - RotatePoint(&STRUCT->TraitD_fx, &STRUCT->TraitD_fy, centerX, centerY, 900 ); - RotatePoint(&STRUCT->FlecheG1_ox, &STRUCT->FlecheG1_oy, centerX, centerY, 900 ); - RotatePoint(&STRUCT->FlecheG1_fx, &STRUCT->FlecheG1_fy, centerX, centerY, 900 ); - RotatePoint(&STRUCT->FlecheG2_ox, &STRUCT->FlecheG2_oy, centerX, centerY, 900 ); - RotatePoint(&STRUCT->FlecheG2_fx, &STRUCT->FlecheG2_fy, centerX, centerY, 900 ); - RotatePoint(&STRUCT->FlecheD1_ox, &STRUCT->FlecheD1_oy, centerX, centerY, 900 ); - RotatePoint(&STRUCT->FlecheD1_fx, &STRUCT->FlecheD1_fy, centerX, centerY, 900 ); - RotatePoint(&STRUCT->FlecheD2_ox, &STRUCT->FlecheD2_oy, centerX, centerY, 900 ); - RotatePoint(&STRUCT->FlecheD2_fx, &STRUCT->FlecheD2_fy, centerX, centerY, 900 ); - ((COTATION*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_OR) ; - break; + RotatePoint( &STRUCT->Barre_ox, &STRUCT->Barre_oy, centerX, centerY, 900 ); + RotatePoint( &STRUCT->Barre_fx, &STRUCT->Barre_fy, centerX, centerY, 900 ); + RotatePoint( &STRUCT->TraitG_ox, &STRUCT->TraitG_oy, centerX, centerY, 900 ); + RotatePoint( &STRUCT->TraitG_fx, &STRUCT->TraitG_fy, centerX, centerY, 900 ); + RotatePoint( &STRUCT->TraitD_ox, &STRUCT->TraitD_oy, centerX, centerY, 900 ); + RotatePoint( &STRUCT->TraitD_fx, &STRUCT->TraitD_fy, centerX, centerY, 900 ); + RotatePoint( &STRUCT->FlecheG1_ox, &STRUCT->FlecheG1_oy, centerX, centerY, 900 ); + RotatePoint( &STRUCT->FlecheG1_fx, &STRUCT->FlecheG1_fy, centerX, centerY, 900 ); + RotatePoint( &STRUCT->FlecheG2_ox, &STRUCT->FlecheG2_oy, centerX, centerY, 900 ); + RotatePoint( &STRUCT->FlecheG2_fx, &STRUCT->FlecheG2_fy, centerX, centerY, 900 ); + RotatePoint( &STRUCT->FlecheD1_ox, &STRUCT->FlecheD1_oy, centerX, centerY, 900 ); + RotatePoint( &STRUCT->FlecheD1_fx, &STRUCT->FlecheD1_fy, centerX, centerY, 900 ); + RotatePoint( &STRUCT->FlecheD2_ox, &STRUCT->FlecheD2_oy, centerX, centerY, 900 ); + RotatePoint( &STRUCT->FlecheD2_fx, &STRUCT->FlecheD2_fy, centerX, centerY, 900 ); + ( (COTATION*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + break; - default: break; - } - } - RedrawActiveWindow(DC, TRUE) ; - if ( g_Show_Ratsnest ) Compile_Ratsnest( DC, TRUE ); + default: + break; + } + } + + RedrawActiveWindow( DC, TRUE ); + if( g_Show_Ratsnest ) + Compile_Ratsnest( DC, TRUE ); } +/*****************************************************/ +void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) +/*****************************************************/ -/*****************************************************/ -void WinEDA_BasePcbFrame::Block_Invert(wxDC * DC) -/*****************************************************/ /* - routine d'inversion miroir deg du block deja selectionne - les elements sont inverse / axe horizontal, - l'axe d'inversion est la mediane horizontale du block -*/ -#define INVERT(pos) (pos) = centerY - ((pos) - centerY) -#define INVERT_ANGLE(phi) (phi) = -(phi) + * routine d'inversion miroir deg du block deja selectionne + * les elements sont inverse / axe horizontal, + * l'axe d'inversion est la mediane horizontale du block + */ +#define INVERT( pos ) (pos) = centerY - ( (pos) - centerY ) +#define INVERT_ANGLE( phi ) (phi) = -(phi) { -MODULE * module; -EDA_BaseStruct * PtStruct; -int masque_layer; -wxPoint memo; -int Ny, centerY; /* position de l'axe d'inversion de l'ensemble des elements */ + MODULE* module; + EDA_BaseStruct* PtStruct; + int masque_layer; + wxPoint memo; + int Ny, centerY;/* position de l'axe d'inversion de l'ensemble des elements */ - if( ! InstallBlockCmdFrame(this, _("Block mirroring")) ) return ; + if( !InstallBlockCmdFrame( this, _( "Block mirroring" ) ) ) + return; - memo = GetScreen()->m_Curseur; - GetScreen()->BlockLocate.Normalize(); + memo = GetScreen()->m_Curseur; + GetScreen()->BlockLocate.Normalize(); - /* calcul du centre d'inversion */ - centerY = GetScreen()->BlockLocate.Centre().y; + /* calcul du centre d'inversion */ + centerY = GetScreen()->BlockLocate.Centre().y; - GetScreen()->SetModify(); + GetScreen()->SetModify(); - /* Inversion des modules */ - if ( Block_Include_Modules ) - { - bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false; - Affiche_Message( _("Footprint mirroring") ); - module = m_Pcb->m_Modules; - for ( ; module != NULL; module = (MODULE*) module->Pnext) - { - if( IsModuleInBox(GetScreen()->BlockLocate, module) == NULL ) continue; - /* le module est ici bon a etre efface */ - m_Pcb->m_Status_Pcb = 0 ; - module->m_Flags = 0; - module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ; + /* Inversion des modules */ + if( Block_Include_Modules ) + { + bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false; + Affiche_Message( _( "Footprint mirroring" ) ); + module = m_Pcb->m_Modules; + for( ; module != NULL; module = (MODULE*) module->Pnext ) + { + if( IsModuleInBox( GetScreen()->BlockLocate, module ) == NULL ) + continue; + /* le module est ici bon a etre efface */ + m_Pcb->m_Status_Pcb = 0; + module->m_Flags = 0; + module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); - /* calcul de la nouvelle position du Module */ - Ny = module->m_Pos.y; - INVERT(Ny); - GetScreen()->m_Curseur.x = module->m_Pos.x; - GetScreen()->m_Curseur.y = Ny ; - Place_Module(module, DC); + /* calcul de la nouvelle position du Module */ + Ny = module->m_Pos.y; + INVERT( Ny ); + GetScreen()->m_Curseur.x = module->m_Pos.x; + GetScreen()->m_Curseur.y = Ny; + Place_Module( module, DC ); - /* inversion du module */ - Change_Side_Module(module, DC); + /* inversion du module */ + Change_Side_Module( module, DC ); - /* regeneration des valeurs originelles */ - GetScreen()->m_Curseur = memo; - } - g_Show_Ratsnest = Show_Ratsnest_tmp; - } + /* regeneration des valeurs originelles */ + GetScreen()->m_Curseur = memo; + } - /* Deplacement des Segments de piste */ - if(Block_Include_Tracks ) - { - TRACK * track; + g_Show_Ratsnest = Show_Ratsnest_tmp; + } - Affiche_Message( _("Track mirroring") ); - track = m_Pcb->m_Track; - while( track ) - { - if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) - { /* la piste est ici bonne a etre deplacee */ - m_Pcb->m_Status_Pcb = 0 ; - track->Draw(DrawPanel, DC, GR_XOR) ; // effacement - INVERT(track->m_Start.y); - INVERT(track->m_End.y); - if( track->m_StructType != TYPEVIA ) - { - track->m_Layer = ChangeSideNumLayer(track->m_Layer); - } + /* Deplacement des Segments de piste */ + if( Block_Include_Tracks ) + { + TRACK* track; - track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage - } - track = (TRACK*) track->Pnext; - } - } + Affiche_Message( _( "Track mirroring" ) ); + track = m_Pcb->m_Track; + while( track ) + { + if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + m_Pcb->m_Status_Pcb = 0; + track->Draw( DrawPanel, DC, GR_XOR ); // effacement + INVERT( track->m_Start.y ); + INVERT( track->m_End.y ); + if( track->m_StructType != TYPEVIA ) + { + track->m_Layer = ChangeSideNumLayer( track->m_Layer ); + } - /* Deplacement des Segments de Zone */ - if( Block_Include_Zones ) - { - TRACK * track; + track->Draw( DrawPanel, DC, GR_OR ); // reaffichage + } + track = (TRACK*) track->Pnext; + } + } - Affiche_Message( _("Zone mirroring") ); - track = (TRACK*)m_Pcb->m_Zone; - while( track ) - { - if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) - { /* la piste est ici bonne a etre deplacee */ - track->Draw(DrawPanel, DC, GR_XOR) ; // effacement - INVERT(track->m_Start.y); - INVERT(track->m_End.y); - track->m_Layer = ChangeSideNumLayer(track->m_Layer); - track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage - } - track = (TRACK*) track->Pnext; - } - } + /* Deplacement des Segments de Zone */ + if( Block_Include_Zones ) + { + TRACK* track; - masque_layer = EDGE_LAYER; - if( Block_Include_Draw_Items ) masque_layer = ALL_LAYERS; - if( ! Block_Include_Edges_Items ) masque_layer &= ~EDGE_LAYER; + Affiche_Message( _( "Zone mirroring" ) ); + track = (TRACK*) m_Pcb->m_Zone; + while( track ) + { + if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + track->Draw( DrawPanel, DC, GR_XOR ); // effacement + INVERT( track->m_Start.y ); + INVERT( track->m_End.y ); + track->m_Layer = ChangeSideNumLayer( track->m_Layer ); + track->Draw( DrawPanel, DC, GR_OR ); // reaffichage + } + track = (TRACK*) track->Pnext; + } + } - Affiche_Message( _("Draw layers mirroring") ); - PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) - { - switch( PtStruct->m_StructType ) - { - case TYPEDRAWSEGMENT: - #undef STRUCT - #define STRUCT ((DRAWSEGMENT*)PtStruct) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* l'element est ici bon a etre selectionne */ - Trace_DrawSegmentPcb(DrawPanel, DC, (DRAWSEGMENT*)PtStruct,GR_XOR) ; - if ( STRUCT->m_Shape == S_ARC ) - { - INVERT_ANGLE(STRUCT->m_Angle); - } - INVERT(STRUCT->m_Start.y); - INVERT(STRUCT->m_End.y); - STRUCT->m_Layer = ChangeSideNumLayer(STRUCT->m_Layer); - Trace_DrawSegmentPcb(DrawPanel, DC, (DRAWSEGMENT*)PtStruct,GR_OR) ; - break; + masque_layer = EDGE_LAYER; + if( Block_Include_Draw_Items ) + masque_layer = ALL_LAYERS; + if( !Block_Include_Edges_Items ) + masque_layer &= ~EDGE_LAYER; - case TYPETEXTE: - #undef STRUCT - #define STRUCT ((TEXTE_PCB*) PtStruct) - if( ! Block_Include_PcbTextes ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* le texte est ici bon a etre selectionne*/ - ((TEXTE_PCB*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); - /* Redessin du Texte */ - INVERT(STRUCT->m_Pos.y); - INVERT_ANGLE(STRUCT->m_Orient); - if( (STRUCT->m_Layer == CUIVRE_N) || (STRUCT->m_Layer == CMP_N) ) - { - STRUCT->m_Miroir ^= 1; /* inverse miroir */ - } - STRUCT->m_Layer = ChangeSideNumLayer(STRUCT->m_Layer); - STRUCT->CreateDrawData(); - ((TEXTE_PCB*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR); - break; + Affiche_Message( _( "Draw layers mirroring" ) ); + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + #undef STRUCT + #define STRUCT ( (DRAWSEGMENT*) PtStruct ) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* l'element est ici bon a etre selectionne */ + Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) PtStruct, GR_XOR ); + if( STRUCT->m_Shape == S_ARC ) + { + INVERT_ANGLE( STRUCT->m_Angle ); + } + INVERT( STRUCT->m_Start.y ); + INVERT( STRUCT->m_End.y ); + STRUCT->m_Layer = ChangeSideNumLayer( STRUCT->m_Layer ); + Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) PtStruct, GR_OR ); + break; - case TYPEMIRE: - #undef STRUCT - #define STRUCT ((MIREPCB*) PtStruct) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* l'element est ici bon a etre modifie */ - ((MIREPCB*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0),GR_XOR) ; - INVERT(STRUCT->m_Pos.y); - STRUCT->m_Layer = ChangeSideNumLayer(STRUCT->m_Layer); - ((MIREPCB*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0),GR_OR) ; - break; + case TYPETEXTE: + #undef STRUCT + #define STRUCT ( (TEXTE_PCB*) PtStruct ) + if( !Block_Include_PcbTextes ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* le texte est ici bon a etre selectionne*/ + ( (TEXTE_PCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + /* Redessin du Texte */ + INVERT( STRUCT->m_Pos.y ); + INVERT_ANGLE( STRUCT->m_Orient ); + if( (STRUCT->m_Layer == CUIVRE_N) || (STRUCT->m_Layer == CMP_N) ) + { + STRUCT->m_Miroir ^= 1; /* inverse miroir */ + } + STRUCT->m_Layer = ChangeSideNumLayer( STRUCT->m_Layer ); + STRUCT->CreateDrawData(); + ( (TEXTE_PCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + break; - case TYPECOTATION: - #undef STRUCT - #define STRUCT ((COTATION*) PtStruct) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* l'element est ici bon a etre modifie */ - ((COTATION*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR) ; + case TYPEMIRE: + #undef STRUCT + #define STRUCT ( (MIREPCB*) PtStruct ) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* l'element est ici bon a etre modifie */ + ( (MIREPCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + INVERT( STRUCT->m_Pos.y ); + STRUCT->m_Layer = ChangeSideNumLayer( STRUCT->m_Layer ); + ( (MIREPCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + break; - INVERT(STRUCT->m_Pos.y); - INVERT(STRUCT->m_Text->m_Pos.y); - INVERT_ANGLE(STRUCT->m_Text->m_Orient); - if( STRUCT->m_Text->m_Orient >= 3600 ) - STRUCT->m_Text->m_Orient -= 3600; - if( (STRUCT->m_Text->m_Orient > 900) && - (STRUCT->m_Text->m_Orient <2700) ) - STRUCT->m_Text->m_Orient -= 1800; + case TYPECOTATION: + #undef STRUCT + #define STRUCT ( (COTATION*) PtStruct ) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* l'element est ici bon a etre modifie */ + ( (COTATION*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); - INVERT(STRUCT->Barre_oy); - INVERT(STRUCT->Barre_fy); - INVERT(STRUCT->TraitG_oy); - INVERT(STRUCT->TraitG_fy); - INVERT(STRUCT->TraitD_oy); - INVERT(STRUCT->TraitD_fy); - INVERT(STRUCT->FlecheG1_oy); - INVERT(STRUCT->FlecheG1_fy); - INVERT(STRUCT->FlecheG2_oy); - INVERT(STRUCT->FlecheG2_fy); - INVERT(STRUCT->FlecheD1_oy); - INVERT(STRUCT->FlecheD1_fy); - INVERT(STRUCT->FlecheD2_oy); - INVERT(STRUCT->FlecheD2_fy); + INVERT( STRUCT->m_Pos.y ); + INVERT( STRUCT->m_Text->m_Pos.y ); + INVERT_ANGLE( STRUCT->m_Text->m_Orient ); + if( STRUCT->m_Text->m_Orient >= 3600 ) + STRUCT->m_Text->m_Orient -= 3600; + if( (STRUCT->m_Text->m_Orient > 900) + && (STRUCT->m_Text->m_Orient <2700) ) + STRUCT->m_Text->m_Orient -= 1800; - STRUCT->m_Layer = ChangeSideNumLayer(STRUCT->m_Layer); + INVERT( STRUCT->Barre_oy ); + INVERT( STRUCT->Barre_fy ); + INVERT( STRUCT->TraitG_oy ); + INVERT( STRUCT->TraitG_fy ); + INVERT( STRUCT->TraitD_oy ); + INVERT( STRUCT->TraitD_fy ); + INVERT( STRUCT->FlecheG1_oy ); + INVERT( STRUCT->FlecheG1_fy ); + INVERT( STRUCT->FlecheG2_oy ); + INVERT( STRUCT->FlecheG2_fy ); + INVERT( STRUCT->FlecheD1_oy ); + INVERT( STRUCT->FlecheD1_fy ); + INVERT( STRUCT->FlecheD2_oy ); + INVERT( STRUCT->FlecheD2_fy ); - ((COTATION*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ; - break; + STRUCT->m_Layer = ChangeSideNumLayer( STRUCT->m_Layer ); - default: break; - } - } - RedrawActiveWindow(DC, TRUE) ; - if ( g_Show_Ratsnest ) Compile_Ratsnest( DC, TRUE ); + ( (COTATION*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + break; + + default: + break; + } + } + + RedrawActiveWindow( DC, TRUE ); + if( g_Show_Ratsnest ) + Compile_Ratsnest( DC, TRUE ); } +/************************************************/ +void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) +/************************************************/ -/************************************************/ -void WinEDA_BasePcbFrame::Block_Move(wxDC * DC) -/************************************************/ /* - Function to move items withing the selected block -*/ + * Function to move items withing the selected block + */ { -MODULE * module; -EDA_BaseStruct * PtStruct; -int masque_layer; -int deltaX, deltaY; -wxPoint oldpos; + MODULE* module; + EDA_BaseStruct* PtStruct; + int masque_layer; + int deltaX, deltaY; + wxPoint oldpos; - oldpos = GetScreen()->m_Curseur; - DrawPanel->ManageCurseur = NULL; + oldpos = GetScreen()->m_Curseur; + DrawPanel->ManageCurseur = NULL; - if( ! InstallBlockCmdFrame(this, _("Move Block") ) ) return ; + if( !InstallBlockCmdFrame( this, _( "Move Block" ) ) ) + return; - GetScreen()->m_Curseur = oldpos; - DrawPanel->MouseToCursorSchema(); - GetScreen()->SetModify(); - GetScreen()->BlockLocate.Normalize(); + GetScreen()->m_Curseur = oldpos; + DrawPanel->MouseToCursorSchema(); + GetScreen()->SetModify(); + GetScreen()->BlockLocate.Normalize(); - /* Deplacement des modules */ - if ( Block_Include_Modules ) - { - bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false; - Affiche_Message( _("Move footprints") ); - module = m_Pcb->m_Modules; - oldpos = GetScreen()->m_Curseur; + /* Deplacement des modules */ + if( Block_Include_Modules ) + { + bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false; + Affiche_Message( _( "Move footprints" ) ); + module = m_Pcb->m_Modules; + oldpos = GetScreen()->m_Curseur; - for ( ; module != NULL; module = (MODULE*) module->Pnext) - { - if( IsModuleInBox(GetScreen()->BlockLocate, module) == NULL ) continue; - /* le module est ici bon a etre deplace */ - m_Pcb->m_Status_Pcb = 0 ; - module->m_Flags = 0; - module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ; + for( ; module != NULL; module = (MODULE*) module->Pnext ) + { + if( IsModuleInBox( GetScreen()->BlockLocate, module ) == NULL ) + continue; + /* le module est ici bon a etre deplace */ + m_Pcb->m_Status_Pcb = 0; + module->m_Flags = 0; + module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); - /* calcul du deplacement pour la routine Place_Module */ - /* calcul du vecteur de deplacement */ - GetScreen()->m_Curseur.x = module->m_Pos.x + GetScreen()->BlockLocate.m_MoveVector.x; - GetScreen()->m_Curseur.y = module->m_Pos.y + GetScreen()->BlockLocate.m_MoveVector.y; - Place_Module(module, DC); - } - GetScreen()->m_Curseur = oldpos; - g_Show_Ratsnest = Show_Ratsnest_tmp; - } + /* calcul du deplacement pour la routine Place_Module */ + /* calcul du vecteur de deplacement */ + GetScreen()->m_Curseur.x = module->m_Pos.x + GetScreen()->BlockLocate.m_MoveVector.x; + GetScreen()->m_Curseur.y = module->m_Pos.y + GetScreen()->BlockLocate.m_MoveVector.y; + Place_Module( module, DC ); + } - /* calcul du vecteur de deplacement pour les deplacements suivants */ - deltaX = GetScreen()->BlockLocate.m_MoveVector.x ; - deltaY = GetScreen()->BlockLocate.m_MoveVector.y ; + GetScreen()->m_Curseur = oldpos; + g_Show_Ratsnest = Show_Ratsnest_tmp; + } - /* Deplacement des Segments de piste */ - if(Block_Include_Tracks ) - { - TRACK * track; + /* calcul du vecteur de deplacement pour les deplacements suivants */ + deltaX = GetScreen()->BlockLocate.m_MoveVector.x; + deltaY = GetScreen()->BlockLocate.m_MoveVector.y; - Affiche_Message( _("Move tracks") ); - track = m_Pcb->m_Track; - while( track ) - { - if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) - { /* la piste est ici bonne a etre deplacee */ - m_Pcb->m_Status_Pcb = 0 ; - track->Draw(DrawPanel, DC, GR_XOR) ; // effacement - track->m_Start.x += deltaX ; track->m_Start.y += deltaY ; - track->m_End.x += deltaX ; track->m_End.y += deltaY ; - track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage - } - track = (TRACK*) track->Pnext; - } - } + /* Deplacement des Segments de piste */ + if( Block_Include_Tracks ) + { + TRACK* track; - /* Deplacement des Segments de Zone */ - if( Block_Include_Zones ) - { - TRACK * track; + Affiche_Message( _( "Move tracks" ) ); + track = m_Pcb->m_Track; + while( track ) + { + if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + m_Pcb->m_Status_Pcb = 0; + track->Draw( DrawPanel, DC, GR_XOR ); // effacement + track->m_Start.x += deltaX; track->m_Start.y += deltaY; + track->m_End.x += deltaX; track->m_End.y += deltaY; + track->Draw( DrawPanel, DC, GR_OR ); // reaffichage + } + track = (TRACK*) track->Pnext; + } + } - Affiche_Message( _("Move zones") ); - track = (TRACK*)m_Pcb->m_Zone; - while( track ) - { - if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) - { /* la piste est ici bonne a etre deplacee */ - track->Draw(DrawPanel, DC, GR_XOR) ; // effacement - track->m_Start.x += deltaX ; track->m_Start.y += deltaY ; - track->m_End.x += deltaX ; track->m_End.y += deltaY ; - track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage - } - track = (TRACK*) track->Pnext; - } - } + /* Deplacement des Segments de Zone */ + if( Block_Include_Zones ) + { + TRACK* track; - masque_layer = EDGE_LAYER; - if( Block_Include_Draw_Items ) masque_layer = ALL_LAYERS; - if( ! Block_Include_Edges_Items ) masque_layer &= ~EDGE_LAYER; + Affiche_Message( _( "Move zones" ) ); + track = (TRACK*) m_Pcb->m_Zone; + while( track ) + { + if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + track->Draw( DrawPanel, DC, GR_XOR ); // effacement + track->m_Start.x += deltaX; track->m_Start.y += deltaY; + track->m_End.x += deltaX; track->m_End.y += deltaY; + track->Draw( DrawPanel, DC, GR_OR ); // reaffichage + } + track = (TRACK*) track->Pnext; + } + } - Affiche_Message( _("Move draw layers") ); - PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) - { - switch( PtStruct->m_StructType ) - { - case TYPEDRAWSEGMENT: - #undef STRUCT - #define STRUCT ((DRAWSEGMENT*)PtStruct) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* l'element est ici bon a etre efface */ - Trace_DrawSegmentPcb(DrawPanel, DC, STRUCT,GR_XOR) ; - STRUCT->m_Start.x += deltaX; STRUCT->m_Start.y += deltaY; - STRUCT->m_End.x += deltaX; STRUCT->m_End.y += deltaY; - Trace_DrawSegmentPcb(DrawPanel, DC, STRUCT,GR_OR) ; - break; + masque_layer = EDGE_LAYER; + if( Block_Include_Draw_Items ) + masque_layer = ALL_LAYERS; + if( !Block_Include_Edges_Items ) + masque_layer &= ~EDGE_LAYER; - case TYPETEXTE: - #undef STRUCT - #define STRUCT ((TEXTE_PCB*) PtStruct) - if( ! Block_Include_PcbTextes ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* le texte est ici bon a etre deplace */ - STRUCT->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); - /* Redessin du Texte */ - STRUCT->m_Pos.x += deltaX; STRUCT->m_Pos.y += deltaY; - ((TEXTE_PCB*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR); - break; + Affiche_Message( _( "Move draw layers" ) ); + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + #undef STRUCT + #define STRUCT ( (DRAWSEGMENT*) PtStruct ) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* l'element est ici bon a etre efface */ + Trace_DrawSegmentPcb( DrawPanel, DC, STRUCT, GR_XOR ); + STRUCT->m_Start.x += deltaX; STRUCT->m_Start.y += deltaY; + STRUCT->m_End.x += deltaX; STRUCT->m_End.y += deltaY; + Trace_DrawSegmentPcb( DrawPanel, DC, STRUCT, GR_OR ); + break; - case TYPEMIRE: - #undef STRUCT - #define STRUCT ((MIREPCB*) PtStruct) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* l'element est ici bon a etre efface */ - ((MIREPCB*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0),GR_XOR) ; - STRUCT->m_Pos.x += deltaX; STRUCT->m_Pos.y += deltaY; - ((MIREPCB*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0),GR_OR) ; - break; + case TYPETEXTE: + #undef STRUCT + #define STRUCT ( (TEXTE_PCB*) PtStruct ) + if( !Block_Include_PcbTextes ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* le texte est ici bon a etre deplace */ + STRUCT->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + /* Redessin du Texte */ + STRUCT->m_Pos.x += deltaX; STRUCT->m_Pos.y += deltaY; + ( (TEXTE_PCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + break; - case TYPECOTATION: - #undef STRUCT - #define STRUCT ((COTATION*) PtStruct) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* l'element est ici bon a etre efface */ - ((COTATION*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR) ; - STRUCT->m_Pos.x += deltaX; - STRUCT->m_Pos.y += deltaY; - STRUCT->m_Text->m_Pos.x += deltaX; - STRUCT->m_Text->m_Pos.y += deltaY; - STRUCT->Barre_ox += deltaX; STRUCT->Barre_oy += deltaY; - STRUCT->Barre_fx += deltaX; STRUCT->Barre_fy += deltaY; - STRUCT->TraitG_ox += deltaX; STRUCT->TraitG_oy += deltaY; - STRUCT->TraitG_fx += deltaX; STRUCT->TraitG_fy += deltaY; - STRUCT->TraitD_ox += deltaX; STRUCT->TraitD_oy += deltaY; - STRUCT->TraitD_fx += deltaX; STRUCT->TraitD_fy += deltaY; - STRUCT->FlecheG1_ox += deltaX; STRUCT->FlecheG1_oy += deltaY; - STRUCT->FlecheG1_fx += deltaX; STRUCT->FlecheG1_fy += deltaY; - STRUCT->FlecheG2_ox += deltaX; STRUCT->FlecheG2_oy += deltaY; - STRUCT->FlecheG2_fx += deltaX; STRUCT->FlecheG2_fy += deltaY; - STRUCT->FlecheD1_ox += deltaX; STRUCT->FlecheD1_oy += deltaY; - STRUCT->FlecheD1_fx += deltaX; STRUCT->FlecheD1_fy += deltaY; - STRUCT->FlecheD2_ox += deltaX; STRUCT->FlecheD2_oy += deltaY; - STRUCT->FlecheD2_fx += deltaX; STRUCT->FlecheD2_fy += deltaY; - ((COTATION*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_OR) ; - break; + case TYPEMIRE: + #undef STRUCT + #define STRUCT ( (MIREPCB*) PtStruct ) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* l'element est ici bon a etre efface */ + ( (MIREPCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + STRUCT->m_Pos.x += deltaX; STRUCT->m_Pos.y += deltaY; + ( (MIREPCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + break; - default: break; - } - } - DrawPanel->Refresh(TRUE);; - if ( g_Show_Ratsnest ) Compile_Ratsnest( DC, TRUE ); + case TYPECOTATION: + #undef STRUCT + #define STRUCT ( (COTATION*) PtStruct ) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* l'element est ici bon a etre efface */ + ( (COTATION*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + STRUCT->m_Pos.x += deltaX; + STRUCT->m_Pos.y += deltaY; + STRUCT->m_Text->m_Pos.x += deltaX; + STRUCT->m_Text->m_Pos.y += deltaY; + STRUCT->Barre_ox += deltaX; STRUCT->Barre_oy += deltaY; + STRUCT->Barre_fx += deltaX; STRUCT->Barre_fy += deltaY; + STRUCT->TraitG_ox += deltaX; STRUCT->TraitG_oy += deltaY; + STRUCT->TraitG_fx += deltaX; STRUCT->TraitG_fy += deltaY; + STRUCT->TraitD_ox += deltaX; STRUCT->TraitD_oy += deltaY; + STRUCT->TraitD_fx += deltaX; STRUCT->TraitD_fy += deltaY; + STRUCT->FlecheG1_ox += deltaX; STRUCT->FlecheG1_oy += deltaY; + STRUCT->FlecheG1_fx += deltaX; STRUCT->FlecheG1_fy += deltaY; + STRUCT->FlecheG2_ox += deltaX; STRUCT->FlecheG2_oy += deltaY; + STRUCT->FlecheG2_fx += deltaX; STRUCT->FlecheG2_fy += deltaY; + STRUCT->FlecheD1_ox += deltaX; STRUCT->FlecheD1_oy += deltaY; + STRUCT->FlecheD1_fx += deltaX; STRUCT->FlecheD1_fy += deltaY; + STRUCT->FlecheD2_ox += deltaX; STRUCT->FlecheD2_oy += deltaY; + STRUCT->FlecheD2_fx += deltaX; STRUCT->FlecheD2_fy += deltaY; + ( (COTATION*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + break; + + default: + break; + } + } + + DrawPanel->Refresh( TRUE );; + if( g_Show_Ratsnest ) + Compile_Ratsnest( DC, TRUE ); } /**************************************************/ -void WinEDA_BasePcbFrame::Block_Duplicate(wxDC * DC) +void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) /**************************************************/ + /* - routine de duplication des elements du block deja selectionne -*/ + * routine de duplication des elements du block deja selectionne + */ { -MODULE * module; -EDA_BaseStruct * PtStruct; -int masque_layer; -int deltaX, deltaY; -wxPoint oldpos; + MODULE* module; + EDA_BaseStruct* PtStruct; + int masque_layer; + int deltaX, deltaY; + wxPoint oldpos; - oldpos = GetScreen()->m_Curseur; - DrawPanel->ManageCurseur = NULL; + oldpos = GetScreen()->m_Curseur; + DrawPanel->ManageCurseur = NULL; - if( ! InstallBlockCmdFrame(this, _("Copy Block") ) ) return ; + if( !InstallBlockCmdFrame( this, _( "Copy Block" ) ) ) + return; - GetScreen()->m_Curseur = oldpos; - DrawPanel->MouseToCursorSchema(); - GetScreen()->SetModify(); - GetScreen()->BlockLocate.Normalize(); + GetScreen()->m_Curseur = oldpos; + DrawPanel->MouseToCursorSchema(); + GetScreen()->SetModify(); + GetScreen()->BlockLocate.Normalize(); - /* Module copy */ - if ( Block_Include_Modules ) - { - bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false; - Affiche_Message( _("Module copy") ); - module = m_Pcb->m_Modules; - oldpos = GetScreen()->m_Curseur; + /* Module copy */ + if( Block_Include_Modules ) + { + bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false; + Affiche_Message( _( "Module copy" ) ); + module = m_Pcb->m_Modules; + oldpos = GetScreen()->m_Curseur; - for ( ; module != NULL; module = (MODULE*) module->Pnext) - { - MODULE * new_module; - if( IsModuleInBox(GetScreen()->BlockLocate, module) == NULL ) continue; - /* le module est ici bon a etre deplace */ - m_Pcb->m_Status_Pcb = 0 ; - module->m_Flags = 0; - new_module = new MODULE(m_Pcb); - new_module->Copy(module); - new_module->m_TimeStamp = GetTimeStamp(); - new_module->Pnext = m_Pcb->m_Modules; - new_module->Pback = m_Pcb; - m_Pcb->m_Modules->Pback = new_module; - m_Pcb->m_Modules = new_module; - /* calcul du deplacement pour la routine Place_Module */ - /* calcul du vecteur de deplacement */ - GetScreen()->m_Curseur.x = module->m_Pos.x + GetScreen()->BlockLocate.m_MoveVector.x; - GetScreen()->m_Curseur.y = module->m_Pos.y + GetScreen()->BlockLocate.m_MoveVector.y; - Place_Module(new_module, DC); - } - GetScreen()->m_Curseur = oldpos; - g_Show_Ratsnest = Show_Ratsnest_tmp; - } + for( ; module != NULL; module = (MODULE*) module->Pnext ) + { + MODULE* new_module; + if( IsModuleInBox( GetScreen()->BlockLocate, module ) == NULL ) + continue; + /* le module est ici bon a etre deplace */ + m_Pcb->m_Status_Pcb = 0; + module->m_Flags = 0; + new_module = new MODULE( m_Pcb ); + new_module->Copy( module ); + new_module->m_TimeStamp = GetTimeStamp(); + new_module->Pnext = m_Pcb->m_Modules; + new_module->Pback = m_Pcb; + m_Pcb->m_Modules->Pback = new_module; + m_Pcb->m_Modules = new_module; + /* calcul du deplacement pour la routine Place_Module */ + /* calcul du vecteur de deplacement */ + GetScreen()->m_Curseur.x = module->m_Pos.x + GetScreen()->BlockLocate.m_MoveVector.x; + GetScreen()->m_Curseur.y = module->m_Pos.y + GetScreen()->BlockLocate.m_MoveVector.y; + Place_Module( new_module, DC ); + } - /* calcul du vecteur de deplacement pour les deplacements suivants */ - deltaX = GetScreen()->BlockLocate.m_MoveVector.x ; - deltaY = GetScreen()->BlockLocate.m_MoveVector.y ; + GetScreen()->m_Curseur = oldpos; + g_Show_Ratsnest = Show_Ratsnest_tmp; + } - /* Deplacement des Segments de piste */ - if(Block_Include_Tracks ) - { - TRACK * track, *next_track, *new_track; + /* calcul du vecteur de deplacement pour les deplacements suivants */ + deltaX = GetScreen()->BlockLocate.m_MoveVector.x; + deltaY = GetScreen()->BlockLocate.m_MoveVector.y; - Affiche_Message( _("Track copy") ); - track = m_Pcb->m_Track; - while( track ) - { - next_track = track->Next(); - if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) - { /* la piste est ici bonne a etre deplacee */ - m_Pcb->m_Status_Pcb = 0 ; - new_track = track->Copy(1); - new_track->Insert(m_Pcb,NULL); - new_track->m_Start.x += deltaX ; new_track->m_Start.y += deltaY ; - new_track->m_End.x += deltaX ; new_track->m_End.y += deltaY ; - new_track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage - } - track = next_track; - } - } + /* Deplacement des Segments de piste */ + if( Block_Include_Tracks ) + { + TRACK* track, * next_track, * new_track; - /* Deplacement des Segments de Zone */ - if( Block_Include_Zones ) - { - TRACK * track, *next_track, *new_track; + Affiche_Message( _( "Track copy" ) ); + track = m_Pcb->m_Track; + while( track ) + { + next_track = track->Next(); + if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + m_Pcb->m_Status_Pcb = 0; + new_track = track->Copy( 1 ); + new_track->Insert( m_Pcb, NULL ); + new_track->m_Start.x += deltaX; new_track->m_Start.y += deltaY; + new_track->m_End.x += deltaX; new_track->m_End.y += deltaY; + new_track->Draw( DrawPanel, DC, GR_OR ); // reaffichage + } + track = next_track; + } + } - Affiche_Message( _("Zone copy") ); - track = (TRACK*)m_Pcb->m_Zone; - while( track ) - { - next_track = track->Next(); - if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) - { /* la piste est ici bonne a etre deplacee */ - new_track = new TRACK(m_Pcb); - new_track = track->Copy(1); - new_track->Insert(m_Pcb,NULL); - new_track->m_Start.x += deltaX ; new_track->m_Start.y += deltaY ; - new_track->m_End.x += deltaX ; new_track->m_End.y += deltaY ; - new_track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage - } - track = next_track; - } - } + /* Deplacement des Segments de Zone */ + if( Block_Include_Zones ) + { + TRACK* track, * next_track, * new_track; - masque_layer = EDGE_LAYER; - if( Block_Include_Draw_Items ) masque_layer = ALL_LAYERS; - if( ! Block_Include_Edges_Items ) masque_layer &= ~EDGE_LAYER; + Affiche_Message( _( "Zone copy" ) ); + track = (TRACK*) m_Pcb->m_Zone; + while( track ) + { + next_track = track->Next(); + if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + new_track = new TRACK( m_Pcb ); + new_track = track->Copy( 1 ); + new_track->Insert( m_Pcb, NULL ); + new_track->m_Start.x += deltaX; new_track->m_Start.y += deltaY; + new_track->m_End.x += deltaX; new_track->m_End.y += deltaY; + new_track->Draw( DrawPanel, DC, GR_OR ); // reaffichage + } + track = next_track; + } + } - Affiche_Message( _("Draw layers copy") ); - PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) - { - switch( PtStruct->m_StructType ) - { - case TYPEDRAWSEGMENT: - { - #undef STRUCT - #define STRUCT ((DRAWSEGMENT*)PtStruct) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* l'element est ici bon a etre copie */ - DRAWSEGMENT * new_drawsegment = new DRAWSEGMENT (m_Pcb); - new_drawsegment->Copy(STRUCT); - new_drawsegment->Pnext = m_Pcb->m_Drawings; - new_drawsegment->Pback = m_Pcb; - m_Pcb->m_Drawings->Pback = new_drawsegment; - m_Pcb->m_Drawings = new_drawsegment; - new_drawsegment->m_Start.x += deltaX; new_drawsegment->m_Start.y += deltaY; - new_drawsegment->m_End.x += deltaX; new_drawsegment->m_End.y += deltaY; - Trace_DrawSegmentPcb(DrawPanel, DC, new_drawsegment,GR_OR) ; - break; - } + masque_layer = EDGE_LAYER; + if( Block_Include_Draw_Items ) + masque_layer = ALL_LAYERS; + if( !Block_Include_Edges_Items ) + masque_layer &= ~EDGE_LAYER; - case TYPETEXTE: - { - #undef STRUCT - #define STRUCT ((TEXTE_PCB*) PtStruct) - if( ! Block_Include_PcbTextes ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* le texte est ici bon a etre deplace */ - TEXTE_PCB * new_pcbtext = new TEXTE_PCB(m_Pcb); - new_pcbtext->Copy(STRUCT); - new_pcbtext->Pnext = m_Pcb->m_Drawings; - new_pcbtext->Pback = m_Pcb; - m_Pcb->m_Drawings->Pback = new_pcbtext; - m_Pcb->m_Drawings = new_pcbtext; - /* Redessin du Texte */ - new_pcbtext->m_Pos.x += deltaX; new_pcbtext->m_Pos.y += deltaY; - new_pcbtext->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR); - break; - } + Affiche_Message( _( "Draw layers copy" ) ); + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + { + #undef STRUCT + #define STRUCT ( (DRAWSEGMENT*) PtStruct ) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* l'element est ici bon a etre copie */ + DRAWSEGMENT* new_drawsegment = new DRAWSEGMENT( m_Pcb ); + new_drawsegment->Copy( STRUCT ); + new_drawsegment->Pnext = m_Pcb->m_Drawings; + new_drawsegment->Pback = m_Pcb; + m_Pcb->m_Drawings->Pback = new_drawsegment; + m_Pcb->m_Drawings = new_drawsegment; + new_drawsegment->m_Start.x += deltaX; new_drawsegment->m_Start.y += deltaY; + new_drawsegment->m_End.x += deltaX; new_drawsegment->m_End.y += deltaY; + Trace_DrawSegmentPcb( DrawPanel, DC, new_drawsegment, GR_OR ); + break; + } - case TYPEMIRE: - { - #undef STRUCT - #define STRUCT ((MIREPCB*) PtStruct) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* l'element est ici bon a etre efface */ - MIREPCB * new_mire = new MIREPCB(m_Pcb); - new_mire->Copy(STRUCT); - new_mire->Pnext = m_Pcb->m_Drawings; - new_mire->Pback = m_Pcb; - m_Pcb->m_Drawings->Pback = new_mire; - m_Pcb->m_Drawings = new_mire; - new_mire->m_Pos.x += deltaX; new_mire->m_Pos.y += deltaY; - new_mire->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR) ; - break; - } + case TYPETEXTE: + { + #undef STRUCT + #define STRUCT ( (TEXTE_PCB*) PtStruct ) + if( !Block_Include_PcbTextes ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* le texte est ici bon a etre deplace */ + TEXTE_PCB* new_pcbtext = new TEXTE_PCB( m_Pcb ); + new_pcbtext->Copy( STRUCT ); + new_pcbtext->Pnext = m_Pcb->m_Drawings; + new_pcbtext->Pback = m_Pcb; + m_Pcb->m_Drawings->Pback = new_pcbtext; + m_Pcb->m_Drawings = new_pcbtext; + /* Redessin du Texte */ + new_pcbtext->m_Pos.x += deltaX; new_pcbtext->m_Pos.y += deltaY; + new_pcbtext->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + break; + } - case TYPECOTATION: - { - #undef STRUCT - #define STRUCT ((COTATION*) PtStruct) - if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; - if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; - /* l'element est ici bon a etre copie */ - COTATION * new_cotation = new COTATION(m_Pcb); - new_cotation->Copy(STRUCT); - new_cotation->Pnext = m_Pcb->m_Drawings; - new_cotation->Pback = m_Pcb; - m_Pcb->m_Drawings->Pback = new_cotation; - m_Pcb->m_Drawings = new_cotation; - new_cotation->m_Pos.x += deltaX; - new_cotation->m_Pos.y += deltaY; - new_cotation->m_Text->m_Pos.x += deltaX; - new_cotation->m_Text->m_Pos.y += deltaY; - new_cotation->Barre_ox += deltaX; new_cotation->Barre_oy += deltaY; - new_cotation->Barre_fx += deltaX; new_cotation->Barre_fy += deltaY; - new_cotation->TraitG_ox += deltaX; new_cotation->TraitG_oy += deltaY; - new_cotation->TraitG_fx += deltaX; new_cotation->TraitG_fy += deltaY; - new_cotation->TraitD_ox += deltaX; new_cotation->TraitD_oy += deltaY; - new_cotation->TraitD_fx += deltaX; new_cotation->TraitD_fy += deltaY; - new_cotation->FlecheG1_ox += deltaX; new_cotation->FlecheG1_oy += deltaY; - new_cotation->FlecheG1_fx += deltaX; new_cotation->FlecheG1_fy += deltaY; - new_cotation->FlecheG2_ox += deltaX; new_cotation->FlecheG2_oy += deltaY; - new_cotation->FlecheG2_fx += deltaX; new_cotation->FlecheG2_fy += deltaY; - new_cotation->FlecheD1_ox += deltaX; new_cotation->FlecheD1_oy += deltaY; - new_cotation->FlecheD1_fx += deltaX; new_cotation->FlecheD1_fy += deltaY; - new_cotation->FlecheD2_ox += deltaX; new_cotation->FlecheD2_oy += deltaY; - new_cotation->FlecheD2_fx += deltaX; new_cotation->FlecheD2_fy += deltaY; - new_cotation->Draw(DrawPanel, DC, wxPoint(0,0),GR_OR) ; - break; - } + case TYPEMIRE: + { + #undef STRUCT + #define STRUCT ( (MIREPCB*) PtStruct ) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* l'element est ici bon a etre efface */ + MIREPCB* new_mire = new MIREPCB( m_Pcb ); + new_mire->Copy( STRUCT ); + new_mire->Pnext = m_Pcb->m_Drawings; + new_mire->Pback = m_Pcb; + m_Pcb->m_Drawings->Pback = new_mire; + m_Pcb->m_Drawings = new_mire; + new_mire->m_Pos.x += deltaX; new_mire->m_Pos.y += deltaY; + new_mire->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + break; + } - default: break; - } - } + case TYPECOTATION: + { + #undef STRUCT + #define STRUCT ( (COTATION*) PtStruct ) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) + break; + if( IsStructInBox( GetScreen()->BlockLocate, PtStruct ) == NULL ) + break; + /* l'element est ici bon a etre copie */ + COTATION* new_cotation = new COTATION( m_Pcb ); + new_cotation->Copy( STRUCT ); + new_cotation->Pnext = m_Pcb->m_Drawings; + new_cotation->Pback = m_Pcb; + m_Pcb->m_Drawings->Pback = new_cotation; + m_Pcb->m_Drawings = new_cotation; + new_cotation->m_Pos.x += deltaX; + new_cotation->m_Pos.y += deltaY; + new_cotation->m_Text->m_Pos.x += deltaX; + new_cotation->m_Text->m_Pos.y += deltaY; + new_cotation->Barre_ox += deltaX; new_cotation->Barre_oy += deltaY; + new_cotation->Barre_fx += deltaX; new_cotation->Barre_fy += deltaY; + new_cotation->TraitG_ox += deltaX; new_cotation->TraitG_oy += deltaY; + new_cotation->TraitG_fx += deltaX; new_cotation->TraitG_fy += deltaY; + new_cotation->TraitD_ox += deltaX; new_cotation->TraitD_oy += deltaY; + new_cotation->TraitD_fx += deltaX; new_cotation->TraitD_fy += deltaY; + new_cotation->FlecheG1_ox += deltaX; new_cotation->FlecheG1_oy += deltaY; + new_cotation->FlecheG1_fx += deltaX; new_cotation->FlecheG1_fy += deltaY; + new_cotation->FlecheG2_ox += deltaX; new_cotation->FlecheG2_oy += deltaY; + new_cotation->FlecheG2_fx += deltaX; new_cotation->FlecheG2_fy += deltaY; + new_cotation->FlecheD1_ox += deltaX; new_cotation->FlecheD1_oy += deltaY; + new_cotation->FlecheD1_fx += deltaX; new_cotation->FlecheD1_fy += deltaY; + new_cotation->FlecheD2_ox += deltaX; new_cotation->FlecheD2_oy += deltaY; + new_cotation->FlecheD2_fx += deltaX; new_cotation->FlecheD2_fy += deltaY; + new_cotation->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + break; + } + + default: + break; + } + } } /*******************************************************************/ -static EDA_BaseStruct * IsStructInBox(DrawBlockStruct & blocklocate, - EDA_BaseStruct * PtStruct ) +static EDA_BaseStruct* IsStructInBox( DrawBlockStruct& blocklocate, + EDA_BaseStruct* PtStruct ) /******************************************************************/ + /* Teste si la structure PtStruct est inscrite dans le block selectionne -*/ + */ { - switch ( PtStruct->m_StructType ) - { - case TYPEDRAWSEGMENT: - #undef STRUCT - #define STRUCT ((DRAWSEGMENT*)PtStruct) - if( ! blocklocate.Inside( STRUCT->m_Start.x, STRUCT->m_Start.y) ) return(NULL); - if( ! blocklocate.Inside(STRUCT->m_End.x, STRUCT->m_End.y) ) return(NULL); - return(PtStruct); + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + #undef STRUCT + #define STRUCT ( (DRAWSEGMENT*) PtStruct ) + if( !blocklocate.Inside( STRUCT->m_Start.x, STRUCT->m_Start.y ) ) + return NULL; + if( !blocklocate.Inside( STRUCT->m_End.x, STRUCT->m_End.y ) ) + return NULL; + return PtStruct; - case TYPETEXTE: - #undef STRUCT - #define STRUCT ((TEXTE_PCB*) PtStruct) - if ( ! blocklocate.Inside(STRUCT->m_Pos.x, STRUCT->m_Pos.y) ) return(NULL); - return(PtStruct); + case TYPETEXTE: + #undef STRUCT + #define STRUCT ( (TEXTE_PCB*) PtStruct ) + if( !blocklocate.Inside( STRUCT->m_Pos.x, STRUCT->m_Pos.y ) ) + return NULL; + return PtStruct; - case TYPEMIRE: - #undef STRUCT - #define STRUCT ((MIREPCB*) PtStruct) - if( ! blocklocate.Inside( STRUCT->m_Pos.x, STRUCT->m_Pos.y) ) return(NULL); - return(PtStruct); + case TYPEMIRE: + #undef STRUCT + #define STRUCT ( (MIREPCB*) PtStruct ) + if( !blocklocate.Inside( STRUCT->m_Pos.x, STRUCT->m_Pos.y ) ) + return NULL; + return PtStruct; - case TYPECOTATION: - #undef STRUCT - #define STRUCT ((COTATION*) PtStruct) - if ( ! blocklocate.Inside( STRUCT->m_Pos.x, STRUCT->m_Pos.y) ) return(NULL); - return(PtStruct); + case TYPECOTATION: + #undef STRUCT + #define STRUCT ( (COTATION*) PtStruct ) + if( !blocklocate.Inside( STRUCT->m_Pos.x, STRUCT->m_Pos.y ) ) + return NULL; + return PtStruct; - default: return(NULL); - } - return(NULL); + default: + return NULL; + } + + return NULL; } /**************************************************************************/ -static TRACK * IsSegmentInBox( DrawBlockStruct & blocklocate, TRACK * PtSegm ) +static TRACK* IsSegmentInBox( DrawBlockStruct& blocklocate, TRACK* PtSegm ) /**************************************************************************/ + /* Teste si la structure PtStruct est inscrite dans le block selectionne - Retourne PtSegm si oui - NULL si non -*/ + * Retourne PtSegm si oui + * NULL si non + */ { - if ( blocklocate.Inside(PtSegm->m_Start.x ,PtSegm->m_Start.y) ) - return ( PtSegm ); + if( blocklocate.Inside( PtSegm->m_Start.x, PtSegm->m_Start.y ) ) + return PtSegm; - if ( blocklocate.Inside(PtSegm->m_End.x, PtSegm->m_End.y) ) - return ( PtSegm ); + if( blocklocate.Inside( PtSegm->m_End.x, PtSegm->m_End.y ) ) + return PtSegm; - return ( NULL ); + return NULL; } + /****************************************************************************/ -static MODULE * IsModuleInBox( DrawBlockStruct& blocklocate, MODULE * Module ) +static MODULE* IsModuleInBox( DrawBlockStruct& blocklocate, MODULE* Module ) /****************************************************************************/ + /* Teste si le Module est inscrit dans le block selectionne - Retourne Module si oui - NULL si non -*/ + * Retourne Module si oui + * NULL si non + */ { -bool is_out_of_box = FALSE; + bool is_out_of_box = FALSE; - Module->SetRectangleExinscrit(); + Module->SetRectangleExinscrit(); - if ( Module->m_RealBoundaryBox.m_Pos.x < blocklocate.GetX() ) - is_out_of_box = TRUE; - if ( Module->m_RealBoundaryBox.m_Pos.y < blocklocate.GetY() ) - is_out_of_box = TRUE; - if ( Module->m_RealBoundaryBox.GetRight() > blocklocate.GetRight() ) - is_out_of_box = TRUE; - if ( Module->m_RealBoundaryBox.GetBottom() > blocklocate.GetBottom() ) - is_out_of_box = TRUE; + if( Module->m_RealBoundaryBox.m_Pos.x < blocklocate.GetX() ) + is_out_of_box = TRUE; + if( Module->m_RealBoundaryBox.m_Pos.y < blocklocate.GetY() ) + is_out_of_box = TRUE; + if( Module->m_RealBoundaryBox.GetRight() > blocklocate.GetRight() ) + is_out_of_box = TRUE; + if( Module->m_RealBoundaryBox.GetBottom() > blocklocate.GetBottom() ) + is_out_of_box = TRUE; - if (is_out_of_box) return ( NULL ); - return ( Module ); + if( is_out_of_box ) + return NULL; + return Module; } - diff --git a/pcbnew/block_module_editor.cpp b/pcbnew/block_module_editor.cpp index b7a7822daa..df63574a24 100644 --- a/pcbnew/block_module_editor.cpp +++ b/pcbnew/block_module_editor.cpp @@ -23,658 +23,711 @@ /* Fonctions exportees */ /* Fonctions Locales */ -static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); -static int MarkItemsInBloc(MODULE * module, - EDA_Rect & Rect); +static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); +static int MarkItemsInBloc( MODULE* module, + EDA_Rect& Rect ); -static void ClearMarkItems(MODULE * module); -static void CopyMarkedItems(MODULE *module, wxPoint offset); -static void MoveMarkedItems(MODULE *module, wxPoint offset); -static void MirrorMarkedItems(MODULE *module, wxPoint offset); -static void RotateMarkedItems(MODULE *module, wxPoint offset); -static void DeleteMarkedItems(MODULE *module); +static void ClearMarkItems( MODULE* module ); +static void CopyMarkedItems( MODULE* module, wxPoint offset ); +static void MoveMarkedItems( MODULE* module, wxPoint offset ); +static void MirrorMarkedItems( MODULE* module, wxPoint offset ); +static void RotateMarkedItems( MODULE* module, wxPoint offset ); +static void DeleteMarkedItems( MODULE* module ); /*************************************************************************/ -int WinEDA_ModuleEditFrame::ReturnBlockCommand(int key) +int WinEDA_ModuleEditFrame::ReturnBlockCommand( int key ) /*************************************************************************/ + /* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to - the key (ALT, SHIFT ALT ..) pressed when dragging mouse and left or middle button - pressed -*/ + * the key (ALT, SHIFT ALT ..) pressed when dragging mouse and left or middle button + * pressed + */ { -int cmd; + int cmd; - switch ( key ) - { - default: - cmd = key & 0x255; - break; + switch( key ) + { + default: + cmd = key & 0x255; + break; - case -1: - cmd = BLOCK_PRESELECT_MOVE; - break; + case - 1: + cmd = BLOCK_PRESELECT_MOVE; + break; - case 0: - cmd = BLOCK_MOVE; - break; + case 0: + cmd = BLOCK_MOVE; + break; - case GR_KB_ALT: - cmd = BLOCK_MIRROR_Y; - break; + case GR_KB_ALT: + cmd = BLOCK_MIRROR_Y; + break; - case GR_KB_SHIFTCTRL: - cmd = BLOCK_DELETE; - break; + case GR_KB_SHIFTCTRL: + cmd = BLOCK_DELETE; + break; - case GR_KB_SHIFT: - cmd = BLOCK_COPY; - break; + case GR_KB_SHIFT: + cmd = BLOCK_COPY; + break; - case GR_KB_CTRL: - cmd = BLOCK_ROTATE; - break; + case GR_KB_CTRL: + cmd = BLOCK_ROTATE; + break; - case MOUSE_MIDDLE: - cmd = BLOCK_ZOOM; - break; - } + case MOUSE_MIDDLE: + cmd = BLOCK_ZOOM; + break; + } - return cmd; + return cmd; } /****************************************************/ -int WinEDA_ModuleEditFrame::HandleBlockEnd(wxDC * DC) +int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) /****************************************************/ + /* Command BLOCK END (end of block sizing) - return : - 0 if command finished (zoom, delete ...) - 1 if HandleBlockPlace must follow (items found, and a block place command must follow) -*/ + * return : + * 0 if command finished (zoom, delete ...) + * 1 if HandleBlockPlace must follow (items found, and a block place command must follow) + */ { -int ItemsCount = 0, MustDoPlace = 0; -MODULE * Currentmodule = m_Pcb->m_Modules; + int ItemsCount = 0, MustDoPlace = 0; + MODULE* Currentmodule = m_Pcb->m_Modules; - if ( GetScreen()->BlockLocate.m_BlockDrawStruct ) - { - BlockState state = GetScreen()->BlockLocate.m_State; - CmdBlockType command = GetScreen()->BlockLocate.m_Command; - DrawPanel->ForceCloseManageCurseur(DrawPanel, DC); - GetScreen()->BlockLocate.m_State = state; - GetScreen()->BlockLocate.m_Command = command; - DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines; - DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand; - GetScreen()->m_Curseur.x = GetScreen()->BlockLocate.GetRight(); - GetScreen()->m_Curseur.y = GetScreen()->BlockLocate.GetBottom(); - DrawPanel->MouseToCursorSchema(); - } + if( GetScreen()->BlockLocate.m_BlockDrawStruct ) + { + BlockState state = GetScreen()->BlockLocate.m_State; + CmdBlockType command = GetScreen()->BlockLocate.m_Command; + DrawPanel->ForceCloseManageCurseur( DrawPanel, DC ); + GetScreen()->BlockLocate.m_State = state; + GetScreen()->BlockLocate.m_Command = command; + DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines; + DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand; + GetScreen()->m_Curseur.x = GetScreen()->BlockLocate.GetRight(); + GetScreen()->m_Curseur.y = GetScreen()->BlockLocate.GetBottom(); + DrawPanel->MouseToCursorSchema(); + } - switch( GetScreen()->BlockLocate.m_Command ) - { - case BLOCK_IDLE: - DisplayError(this, wxT("Error in HandleBlockPLace") ); - break; + switch( GetScreen()->BlockLocate.m_Command ) + { + case BLOCK_IDLE: + DisplayError( this, wxT( "Error in HandleBlockPLace" ) ); + break; - case BLOCK_DRAG: /* Drag */ - case BLOCK_MOVE: /* Move */ - case BLOCK_COPY: /* Copy */ - ItemsCount = MarkItemsInBloc(Currentmodule, GetScreen()->BlockLocate); - if ( ItemsCount ) - { - MustDoPlace = 1; - if(DrawPanel->ManageCurseur != NULL) - { - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - DrawPanel->ManageCurseur = DrawMovingBlockOutlines; - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - } - GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; - DrawPanel->Refresh(TRUE); - } - break; + case BLOCK_DRAG: /* Drag */ + case BLOCK_MOVE: /* Move */ + case BLOCK_COPY: /* Copy */ + ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->BlockLocate ); + if( ItemsCount ) + { + MustDoPlace = 1; + if( DrawPanel->ManageCurseur != NULL ) + { + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + } + GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; + DrawPanel->Refresh( TRUE ); + } + break; - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ - MustDoPlace = 1; - DrawPanel->ManageCurseur = DrawMovingBlockOutlines; - GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; - break; + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + MustDoPlace = 1; + DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; + break; - case BLOCK_DELETE: /* Delete */ - ItemsCount = MarkItemsInBloc(Currentmodule, GetScreen()->BlockLocate); - if ( ItemsCount ) SaveCopyInUndoList(Currentmodule); - DeleteMarkedItems(Currentmodule); - break; - - case BLOCK_SAVE: /* Save */ - case BLOCK_PASTE: - break; + case BLOCK_DELETE: /* Delete */ + ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->BlockLocate ); + if( ItemsCount ) + SaveCopyInUndoList( Currentmodule ); + DeleteMarkedItems( Currentmodule ); + break; - case BLOCK_ROTATE: - ItemsCount = MarkItemsInBloc(Currentmodule, GetScreen()->BlockLocate); - if ( ItemsCount ) SaveCopyInUndoList(Currentmodule); - RotateMarkedItems(Currentmodule, GetScreen()->BlockLocate.Centre()); - break; + case BLOCK_SAVE: /* Save */ + case BLOCK_PASTE: + break; + + case BLOCK_ROTATE: + ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->BlockLocate ); + if( ItemsCount ) + SaveCopyInUndoList( Currentmodule ); + RotateMarkedItems( Currentmodule, GetScreen()->BlockLocate.Centre() ); + break; - case BLOCK_MIRROR_X: - case BLOCK_MIRROR_Y: - case BLOCK_INVERT: /* mirror */ - ItemsCount = MarkItemsInBloc(Currentmodule, GetScreen()->BlockLocate); - if ( ItemsCount ) SaveCopyInUndoList(Currentmodule); - MirrorMarkedItems(Currentmodule, GetScreen()->BlockLocate.Centre()); - break; + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: + case BLOCK_INVERT: /* mirror */ + ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->BlockLocate ); + if( ItemsCount ) + SaveCopyInUndoList( Currentmodule ); + MirrorMarkedItems( Currentmodule, GetScreen()->BlockLocate.Centre() ); + break; - case BLOCK_ZOOM: /* Window Zoom */ - Window_Zoom( GetScreen()->BlockLocate ); - break; + case BLOCK_ZOOM: /* Window Zoom */ + Window_Zoom( GetScreen()->BlockLocate ); + break; - case BLOCK_ABORT: - break; - - case BLOCK_SELECT_ITEMS_ONLY: - break; - } + case BLOCK_ABORT: + break; - if ( MustDoPlace <= 0 ) - { - if ( GetScreen()->BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY ) - { - ClearMarkItems(Currentmodule); - } - GetScreen()->BlockLocate.m_Flags = 0; - GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; - GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->m_CurrentItem = NULL; - SetToolID(m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); - DrawPanel->Refresh(TRUE); - } + case BLOCK_SELECT_ITEMS_ONLY: + break; + } + + if( MustDoPlace <= 0 ) + { + if( GetScreen()->BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY ) + { + ClearMarkItems( Currentmodule ); + } + GetScreen()->BlockLocate.m_Flags = 0; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->SetCurItem( NULL ); + SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); + DrawPanel->Refresh( TRUE ); + } - return(MustDoPlace); + return MustDoPlace; } /******************************************************/ -void WinEDA_ModuleEditFrame::HandleBlockPlace(wxDC * DC) +void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC ) /******************************************************/ + /* Routine to handle the BLOCK PLACE commande - Last routine for block operation for: - - block move & drag - - block copie & paste -*/ + * Last routine for block operation for: + * - block move & drag + * - block copie & paste + */ { -bool err = FALSE; -MODULE * Currentmodule = m_Pcb->m_Modules; + bool err = FALSE; + MODULE* Currentmodule = m_Pcb->m_Modules; - if(DrawPanel->ManageCurseur == NULL) - { - err = TRUE; - DisplayError(this, wxT("HandleBlockPLace : ManageCurseur = NULL") ); - } + if( DrawPanel->ManageCurseur == NULL ) + { + err = TRUE; + DisplayError( this, wxT( "HandleBlockPLace : ManageCurseur = NULL" ) ); + } - GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; - switch(GetScreen()->BlockLocate.m_Command ) - { - case BLOCK_IDLE: - err = TRUE; - break; - - case BLOCK_DRAG: /* Drag */ - case BLOCK_MOVE: /* Move */ - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ - GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; - SaveCopyInUndoList(Currentmodule); - MoveMarkedItems(Currentmodule, GetScreen()->BlockLocate.m_MoveVector); - DrawPanel->Refresh(TRUE); - break; + switch( GetScreen()->BlockLocate.m_Command ) + { + case BLOCK_IDLE: + err = TRUE; + break; - case BLOCK_COPY: /* Copy */ - GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; - SaveCopyInUndoList(Currentmodule); - CopyMarkedItems(Currentmodule, GetScreen()->BlockLocate.m_MoveVector); - break; + case BLOCK_DRAG: /* Drag */ + case BLOCK_MOVE: /* Move */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + SaveCopyInUndoList( Currentmodule ); + MoveMarkedItems( Currentmodule, GetScreen()->BlockLocate.m_MoveVector ); + DrawPanel->Refresh( TRUE ); + break; - case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */ - GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; - break; + case BLOCK_COPY: /* Copy */ + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + SaveCopyInUndoList( Currentmodule ); + CopyMarkedItems( Currentmodule, GetScreen()->BlockLocate.m_MoveVector ); + break; - case BLOCK_MIRROR_X: - case BLOCK_MIRROR_Y: - case BLOCK_INVERT: /* Mirror by popup menu, from block move */ - SaveCopyInUndoList(Currentmodule); - MirrorMarkedItems(Currentmodule, GetScreen()->BlockLocate.Centre()); - break; + case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */ + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + break; - case BLOCK_ROTATE: - SaveCopyInUndoList(Currentmodule); - RotateMarkedItems(Currentmodule, GetScreen()->BlockLocate.Centre()); - break; + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: + case BLOCK_INVERT: /* Mirror by popup menu, from block move */ + SaveCopyInUndoList( Currentmodule ); + MirrorMarkedItems( Currentmodule, GetScreen()->BlockLocate.Centre() ); + break; - case BLOCK_ZOOM: // Handled by HandleBlockEnd - case BLOCK_DELETE: - case BLOCK_SAVE: - case BLOCK_ABORT: - default: - break; - } + case BLOCK_ROTATE: + SaveCopyInUndoList( Currentmodule ); + RotateMarkedItems( Currentmodule, GetScreen()->BlockLocate.Centre() ); + break; - GetScreen()->SetModify(); + case BLOCK_ZOOM: // Handled by HandleBlockEnd + case BLOCK_DELETE: + case BLOCK_SAVE: + case BLOCK_ABORT: + default: + break; + } - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->BlockLocate.m_Flags = 0; - GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; - GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; - GetScreen()->m_CurrentItem = NULL; - DrawPanel->Refresh(TRUE); + GetScreen()->SetModify(); - SetToolID(m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->BlockLocate.m_Flags = 0; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + GetScreen()->SetCurItem( NULL ); + DrawPanel->Refresh( TRUE ); + + SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); } /************************************************************************/ -static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, - bool erase ) +static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, + bool erase ) /************************************************************************/ + /* Retrace le contour du block de recherche de structures - L'ensemble du block suit le curseur -*/ + * L'ensemble du block suit le curseur + */ { -DrawBlockStruct * PtBlock; -BASE_SCREEN * screen = panel->m_Parent->GetScreen(); -EDA_BaseStruct * item; -wxPoint move_offset; -MODULE * Currentmodule = EDA_Appl->m_ModuleEditFrame->m_Pcb->m_Modules; - - PtBlock = &panel->GetScreen()->BlockLocate; - GRSetDrawMode(DC, g_XorMode); + DrawBlockStruct* PtBlock; + BASE_SCREEN* screen = panel->m_Parent->GetScreen(); + EDA_BaseStruct* item; + wxPoint move_offset; + MODULE* Currentmodule = EDA_Appl->m_ModuleEditFrame->m_Pcb->m_Modules; - /* Effacement ancien cadre */ - if( erase ) - { - PtBlock->Offset(PtBlock->m_MoveVector); - PtBlock->Draw(panel, DC); - PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y); + PtBlock = &panel->GetScreen()->BlockLocate; + GRSetDrawMode( DC, g_XorMode ); - if ( Currentmodule ) - { - move_offset.x = - PtBlock->m_MoveVector.x; - move_offset.y = - PtBlock->m_MoveVector.y; - item = Currentmodule->m_Drawings; - for ( ; item != NULL; item = item->Next() ) - { - if ( item->m_Selected == 0 ) continue; - switch( item->m_StructType ) - { - case TYPETEXTEMODULE: - ((TEXTE_MODULE *) item)->Draw(panel, DC, move_offset, g_XorMode); - break; - - case TYPEEDGEMODULE: - ((EDGE_MODULE *) item)->Draw(panel, DC, move_offset, g_XorMode); - break; - - default: break; - } - } - D_PAD* pad = Currentmodule->m_Pads; - for ( ; pad != NULL; pad = pad->Next() ) - { - if ( pad->m_Selected == 0 ) continue; - pad->Draw(panel, DC, move_offset, g_XorMode); - } - } - } + /* Effacement ancien cadre */ + if( erase ) + { + PtBlock->Offset( PtBlock->m_MoveVector ); + PtBlock->Draw( panel, DC ); + PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y ); - /* Redessin nouvel affichage */ - PtBlock->m_MoveVector.x = screen->m_Curseur.x - PtBlock->m_BlockLastCursorPosition.x; - PtBlock->m_MoveVector.y = screen->m_Curseur.y - PtBlock->m_BlockLastCursorPosition.y; + if( Currentmodule ) + { + move_offset.x = -PtBlock->m_MoveVector.x; + move_offset.y = -PtBlock->m_MoveVector.y; + item = Currentmodule->m_Drawings; + for( ; item != NULL; item = item->Next() ) + { + if( item->m_Selected == 0 ) + continue; - GRSetDrawMode(DC, g_XorMode); - PtBlock->Offset(PtBlock->m_MoveVector); - PtBlock->Draw(panel, DC); - PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y); + switch( item->m_StructType ) + { + case TYPETEXTEMODULE: + ( (TEXTE_MODULE*) item )->Draw( panel, DC, move_offset, g_XorMode ); + break; - - if ( Currentmodule ) - { - item = Currentmodule->m_Drawings; - move_offset.x = - PtBlock->m_MoveVector.x; - move_offset.y = - PtBlock->m_MoveVector.y; - for ( ; item != NULL; item = item->Next() ) - { - if ( item->m_Selected == 0 ) continue; - switch( item->m_StructType ) - { - case TYPETEXTEMODULE: - ((TEXTE_MODULE *) item)->Draw(panel, DC, move_offset, g_XorMode); - break; - - case TYPEEDGEMODULE: - ((EDGE_MODULE *) item)->Draw(panel, DC, move_offset, g_XorMode); - break; - - default: break; - } - } - D_PAD* pad = Currentmodule->m_Pads; - for ( ; pad != NULL; pad = pad->Next() ) - { - if ( pad->m_Selected == 0 ) continue; - pad->Draw(panel, DC, move_offset, g_XorMode); - } - } + case TYPEEDGEMODULE: + ( (EDGE_MODULE*) item )->Draw( panel, DC, move_offset, g_XorMode ); + break; + + default: + break; + } + } + + D_PAD* pad = Currentmodule->m_Pads; + for( ; pad != NULL; pad = pad->Next() ) + { + if( pad->m_Selected == 0 ) + continue; + pad->Draw( panel, DC, move_offset, g_XorMode ); + } + } + } + + /* Redessin nouvel affichage */ + PtBlock->m_MoveVector.x = screen->m_Curseur.x - PtBlock->m_BlockLastCursorPosition.x; + PtBlock->m_MoveVector.y = screen->m_Curseur.y - PtBlock->m_BlockLastCursorPosition.y; + + GRSetDrawMode( DC, g_XorMode ); + PtBlock->Offset( PtBlock->m_MoveVector ); + PtBlock->Draw( panel, DC ); + PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y ); + + + if( Currentmodule ) + { + item = Currentmodule->m_Drawings; + move_offset.x = -PtBlock->m_MoveVector.x; + move_offset.y = -PtBlock->m_MoveVector.y; + for( ; item != NULL; item = item->Next() ) + { + if( item->m_Selected == 0 ) + continue; + + switch( item->m_StructType ) + { + case TYPETEXTEMODULE: + ( (TEXTE_MODULE*) item )->Draw( panel, DC, move_offset, g_XorMode ); + break; + + case TYPEEDGEMODULE: + ( (EDGE_MODULE*) item )->Draw( panel, DC, move_offset, g_XorMode ); + break; + + default: + break; + } + } + + D_PAD* pad = Currentmodule->m_Pads; + for( ; pad != NULL; pad = pad->Next() ) + { + if( pad->m_Selected == 0 ) + continue; + pad->Draw( panel, DC, move_offset, g_XorMode ); + } + } } + /****************************************************************************/ -void CopyMarkedItems(MODULE *module, wxPoint offset) +void CopyMarkedItems( MODULE* module, wxPoint offset ) /****************************************************************************/ -/* Copy marked items, at new position = old position + offset -*/ + +/* Copy marked items, at new position = old position + offset + */ { -EDA_BaseStruct * item; -EDA_BaseStruct* NewStruct; - - if ( module == NULL ) return; - - D_PAD * pad = module->m_Pads; - for ( ; pad != NULL; pad = pad->Next() ) - { - if ( pad->m_Selected == 0 ) continue; - pad->m_Selected = 0; - D_PAD * NewPad = new D_PAD( module ); - NewPad->Copy(pad); - NewPad->m_Selected = IS_SELECTED; - NewPad->Pnext = module->m_Pads; - NewPad->Pback = module; - module->m_Pads->Pback = NewPad; - module->m_Pads = NewPad; - } + EDA_BaseStruct* item; + EDA_BaseStruct* NewStruct; - item = module->m_Drawings; - for ( ; item != NULL; item = item->Next() ) - { - if ( item->m_Selected == 0 ) continue; - item->m_Selected = 0; - NewStruct = NULL; - switch(item->m_StructType) - { - case TYPETEXTEMODULE: - NewStruct = new TEXTE_MODULE( module ); - ((TEXTE_MODULE*)NewStruct)->Copy((TEXTE_MODULE*)item); - break; + if( module == NULL ) + return; - case TYPEEDGEMODULE: - NewStruct = new EDGE_MODULE( module ); - ((EDGE_MODULE*)NewStruct)->Copy((EDGE_MODULE*)item); - break; - default: - DisplayError(NULL, wxT("Internal Err: CopyMarkedItems: type indefini")); - break; - } - if( NewStruct == NULL) break; - NewStruct->m_Selected = IS_SELECTED; - NewStruct->Pnext = module->m_Drawings; - NewStruct->Pback = module; - module->m_Drawings->Pback = module; - module->m_Drawings = NewStruct; - } - - MoveMarkedItems(module, offset); + D_PAD* pad = module->m_Pads; + for( ; pad != NULL; pad = pad->Next() ) + { + if( pad->m_Selected == 0 ) + continue; + pad->m_Selected = 0; + D_PAD* NewPad = new D_PAD( module ); + NewPad->Copy( pad ); + NewPad->m_Selected = IS_SELECTED; + NewPad->Pnext = module->m_Pads; + NewPad->Pback = module; + module->m_Pads->Pback = NewPad; + module->m_Pads = NewPad; + } + + item = module->m_Drawings; + for( ; item != NULL; item = item->Next() ) + { + if( item->m_Selected == 0 ) + continue; + item->m_Selected = 0; + NewStruct = NULL; + + switch( item->m_StructType ) + { + case TYPETEXTEMODULE: + NewStruct = new TEXTE_MODULE( module ); + ( (TEXTE_MODULE*) NewStruct )->Copy( (TEXTE_MODULE*) item ); + break; + + case TYPEEDGEMODULE: + NewStruct = new EDGE_MODULE( module ); + ( (EDGE_MODULE*) NewStruct )->Copy( (EDGE_MODULE*) item ); + break; + + default: + DisplayError( NULL, wxT( "Internal Err: CopyMarkedItems: type indefini" ) ); + break; + } + + if( NewStruct == NULL ) + break; + NewStruct->m_Selected = IS_SELECTED; + NewStruct->Pnext = module->m_Drawings; + NewStruct->Pback = module; + module->m_Drawings->Pback = module; + module->m_Drawings = NewStruct; + } + + MoveMarkedItems( module, offset ); } + /****************************************************/ -void MoveMarkedItems(MODULE *module, wxPoint offset) +void MoveMarkedItems( MODULE* module, wxPoint offset ) /****************************************************/ -/* Move marked items, at new position = old position + offset -*/ + +/* Move marked items, at new position = old position + offset + */ { -EDA_BaseStruct * item; - - if ( module == NULL ) return; - - D_PAD * pad = module->m_Pads; - for ( ; pad != NULL; pad = pad->Next() ) - { - if ( pad->m_Selected == 0 ) continue; - pad->m_Pos.x += offset.x; - pad->m_Pos.y += offset.y; - pad->m_Pos0.x += offset.x; - pad->m_Pos0.y += offset.y; - } + EDA_BaseStruct* item; - item = module->m_Drawings; - for ( ; item != NULL; item = item->Next() ) - { - if ( item->m_Selected == 0 ) continue; - - switch ( item->m_StructType ) - { - case TYPETEXTEMODULE: - ((TEXTE_MODULE*)item)->m_Pos.x += offset.x; - ((TEXTE_MODULE*)item)->m_Pos.y += offset.y; - ((TEXTE_MODULE*)item)->m_Pos0.x += offset.x; - ((TEXTE_MODULE*)item)->m_Pos0.y += offset.y; - break; + if( module == NULL ) + return; - case TYPEEDGEMODULE : - ((EDGE_MODULE*)item)->m_Start.x += offset.x; - ((EDGE_MODULE*)item)->m_Start.y += offset.y; - ((EDGE_MODULE*)item)->m_End.x += offset.x; - ((EDGE_MODULE*)item)->m_End.y += offset.y; - ((EDGE_MODULE*)item)->m_Start0.x += offset.x; - ((EDGE_MODULE*)item)->m_Start0.y += offset.y; - ((EDGE_MODULE*)item)->m_End0.x += offset.x; - ((EDGE_MODULE*)item)->m_End0.y += offset.y; - break; - } - item->m_Flags = item->m_Selected = 0; - } -} + D_PAD* pad = module->m_Pads; + for( ; pad != NULL; pad = pad->Next() ) + { + if( pad->m_Selected == 0 ) + continue; + pad->m_Pos.x += offset.x; + pad->m_Pos.y += offset.y; + pad->m_Pos0.x += offset.x; + pad->m_Pos0.y += offset.y; + } -/******************************************************/ -void DeleteMarkedItems(MODULE *module) -/******************************************************/ -/* Delete marked items -*/ -{ -EDA_BaseStruct * item, * next_item; -D_PAD * pad, * next_pad; - - if ( module == NULL ) return; - - pad = module->m_Pads; - for ( ; pad != NULL; pad = next_pad ) - { - next_pad = pad->Next(); - if ( pad->m_Selected == 0 ) continue; - DeleteStructure(pad); - } + item = module->m_Drawings; + for( ; item != NULL; item = item->Next() ) + { + if( item->m_Selected == 0 ) + continue; - item = module->m_Drawings; - for ( ; item != NULL; item = next_item ) - { - next_item = item->Next(); - if ( item->m_Selected == 0 ) continue; - DeleteStructure(item); - } + switch( item->m_StructType ) + { + case TYPETEXTEMODULE: + ( (TEXTE_MODULE*) item )->m_Pos.x += offset.x; + ( (TEXTE_MODULE*) item )->m_Pos.y += offset.y; + ( (TEXTE_MODULE*) item )->m_Pos0.x += offset.x; + ( (TEXTE_MODULE*) item )->m_Pos0.y += offset.y; + break; + + case TYPEEDGEMODULE: + ( (EDGE_MODULE*) item )->m_Start.x += offset.x; + ( (EDGE_MODULE*) item )->m_Start.y += offset.y; + ( (EDGE_MODULE*) item )->m_End.x += offset.x; + ( (EDGE_MODULE*) item )->m_End.y += offset.y; + ( (EDGE_MODULE*) item )->m_Start0.x += offset.x; + ( (EDGE_MODULE*) item )->m_Start0.y += offset.y; + ( (EDGE_MODULE*) item )->m_End0.x += offset.x; + ( (EDGE_MODULE*) item )->m_End0.y += offset.y; + break; + } + + item->m_Flags = item->m_Selected = 0; + } } /******************************************************/ -void MirrorMarkedItems(MODULE *module, wxPoint offset) +void DeleteMarkedItems( MODULE* module ) /******************************************************/ + +/* Delete marked items + */ +{ + EDA_BaseStruct* item, * next_item; + D_PAD* pad, * next_pad; + + if( module == NULL ) + return; + + pad = module->m_Pads; + for( ; pad != NULL; pad = next_pad ) + { + next_pad = pad->Next(); + if( pad->m_Selected == 0 ) + continue; + DeleteStructure( pad ); + } + + item = module->m_Drawings; + for( ; item != NULL; item = next_item ) + { + next_item = item->Next(); + if( item->m_Selected == 0 ) + continue; + DeleteStructure( item ); + } +} + + +/******************************************************/ +void MirrorMarkedItems( MODULE* module, wxPoint offset ) +/******************************************************/ + /* Mirror marked items, refer to a Vertical axis at position offset -*/ + */ { -#define SETMIRROR(z) (z) -= offset.x; (z) = -(z); (z) += offset.x; -EDA_BaseStruct * item; - - if ( module == NULL ) return; - - D_PAD * pad = module->m_Pads; - for ( ; pad != NULL; pad = pad->Next() ) - { - if ( pad->m_Selected == 0 ) continue; - SETMIRROR(pad->m_Pos.x); - pad->m_Pos0.x = pad->m_Pos.x; - pad->m_Offset.x = -pad->m_Offset.x; - pad->m_DeltaSize.x = -pad->m_DeltaSize.x; - pad->m_Orient = 1800 - pad->m_Orient; - NORMALIZE_ANGLE(pad->m_Orient); - } +#define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x; + EDA_BaseStruct* item; - item = module->m_Drawings; - for ( ; item != NULL; item = item->Next() ) - { - if ( item->m_Selected == 0 ) continue; - - switch ( item->m_StructType ) - { - case TYPEEDGEMODULE: - SETMIRROR(((EDGE_MODULE*)item)->m_Start.x); - ((EDGE_MODULE*)item)->m_Start0.x = ((EDGE_MODULE*)item)->m_Start.x; - SETMIRROR(((EDGE_MODULE*)item)->m_End.x); - ((EDGE_MODULE*)item)->m_End0.x = ((EDGE_MODULE*)item)->m_End.x; - ((EDGE_MODULE*)item)->m_Angle = - ((EDGE_MODULE*)item)->m_Angle; - break; - - case TYPETEXTEMODULE: - SETMIRROR(((TEXTE_MODULE*)item)->m_Pos.x); - ((TEXTE_MODULE*)item)->m_Pos0.x = ((TEXTE_MODULE*)item)->m_Pos.x; - break; - } - item->m_Flags = item->m_Selected = 0; - } + if( module == NULL ) + return; + + D_PAD* pad = module->m_Pads; + for( ; pad != NULL; pad = pad->Next() ) + { + if( pad->m_Selected == 0 ) + continue; + SETMIRROR( pad->m_Pos.x ); + pad->m_Pos0.x = pad->m_Pos.x; + pad->m_Offset.x = -pad->m_Offset.x; + pad->m_DeltaSize.x = -pad->m_DeltaSize.x; + pad->m_Orient = 1800 - pad->m_Orient; + NORMALIZE_ANGLE( pad->m_Orient ); + } + + item = module->m_Drawings; + for( ; item != NULL; item = item->Next() ) + { + if( item->m_Selected == 0 ) + continue; + + switch( item->m_StructType ) + { + case TYPEEDGEMODULE: + SETMIRROR( ( (EDGE_MODULE*) item )->m_Start.x ); + ( (EDGE_MODULE*) item )->m_Start0.x = ( (EDGE_MODULE*) item )->m_Start.x; + SETMIRROR( ( (EDGE_MODULE*) item )->m_End.x ); + ( (EDGE_MODULE*) item )->m_End0.x = ( (EDGE_MODULE*) item )->m_End.x; + ( (EDGE_MODULE*) item )->m_Angle = -( (EDGE_MODULE*) item )->m_Angle; + break; + + case TYPETEXTEMODULE: + SETMIRROR( ( (TEXTE_MODULE*) item )->m_Pos.x ); + ( (TEXTE_MODULE*) item )->m_Pos0.x = ( (TEXTE_MODULE*) item )->m_Pos.x; + break; + } + + item->m_Flags = item->m_Selected = 0; + } } + /******************************************************/ -void RotateMarkedItems(MODULE *module, wxPoint offset) +void RotateMarkedItems( MODULE* module, wxPoint offset ) /******************************************************/ + /* Rotate marked items, refer to a Vertical axis at position offset -*/ + */ { -#define ROTATE(z) RotatePoint((&z), offset, 900) -EDA_BaseStruct * item; - - if ( module == NULL ) return; - - D_PAD * pad = module->m_Pads; - for ( ; pad != NULL; pad = pad->Next() ) - { - if ( pad->m_Selected == 0 ) continue; - ROTATE(pad->m_Pos); - pad->m_Pos0 = pad->m_Pos; - pad->m_Orient += 900; - NORMALIZE_ANGLE(pad->m_Orient); - } +#define ROTATE( z ) RotatePoint( (&z), offset, 900 ) + EDA_BaseStruct* item; - item = module->m_Drawings; - for ( ; item != NULL; item = item->Next() ) - { - if ( item->m_Selected == 0 ) continue; - - switch ( item->m_StructType ) - { - case TYPEEDGEMODULE: - ROTATE(((EDGE_MODULE*)item)->m_Start); - ((EDGE_MODULE*)item)->m_Start0 = ((EDGE_MODULE*)item)->m_Start; - ROTATE(((EDGE_MODULE*)item)->m_End); - ((EDGE_MODULE*)item)->m_End0 = ((EDGE_MODULE*)item)->m_End; - break; - - case TYPETEXTEMODULE: - ROTATE(((TEXTE_MODULE*)item)->m_Pos); - ((TEXTE_MODULE*)item)->m_Pos0 = ((TEXTE_MODULE*)item)->m_Pos; - ((TEXTE_MODULE*)item)->m_Orient += 900; - break; - } - item->m_Flags = item->m_Selected = 0; - } + if( module == NULL ) + return; + + D_PAD* pad = module->m_Pads; + for( ; pad != NULL; pad = pad->Next() ) + { + if( pad->m_Selected == 0 ) + continue; + ROTATE( pad->m_Pos ); + pad->m_Pos0 = pad->m_Pos; + pad->m_Orient += 900; + NORMALIZE_ANGLE( pad->m_Orient ); + } + + item = module->m_Drawings; + for( ; item != NULL; item = item->Next() ) + { + if( item->m_Selected == 0 ) + continue; + + switch( item->m_StructType ) + { + case TYPEEDGEMODULE: + ROTATE( ( (EDGE_MODULE*) item )->m_Start ); + ( (EDGE_MODULE*) item )->m_Start0 = ( (EDGE_MODULE*) item )->m_Start; + ROTATE( ( (EDGE_MODULE*) item )->m_End ); + ( (EDGE_MODULE*) item )->m_End0 = ( (EDGE_MODULE*) item )->m_End; + break; + + case TYPETEXTEMODULE: + ROTATE( ( (TEXTE_MODULE*) item )->m_Pos ); + ( (TEXTE_MODULE*) item )->m_Pos0 = ( (TEXTE_MODULE*) item )->m_Pos; + ( (TEXTE_MODULE*) item )->m_Orient += 900; + break; + } + + item->m_Flags = item->m_Selected = 0; + } } + /*********************************************************/ -void ClearMarkItems(MODULE * module) +void ClearMarkItems( MODULE* module ) /*********************************************************/ { -EDA_BaseStruct * item; - - if ( module == NULL ) return; + EDA_BaseStruct* item; - item = module->m_Drawings; - for ( ; item != NULL; item = item->Next() ) - item->m_Flags = item->m_Selected = 0; + if( module == NULL ) + return; - item = module->m_Pads; - for ( ; item != NULL; item = item->Next() ) - item->m_Flags = item->m_Selected = 0; + item = module->m_Drawings; + for( ; item != NULL; item = item->Next() ) + item->m_Flags = item->m_Selected = 0; + + item = module->m_Pads; + for( ; item != NULL; item = item->Next() ) + item->m_Flags = item->m_Selected = 0; } + /***************************************************************/ -int MarkItemsInBloc(MODULE * module, EDA_Rect & Rect) +int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect ) /***************************************************************/ + /* Mark items inside rect. - Items are inside rect when an end point is inside rect -*/ + * Items are inside rect when an end point is inside rect + */ { -EDA_BaseStruct * item; -int ItemsCount = 0; -wxPoint pos; -D_PAD * pad; - - if ( module == NULL ) return 0; - - pad = module->m_Pads; - for ( ; pad != NULL; pad = pad->Next() ) - { - pad->m_Selected = 0; - pos = pad->m_Pos; - if ( Rect.Inside(pos) ) - { - pad->m_Selected = IS_SELECTED; - ItemsCount++; - } - } + EDA_BaseStruct* item; + int ItemsCount = 0; + wxPoint pos; + D_PAD* pad; - item = module->m_Drawings; - for ( ; item != NULL; item = item->Next() ) - { - item->m_Selected = 0; - switch( item->m_StructType ) - { - case TYPEEDGEMODULE: - pos = ((EDGE_MODULE*)item)->m_Start; - if ( Rect.Inside(pos) ) - { - item->m_Selected = IS_SELECTED; - ItemsCount++; - } - pos = ((EDGE_MODULE*)item)->m_End; - if ( Rect.Inside(pos) ) - { - item->m_Selected = IS_SELECTED; - ItemsCount++; - } - break; - - case TYPETEXTEMODULE: - pos = ((TEXTE_MODULE*)item)->m_Pos; - if ( Rect.Inside(pos) ) - { - item->m_Selected = IS_SELECTED; - ItemsCount++; - } - break; - - default: - break; - } - - } - return ItemsCount; - + if( module == NULL ) + return 0; + + pad = module->m_Pads; + for( ; pad != NULL; pad = pad->Next() ) + { + pad->m_Selected = 0; + pos = pad->m_Pos; + if( Rect.Inside( pos ) ) + { + pad->m_Selected = IS_SELECTED; + ItemsCount++; + } + } + + item = module->m_Drawings; + for( ; item != NULL; item = item->Next() ) + { + item->m_Selected = 0; + + switch( item->m_StructType ) + { + case TYPEEDGEMODULE: + pos = ( (EDGE_MODULE*) item )->m_Start; + if( Rect.Inside( pos ) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + pos = ( (EDGE_MODULE*) item )->m_End; + if( Rect.Inside( pos ) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + break; + + case TYPETEXTEMODULE: + pos = ( (TEXTE_MODULE*) item )->m_Pos; + if( Rect.Inside( pos ) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + break; + + default: + break; + } + } + + return ItemsCount; } diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index 6ac15c75a7..713aba03b7 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -351,7 +351,7 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) if( GetScreen()->BlockLocate.m_State != STATE_NO_BLOCK ) keep_on_grid = TRUE; - EDA_BaseStruct* DrawStruct = GetScreen()->m_CurrentItem; + EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem(); if( DrawStruct && DrawStruct->m_Flags ) keep_on_grid = TRUE; diff --git a/pcbnew/cotation.cpp b/pcbnew/cotation.cpp index c7b2a19019..a2a26fd949 100644 --- a/pcbnew/cotation.cpp +++ b/pcbnew/cotation.cpp @@ -1,6 +1,6 @@ - /*****************************************/ - /* Edition du pcb: Gestion des cotations */ - /*****************************************/ +/*****************************************/ +/* Edition du pcb: Gestion des cotations */ +/*****************************************/ #include "fctsys.h" @@ -10,468 +10,485 @@ #include "protos.h" /* Routines Locales */ -static void Exit_EditCotation(WinEDA_DrawPanel * Panel, wxDC *DC); -static void Montre_Position_New_Cotation(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); -static void Ajuste_Details_Cotation(COTATION * pts); +static void Exit_EditCotation( WinEDA_DrawPanel* Panel, wxDC* DC ); +static void Montre_Position_New_Cotation( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); +static void Ajuste_Details_Cotation( COTATION* pts ); /* Variables "locales" : */ -static int status_cotation; /* = 0 : pas de cotation en cours - = 1 : debut place, fin a placer - = 2 : fin placee, texte a ajuster */ +static int status_cotation; /* = 0 : pas de cotation en cours + * = 1 : debut place, fin a placer + * = 2 : fin placee, texte a ajuster */ /* - Les routines generent une cotation de la forme - - cote usuelle: + * Les routines generent une cotation de la forme + * - cote usuelle: + * + | | + | dist | + |<---------->| + | | + * + */ - | | - | dist | - |<---------->| - | | - -*/ - -#define MAX_CHAR 40 /* longueur maxi de la cotation */ +#define MAX_CHAR 40 /* longueur maxi de la cotation */ /* Dimension des fleches */ #define FLECHE_L 500 -enum id_Cotation_properties -{ - ID_ACCEPT_COTATION_PROPERTIES = 1900, - ID_CLOSE_COTATION_PROPERTIES, - ID_TEXTPCB_SELECT_LAYER +enum id_Cotation_properties { + ID_ACCEPT_COTATION_PROPERTIES = 1900, + ID_CLOSE_COTATION_PROPERTIES, + ID_TEXTPCB_SELECT_LAYER }; - /************************************/ - /* class WinEDA_CotationPropertiesFrame */ - /************************************/ +/************************************/ +/* class WinEDA_CotationPropertiesFrame */ +/************************************/ -class WinEDA_CotationPropertiesFrame: public wxDialog +class WinEDA_CotationPropertiesFrame : public wxDialog { private: - WinEDA_PcbFrame * m_Parent; - wxDC * m_DC; - COTATION * CurrentCotation; - WinEDA_EnterText * m_Name; - WinEDA_SizeCtrl * m_TxtSizeCtrl; - WinEDA_ValueCtrl * m_TxtWidthCtrl; - wxRadioBox * m_Mirror; - WinEDAChoiceBox * m_SelLayerBox; + WinEDA_PcbFrame* m_Parent; + wxDC* m_DC; + COTATION* CurrentCotation; + WinEDA_EnterText* m_Name; + WinEDA_SizeCtrl* m_TxtSizeCtrl; + WinEDA_ValueCtrl* m_TxtWidthCtrl; + wxRadioBox* m_Mirror; + WinEDAChoiceBox* m_SelLayerBox; public: - // Constructor and destructor - WinEDA_CotationPropertiesFrame(WinEDA_PcbFrame *parent, - COTATION * Cotation, wxDC * DC, const wxPoint & pos); - ~WinEDA_CotationPropertiesFrame(void) - { - } + + // Constructor and destructor + WinEDA_CotationPropertiesFrame( WinEDA_PcbFrame* parent, + COTATION* Cotation, wxDC* DC, const wxPoint& pos ); + ~WinEDA_CotationPropertiesFrame( void ) + { + } + private: - void OnQuit(wxCommandEvent& event); - void CotationPropertiesAccept(wxCommandEvent& event); + void OnQuit( wxCommandEvent& event ); + void CotationPropertiesAccept( wxCommandEvent& event ); - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() }; -BEGIN_EVENT_TABLE(WinEDA_CotationPropertiesFrame, wxDialog) - EVT_BUTTON(ID_ACCEPT_COTATION_PROPERTIES, - WinEDA_CotationPropertiesFrame::CotationPropertiesAccept) - EVT_BUTTON(ID_CLOSE_COTATION_PROPERTIES, - WinEDA_CotationPropertiesFrame::OnQuit) +BEGIN_EVENT_TABLE( WinEDA_CotationPropertiesFrame, wxDialog ) +EVT_BUTTON( ID_ACCEPT_COTATION_PROPERTIES, + WinEDA_CotationPropertiesFrame::CotationPropertiesAccept ) +EVT_BUTTON( ID_CLOSE_COTATION_PROPERTIES, + WinEDA_CotationPropertiesFrame::OnQuit ) END_EVENT_TABLE() -WinEDA_CotationPropertiesFrame::WinEDA_CotationPropertiesFrame(WinEDA_PcbFrame *parent, - COTATION * Cotation,wxDC * DC, - const wxPoint & framepos): - wxDialog(parent, -1, _("Cotation properties"), framepos, wxSize(340, 270), - DIALOG_STYLE) +WinEDA_CotationPropertiesFrame::WinEDA_CotationPropertiesFrame( WinEDA_PcbFrame* parent, + COTATION* Cotation, wxDC* DC, + const wxPoint& framepos ) : + wxDialog( parent, -1, _( "Cotation properties" ), framepos, wxSize( 340, 270 ), + DIALOG_STYLE ) { -wxButton * Button; + wxButton* Button; - m_Parent = parent; - SetFont(*g_DialogFont); - m_DC = DC; - Centre(); + m_Parent = parent; + SetFont( *g_DialogFont ); + m_DC = DC; + Centre(); - CurrentCotation = Cotation; + CurrentCotation = Cotation; - wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); - SetSizer(MainBoxSizer); - wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); - wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); - MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); - MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); + SetSizer( MainBoxSizer ); + wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL ); + MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 ); + MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - /* Creation des boutons de commande */ - Button = new wxButton(this, ID_ACCEPT_COTATION_PROPERTIES, - _("Ok")); - Button->SetForegroundColour(*wxRED); - RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + /* Creation des boutons de commande */ + Button = new wxButton( this, ID_ACCEPT_COTATION_PROPERTIES, + _( "Ok" ) ); + Button->SetForegroundColour( *wxRED ); + RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - Button = new wxButton(this, ID_CLOSE_COTATION_PROPERTIES, - _("Cancel")); - Button->SetForegroundColour(*wxBLUE); - RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + Button = new wxButton( this, ID_CLOSE_COTATION_PROPERTIES, + _( "Cancel" ) ); + Button->SetForegroundColour( *wxBLUE ); + RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); -wxString display_msg[2] = { _("Normal"), _("Mirror") }; - m_Mirror = new wxRadioBox(this, -1, _("Display"), - wxDefaultPosition, wxSize(-1,-1), 2, display_msg, - 1, wxRA_SPECIFY_COLS ); - if ( ! Cotation->m_Text->m_Miroir ) m_Mirror->SetSelection(1);; - RightBoxSizer->Add(m_Mirror, 0, wxGROW|wxALL, 5); + wxString display_msg[2] = { _( "Normal" ), _( "Mirror" ) }; + m_Mirror = new wxRadioBox( this, -1, _( "Display" ), + wxDefaultPosition, wxSize( -1, -1 ), 2, display_msg, + 1, wxRA_SPECIFY_COLS ); + if( !Cotation->m_Text->m_Miroir ) + m_Mirror->SetSelection( 1 );; + RightBoxSizer->Add( m_Mirror, 0, wxGROW | wxALL, 5 ); - m_Name = new WinEDA_EnterText(this, wxT("Text:"), - Cotation->m_Text->m_Text, - LeftBoxSizer, wxSize( 200, -1) ); + m_Name = new WinEDA_EnterText( this, wxT( "Text:" ), + Cotation->m_Text->m_Text, + LeftBoxSizer, wxSize( 200, -1 ) ); - m_TxtSizeCtrl = new WinEDA_SizeCtrl(this, _("Size"), - Cotation->m_Text->m_Size, - g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits); + m_TxtSizeCtrl = new WinEDA_SizeCtrl( this, _( "Size" ), + Cotation->m_Text->m_Size, + g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits ); - m_TxtWidthCtrl = new WinEDA_ValueCtrl(this, _("Width"), - Cotation->m_Width, - g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits); + m_TxtWidthCtrl = new WinEDA_ValueCtrl( this, _( "Width" ), + Cotation->m_Width, + g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits ); - wxStaticText * text = new wxStaticText(this, -1, _("Layer:")); - LeftBoxSizer->Add(text, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); - m_SelLayerBox = new WinEDAChoiceBox(this, ID_TEXTPCB_SELECT_LAYER, - wxDefaultPosition, wxDefaultSize); - LeftBoxSizer->Add(m_SelLayerBox, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); - int ii; - for ( ii = CMP_N + 1; ii < 29 ; ii ++ ) - { - m_SelLayerBox->Append(ReturnPcbLayerName(ii)); - } - m_SelLayerBox->SetSelection( Cotation->m_Layer - (CMP_N + 1) ); + wxStaticText* text = new wxStaticText( this, -1, _( "Layer:" ) ); + LeftBoxSizer->Add( text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); + m_SelLayerBox = new WinEDAChoiceBox( this, ID_TEXTPCB_SELECT_LAYER, + wxDefaultPosition, wxDefaultSize ); + LeftBoxSizer->Add( m_SelLayerBox, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); + int ii; + for( ii = CMP_N + 1; ii < 29; ii++ ) + { + m_SelLayerBox->Append( ReturnPcbLayerName( ii ) ); + } - GetSizer()->Fit(this); - GetSizer()->SetSizeHints(this); -} + m_SelLayerBox->SetSelection( Cotation->m_Layer - (CMP_N + 1) ); -/**********************************************************************/ -void WinEDA_CotationPropertiesFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) -/**********************************************************************/ -{ - Close(true); // true is to force the frame to close + GetSizer()->Fit( this ); + GetSizer()->SetSizeHints( this ); } +/**********************************************************************/ +void WinEDA_CotationPropertiesFrame::OnQuit( wxCommandEvent& WXUNUSED (event) ) +/**********************************************************************/ +{ + Close( true ); // true is to force the frame to close +} + /***********************************************************************************/ -void WinEDA_CotationPropertiesFrame::CotationPropertiesAccept(wxCommandEvent& event) +void WinEDA_CotationPropertiesFrame::CotationPropertiesAccept( wxCommandEvent& event ) /***********************************************************************************/ { - if ( m_DC ) // Effacement ancien texte - { - CurrentCotation->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0), GR_XOR); - } + if( m_DC ) // Effacement ancien texte + { + CurrentCotation->Draw( m_Parent->DrawPanel, m_DC, wxPoint( 0, 0 ), GR_XOR ); + } - if ( m_Name->GetValue() != wxEmptyString ) - { - CurrentCotation->SetText( m_Name->GetValue()); - } + if( m_Name->GetValue() != wxEmptyString ) + { + CurrentCotation->SetText( m_Name->GetValue() ); + } - CurrentCotation->m_Text->m_Size = m_TxtSizeCtrl->GetValue(); - CurrentCotation->m_Text->m_Width = CurrentCotation->m_Width = - m_TxtWidthCtrl->GetValue(); - CurrentCotation->m_Text->m_Miroir = (m_Mirror->GetSelection() == 0) ? 1 : 0; - CurrentCotation->m_Layer = CurrentCotation->m_Text->m_Layer = - m_SelLayerBox->GetChoice() + CMP_N + 1; + CurrentCotation->m_Text->m_Size = m_TxtSizeCtrl->GetValue(); + CurrentCotation->m_Text->m_Width = CurrentCotation->m_Width = + m_TxtWidthCtrl->GetValue(); + CurrentCotation->m_Text->m_Miroir = (m_Mirror->GetSelection() == 0) ? 1 : 0; + CurrentCotation->m_Layer = CurrentCotation->m_Text->m_Layer = + m_SelLayerBox->GetChoice() + CMP_N + 1; - CurrentCotation->m_Text->CreateDrawData(); + CurrentCotation->m_Text->CreateDrawData(); - if ( m_DC ) // Affichage nouveau texte - { - /* Redessin du Texte */ - CurrentCotation->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0), GR_OR); - } + if( m_DC ) // Affichage nouveau texte + { + /* Redessin du Texte */ + CurrentCotation->Draw( m_Parent->DrawPanel, m_DC, wxPoint( 0, 0 ), GR_OR ); + } - m_Parent->m_CurrentScreen->SetModify(); - Close(TRUE); + m_Parent->m_CurrentScreen->SetModify(); + Close( TRUE ); } /**************************************************************/ -static void Exit_EditCotation(WinEDA_DrawPanel * Panel, wxDC *DC) +static void Exit_EditCotation( WinEDA_DrawPanel* Panel, wxDC* DC ) /**************************************************************/ { -COTATION * Cotation = (COTATION*) Panel->GetScreen()->m_CurrentItem; + COTATION* Cotation = (COTATION*) Panel->GetScreen()->GetCurItem(); - if( Cotation ) - { - if ( Cotation->m_Flags & IS_NEW) - { - Cotation->Draw(Panel, DC,wxPoint(0,0),GR_XOR) ; - DeleteStructure( Cotation); - } - else - { - Cotation->Draw(Panel, DC,wxPoint(0,0),GR_OR) ; - } - } - - status_cotation = 0; - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; - Panel->GetScreen()->m_CurrentItem = NULL; + if( Cotation ) + { + if( Cotation->m_Flags & IS_NEW ) + { + Cotation->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR ); + DeleteStructure( Cotation ); + } + else + { + Cotation->Draw( Panel, DC, wxPoint( 0, 0 ), GR_OR ); + } + } + status_cotation = 0; + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + Panel->GetScreen()->SetCurItem( NULL ); } + /*************************************************************************/ -COTATION * WinEDA_PcbFrame::Begin_Cotation(COTATION * Cotation, wxDC * DC) +COTATION* WinEDA_PcbFrame::Begin_Cotation( COTATION* Cotation, wxDC* DC ) /*************************************************************************/ { -wxPoint pos ; + wxPoint pos; - if(Cotation == NULL ) /* debut reel du trace */ - { - status_cotation = 1; - pos = m_CurrentScreen->m_Curseur; + if( Cotation == NULL ) /* debut reel du trace */ + { + status_cotation = 1; + pos = m_CurrentScreen->m_Curseur; - Cotation = new COTATION(m_Pcb); - Cotation->m_Flags = IS_NEW; + Cotation = new COTATION( m_Pcb ); + Cotation->m_Flags = IS_NEW; - Cotation->m_Layer = GetScreen()->m_Active_Layer; - Cotation->m_Width = g_DesignSettings.m_DrawSegmentWidth; - Cotation->m_Text->m_Width = Cotation->m_Width; + Cotation->m_Layer = GetScreen()->m_Active_Layer; + Cotation->m_Width = g_DesignSettings.m_DrawSegmentWidth; + Cotation->m_Text->m_Width = Cotation->m_Width; - Cotation->Barre_ox = Cotation->Barre_fx = pos.x ; - Cotation->Barre_oy = Cotation->Barre_fy = pos.y ; + Cotation->Barre_ox = Cotation->Barre_fx = pos.x; + Cotation->Barre_oy = Cotation->Barre_fy = pos.y; - Cotation->TraitD_ox = Cotation->TraitD_fx = pos.x ; - Cotation->TraitD_oy = Cotation->TraitD_fy = pos.y ; + Cotation->TraitD_ox = Cotation->TraitD_fx = pos.x; + Cotation->TraitD_oy = Cotation->TraitD_fy = pos.y; - Cotation->TraitG_ox = Cotation->TraitG_fx = pos.x ; - Cotation->TraitG_oy = Cotation->TraitG_fy = pos.y ; + Cotation->TraitG_ox = Cotation->TraitG_fx = pos.x; + Cotation->TraitG_oy = Cotation->TraitG_fy = pos.y; - Cotation->FlecheG1_ox = Cotation->FlecheG1_fx = pos.x ; - Cotation->FlecheG1_oy = Cotation->FlecheG1_fy = pos.y ; + Cotation->FlecheG1_ox = Cotation->FlecheG1_fx = pos.x; + Cotation->FlecheG1_oy = Cotation->FlecheG1_fy = pos.y; - Cotation->FlecheG2_ox = Cotation->FlecheG2_fx = pos.x ; - Cotation->FlecheG2_oy = Cotation->FlecheG2_fy = pos.y ; + Cotation->FlecheG2_ox = Cotation->FlecheG2_fx = pos.x; + Cotation->FlecheG2_oy = Cotation->FlecheG2_fy = pos.y; - Cotation->FlecheD1_ox = Cotation->FlecheD1_fx = pos.x ; - Cotation->FlecheD1_oy = Cotation->FlecheD1_fy = pos.y ; + Cotation->FlecheD1_ox = Cotation->FlecheD1_fx = pos.x; + Cotation->FlecheD1_oy = Cotation->FlecheD1_fy = pos.y; - Cotation->FlecheD2_ox = Cotation->FlecheD2_fx = pos.x ; - Cotation->FlecheD2_oy = Cotation->FlecheD2_fy = pos.y ; + Cotation->FlecheD2_ox = Cotation->FlecheD2_fx = pos.x; + Cotation->FlecheD2_oy = Cotation->FlecheD2_fy = pos.y; - Cotation->m_Text->m_Miroir = 1; - Cotation->m_Text->m_Size = g_DesignSettings.m_PcbTextSize; - Cotation->m_Text->m_Width = g_DesignSettings.m_PcbTextWidth; + Cotation->m_Text->m_Miroir = 1; + Cotation->m_Text->m_Size = g_DesignSettings.m_PcbTextSize; + Cotation->m_Text->m_Width = g_DesignSettings.m_PcbTextWidth; - Ajuste_Details_Cotation(Cotation); + Ajuste_Details_Cotation( Cotation ); - Cotation->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); + Cotation->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); - DrawPanel->ManageCurseur = Montre_Position_New_Cotation; - DrawPanel->ForceCloseManageCurseur = Exit_EditCotation; - return Cotation; - } + DrawPanel->ManageCurseur = Montre_Position_New_Cotation; + DrawPanel->ForceCloseManageCurseur = Exit_EditCotation; + return Cotation; + } - // Cotation != NULL - if( status_cotation == 1 ) - { - status_cotation = 2; - return Cotation; - } + // Cotation != NULL + if( status_cotation == 1 ) + { + status_cotation = 2; + return Cotation; + } - Cotation->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); - Cotation->m_Flags = 0; + Cotation->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + Cotation->m_Flags = 0; - /* Insertion de la structure dans le Chainage .Drawings du PCB */ - Cotation->Pback = m_Pcb; - Cotation->Pnext = m_Pcb->m_Drawings; - if( m_Pcb->m_Drawings) m_Pcb->m_Drawings->Pback = Cotation; - m_Pcb->m_Drawings = Cotation; + /* Insertion de la structure dans le Chainage .Drawings du PCB */ + Cotation->Pback = m_Pcb; + Cotation->Pnext = m_Pcb->m_Drawings; + if( m_Pcb->m_Drawings ) + m_Pcb->m_Drawings->Pback = Cotation; + m_Pcb->m_Drawings = Cotation; - m_CurrentScreen->SetModify(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + m_CurrentScreen->SetModify(); + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; - return NULL; + return NULL; } /************************************************************************************/ -static void Montre_Position_New_Cotation(WinEDA_DrawPanel * panel, wxDC * DC, bool erase ) +static void Montre_Position_New_Cotation( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /************************************************************************************/ /* redessin du contour de la piste lors des deplacements de la souris */ { -PCB_SCREEN * screen = (PCB_SCREEN *)panel->GetScreen(); -COTATION * Cotation = (COTATION *) screen->m_CurrentItem; -wxPoint pos = screen->m_Curseur; + PCB_SCREEN* screen = (PCB_SCREEN*) panel->GetScreen(); + COTATION* Cotation = (COTATION*) screen->GetCurItem(); + wxPoint pos = screen->m_Curseur; - if( Cotation == NULL ) return ; + if( Cotation == NULL ) + return; - /* efface ancienne position */ - if( erase) - { - Cotation->Draw(panel, DC, wxPoint(0,0),GR_XOR) ; - } + /* efface ancienne position */ + if( erase ) + { + Cotation->Draw( panel, DC, wxPoint( 0, 0 ), GR_XOR ); + } - Cotation->m_Layer = screen->m_Active_Layer; - if( status_cotation == 1) - { - Cotation->TraitD_ox = pos.x; - Cotation->TraitD_oy = pos.y; - Cotation->Barre_fx = Cotation->TraitD_ox; - Cotation->Barre_fy = Cotation->TraitD_oy; - Ajuste_Details_Cotation(Cotation); - } + Cotation->m_Layer = screen->m_Active_Layer; + if( status_cotation == 1 ) + { + Cotation->TraitD_ox = pos.x; + Cotation->TraitD_oy = pos.y; + Cotation->Barre_fx = Cotation->TraitD_ox; + Cotation->Barre_fy = Cotation->TraitD_oy; + Ajuste_Details_Cotation( Cotation ); + } + else + { + int deltax, deltay, dx, dy; + float angle, depl; + deltax = Cotation->TraitD_ox - Cotation->TraitG_ox; + deltay = Cotation->TraitD_oy - Cotation->TraitG_oy; - else - { - int deltax, deltay, dx , dy; - float angle, depl; - deltax = Cotation->TraitD_ox - Cotation->TraitG_ox; - deltay = Cotation->TraitD_oy - Cotation->TraitG_oy; - /* Calcul de la direction de deplacement - ( perpendiculaire a l'axe de la cote ) */ - angle = atan2(deltay,deltax) + (M_PI / 2); + /* Calcul de la direction de deplacement + * ( perpendiculaire a l'axe de la cote ) */ + angle = atan2( deltay, deltax ) + (M_PI / 2); - deltax = pos.x - Cotation->TraitD_ox; - deltay = pos.y - Cotation->TraitD_oy; - depl = (deltax * cos(angle)) + (deltay * sin(angle)); - dx = (int)(depl * cos(angle)); - dy = (int)(depl * sin(angle)); - Cotation->Barre_ox = Cotation->TraitG_ox + dx; - Cotation->Barre_oy = Cotation->TraitG_oy + dy ; - Cotation->Barre_fx = Cotation->TraitD_ox + dx; - Cotation->Barre_fy = Cotation->TraitD_oy + dy ; + deltax = pos.x - Cotation->TraitD_ox; + deltay = pos.y - Cotation->TraitD_oy; + depl = ( deltax * cos( angle ) ) + ( deltay * sin( angle ) ); + dx = (int) ( depl * cos( angle ) ); + dy = (int) ( depl * sin( angle ) ); + Cotation->Barre_ox = Cotation->TraitG_ox + dx; + Cotation->Barre_oy = Cotation->TraitG_oy + dy; + Cotation->Barre_fx = Cotation->TraitD_ox + dx; + Cotation->Barre_fy = Cotation->TraitD_oy + dy; - Ajuste_Details_Cotation(Cotation); - } + Ajuste_Details_Cotation( Cotation ); + } - Cotation->Draw(panel, DC, wxPoint(0,0),GR_XOR) ; + Cotation->Draw( panel, DC, wxPoint( 0, 0 ), GR_XOR ); } /***************************************************************/ -void WinEDA_PcbFrame::Install_Edit_Cotation(COTATION * Cotation, - wxDC * DC, const wxPoint & pos) +void WinEDA_PcbFrame::Install_Edit_Cotation( COTATION* Cotation, + wxDC* DC, const wxPoint& pos ) /***************************************************************/ { - if( Cotation == NULL) return; + if( Cotation == NULL ) + return; - WinEDA_CotationPropertiesFrame * frame = new WinEDA_CotationPropertiesFrame(this, - Cotation, DC, pos); - frame->ShowModal(); frame->Destroy(); + WinEDA_CotationPropertiesFrame* frame = new WinEDA_CotationPropertiesFrame( this, + Cotation, DC, pos ); + frame->ShowModal(); frame->Destroy(); } + /*******************************************************************/ -void WinEDA_PcbFrame::Delete_Cotation(COTATION * Cotation, wxDC * DC) +void WinEDA_PcbFrame::Delete_Cotation( COTATION* Cotation, wxDC* DC ) /*******************************************************************/ { - if( Cotation == NULL) return; + if( Cotation == NULL ) + return; - if ( DC ) Cotation->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR ); - DeleteStructure( Cotation); - m_CurrentScreen->SetModify(); + if( DC ) + Cotation->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + DeleteStructure( Cotation ); + m_CurrentScreen->SetModify(); } /*****************************************************/ -static void Ajuste_Details_Cotation(COTATION * Cotation) +static void Ajuste_Details_Cotation( COTATION* Cotation ) /*****************************************************/ + /* Calcule les details des coordonnees des differents segments constitutifs -de la cotation -*/ + * de la cotation + */ { -int ii; -int mesure, deltax, deltay; /* valeur de la mesure sur les axes X et Y */ -int fleche_up_X=0, fleche_up_Y=0; /* coord des fleches : barre / */ -int fleche_dw_X=0, fleche_dw_Y=0; /* coord des fleches : barre \ */ -int hx, hy; /* coord des traits de rappel de cote */ -float angle, angle_f; -wxString msg; - - /* Init des couches : */ - Cotation->m_Text->m_Layer = Cotation->m_Layer; + int ii; + int mesure, deltax, deltay; /* valeur de la mesure sur les axes X et Y */ + int fleche_up_X = 0, fleche_up_Y = 0; /* coord des fleches : barre / */ + int fleche_dw_X = 0, fleche_dw_Y = 0; /* coord des fleches : barre \ */ + int hx, hy; /* coord des traits de rappel de cote */ + float angle, angle_f; + wxString msg; - /* calcul de la hauteur du texte + trait de cotation */ - ii = Cotation->m_Text->m_Size.y + - Cotation->m_Text->m_Width + (Cotation->m_Width * 3); + /* Init des couches : */ + Cotation->m_Text->m_Layer = Cotation->m_Layer; - deltax = Cotation->TraitD_ox - Cotation->TraitG_ox; - deltay = Cotation->TraitD_oy - Cotation->TraitG_oy; + /* calcul de la hauteur du texte + trait de cotation */ + ii = Cotation->m_Text->m_Size.y + + Cotation->m_Text->m_Width + (Cotation->m_Width * 3); - /* Calcul de la cote */ - mesure = (int)(hypot( (float)deltax, (float)deltay ) + 0.5 ) ; + deltax = Cotation->TraitD_ox - Cotation->TraitG_ox; + deltay = Cotation->TraitD_oy - Cotation->TraitG_oy; - if( deltax || deltay) angle = atan2( (float)deltay,(float)deltax); - else angle = 0.0; + /* Calcul de la cote */ + mesure = (int) (hypot( (float) deltax, (float) deltay ) + 0.5 ); - /* Calcul des parametre dimensions X et Y des fleches et traits de cotes */ - hx = hy = ii; + if( deltax || deltay ) + angle = atan2( (float) deltay, (float) deltax ); + else + angle = 0.0; - /* On tient compte de l'inclinaison de la cote */ - if(mesure) - { - hx = (abs)((int)( ( (float)deltay * hx) / mesure)); - hy = (abs)((int)( ( (float)deltax * hy) / mesure)); + /* Calcul des parametre dimensions X et Y des fleches et traits de cotes */ + hx = hy = ii; - if( Cotation->TraitG_ox > Cotation->Barre_ox ) hx = -hx; - if( Cotation->TraitG_ox == Cotation->Barre_ox ) hx = 0; - if( Cotation->TraitG_oy > Cotation->Barre_oy ) hy = -hy; - if( Cotation->TraitG_oy == Cotation->Barre_oy ) hy = 0; + /* On tient compte de l'inclinaison de la cote */ + if( mesure ) + { + hx = (abs) ( (int) ( ( (float) deltay * hx ) / mesure ) ); + hy = (abs) ( (int) ( ( (float) deltax * hy ) / mesure ) ); - angle_f = angle + (M_PI * 27.5 /180); - fleche_up_X = (int)(FLECHE_L * cos(angle_f)); - fleche_up_Y = (int)(FLECHE_L * sin(angle_f)); - angle_f = angle - (M_PI * 27.5 /180); - fleche_dw_X = (int)(FLECHE_L * cos(angle_f)); - fleche_dw_Y = (int)(FLECHE_L * sin(angle_f)); - } + if( Cotation->TraitG_ox > Cotation->Barre_ox ) + hx = -hx; + if( Cotation->TraitG_ox == Cotation->Barre_ox ) + hx = 0; + if( Cotation->TraitG_oy > Cotation->Barre_oy ) + hy = -hy; + if( Cotation->TraitG_oy == Cotation->Barre_oy ) + hy = 0; + + angle_f = angle + (M_PI * 27.5 / 180); + fleche_up_X = (int) ( FLECHE_L * cos( angle_f ) ); + fleche_up_Y = (int) ( FLECHE_L * sin( angle_f ) ); + angle_f = angle - (M_PI * 27.5 / 180); + fleche_dw_X = (int) ( FLECHE_L * cos( angle_f ) ); + fleche_dw_Y = (int) ( FLECHE_L * sin( angle_f ) ); + } - Cotation->FlecheG1_ox = Cotation->Barre_ox; - Cotation->FlecheG1_oy = Cotation->Barre_oy; - Cotation->FlecheG1_fx = Cotation->Barre_ox + fleche_up_X ; - Cotation->FlecheG1_fy = Cotation->Barre_oy + fleche_up_Y; + Cotation->FlecheG1_ox = Cotation->Barre_ox; + Cotation->FlecheG1_oy = Cotation->Barre_oy; + Cotation->FlecheG1_fx = Cotation->Barre_ox + fleche_up_X; + Cotation->FlecheG1_fy = Cotation->Barre_oy + fleche_up_Y; - Cotation->FlecheG2_ox = Cotation->Barre_ox ; - Cotation->FlecheG2_oy = Cotation->Barre_oy ; - Cotation->FlecheG2_fx = Cotation->Barre_ox + fleche_dw_X; - Cotation->FlecheG2_fy = Cotation->Barre_oy + fleche_dw_Y; + Cotation->FlecheG2_ox = Cotation->Barre_ox; + Cotation->FlecheG2_oy = Cotation->Barre_oy; + Cotation->FlecheG2_fx = Cotation->Barre_ox + fleche_dw_X; + Cotation->FlecheG2_fy = Cotation->Barre_oy + fleche_dw_Y; - /*la fleche de droite est symetrique a celle de gauche: - / = -\ et \ = -/ - */ - Cotation->FlecheD1_ox = Cotation->Barre_fx ; - Cotation->FlecheD1_oy = Cotation->Barre_fy ; - Cotation->FlecheD1_fx = Cotation->Barre_fx - fleche_dw_X; - Cotation->FlecheD1_fy = Cotation->Barre_fy - fleche_dw_Y; + /*la fleche de droite est symetrique a celle de gauche: + * / = -\ et \ = -/ + */ + Cotation->FlecheD1_ox = Cotation->Barre_fx; + Cotation->FlecheD1_oy = Cotation->Barre_fy; + Cotation->FlecheD1_fx = Cotation->Barre_fx - fleche_dw_X; + Cotation->FlecheD1_fy = Cotation->Barre_fy - fleche_dw_Y; - Cotation->FlecheD2_ox = Cotation->Barre_fx ; - Cotation->FlecheD2_oy = Cotation->Barre_fy ; - Cotation->FlecheD2_fx = Cotation->Barre_fx - fleche_up_X; - Cotation->FlecheD2_fy = Cotation->Barre_fy - fleche_up_Y; + Cotation->FlecheD2_ox = Cotation->Barre_fx; + Cotation->FlecheD2_oy = Cotation->Barre_fy; + Cotation->FlecheD2_fx = Cotation->Barre_fx - fleche_up_X; + Cotation->FlecheD2_fy = Cotation->Barre_fy - fleche_up_Y; - Cotation->TraitG_fx = Cotation->Barre_ox + hx; - Cotation->TraitG_fy = Cotation->Barre_oy + hy; + Cotation->TraitG_fx = Cotation->Barre_ox + hx; + Cotation->TraitG_fy = Cotation->Barre_oy + hy; - Cotation->TraitD_fx = Cotation->Barre_fx + hx; - Cotation->TraitD_fy = Cotation->Barre_fy + hy; + Cotation->TraitD_fx = Cotation->Barre_fx + hx; + Cotation->TraitD_fy = Cotation->Barre_fy + hy; - /* Calcul de la position du centre du texte et son orientation: */ - Cotation->m_Pos.x = Cotation->m_Text->m_Pos.x - = (Cotation->Barre_fx + Cotation->TraitG_fx) / 2; - Cotation->m_Pos.y = Cotation->m_Text->m_Pos.y - = (Cotation->Barre_fy + Cotation->TraitG_fy) / 2; + /* Calcul de la position du centre du texte et son orientation: */ + Cotation->m_Pos.x = Cotation->m_Text->m_Pos.x + = (Cotation->Barre_fx + Cotation->TraitG_fx) / 2; + Cotation->m_Pos.y = Cotation->m_Text->m_Pos.y + = (Cotation->Barre_fy + Cotation->TraitG_fy) / 2; - Cotation->m_Text->m_Orient = - (int)(angle * 1800 / M_PI); - if(Cotation->m_Text->m_Orient < 0) Cotation->m_Text->m_Orient += 3600; - if(Cotation->m_Text->m_Orient >= 3600) Cotation->m_Text->m_Orient -= 3600; - if( (Cotation->m_Text->m_Orient > 900) && (Cotation->m_Text->m_Orient <2700) ) - Cotation->m_Text->m_Orient -= 1800; + Cotation->m_Text->m_Orient = -(int) (angle * 1800 / M_PI); + if( Cotation->m_Text->m_Orient < 0 ) + Cotation->m_Text->m_Orient += 3600; + if( Cotation->m_Text->m_Orient >= 3600 ) + Cotation->m_Text->m_Orient -= 3600; + if( (Cotation->m_Text->m_Orient > 900) && (Cotation->m_Text->m_Orient <2700) ) + Cotation->m_Text->m_Orient -= 1800; - Cotation->m_Value = mesure; - valeur_param(Cotation->m_Value,msg); - Cotation->SetText( msg); - Cotation->m_Text->CreateDrawData(); + Cotation->m_Value = mesure; + valeur_param( Cotation->m_Value, msg ); + Cotation->SetText( msg ); + Cotation->m_Text->CreateDrawData(); } - diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp index 16a8bcc853..d95b4333bf 100644 --- a/pcbnew/deltrack.cpp +++ b/pcbnew/deltrack.cpp @@ -1,7 +1,7 @@ - /*********************************************/ - /* Edition des pistes: Routines d'effacement */ - /* Effacement de segment, piste, net et zone */ - /*********************************************/ +/*********************************************/ +/* Edition des pistes: Routines d'effacement */ +/* Effacement de segment, piste, net et zone */ +/*********************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -17,182 +17,192 @@ /***************************************************************/ -TRACK * WinEDA_PcbFrame::Delete_Segment(wxDC * DC, TRACK *Track) +TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track ) /***************************************************************/ + /* Supprime 1 segment de piste. - 2 Cas possibles: - Si On est en trace de nouvelle piste: Effacement du segment en - cours de trace - Sinon : Effacment du segment sous le curseur. -*/ + * 2 Cas possibles: + * Si On est en trace de nouvelle piste: Effacement du segment en + * cours de trace + * Sinon : Effacment du segment sous le curseur. + */ { -int current_net_code; - if ( Track == NULL ) return NULL; + int current_net_code; - if(Track->m_Flags & IS_NEW) // Trace en cours, on peut effacer le dernier segment - { - if(g_TrackSegmentCount > 0 ) - { - int previous_layer = GetScreen()->m_Active_Layer; - // effacement de la piste en cours - ShowNewTrackWhenMovingCursor(DrawPanel, DC, FALSE); + if( Track == NULL ) + return NULL; - // modification du trace - Track = g_CurrentTrackSegment; - g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; - delete Track; - g_TrackSegmentCount--; + if( Track->m_Flags & IS_NEW ) // Trace en cours, on peut effacer le dernier segment + { + if( g_TrackSegmentCount > 0 ) + { + int previous_layer = GetScreen()->m_Active_Layer; - if ( g_TwoSegmentTrackBuild ) - { // g_CurrentTrackSegment->Pback must not be a via, or we want delete also the via - if ( (g_TrackSegmentCount >= 2) && - (g_CurrentTrackSegment->m_StructType != TYPEVIA) && - (g_CurrentTrackSegment->Pback->m_StructType == TYPEVIA) ) - { - Track = g_CurrentTrackSegment; - g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; - delete Track; - g_TrackSegmentCount--; - } - } - - while( g_TrackSegmentCount && g_CurrentTrackSegment && - (g_CurrentTrackSegment->m_StructType == TYPEVIA) ) - { - Track = g_CurrentTrackSegment; - g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; - delete Track; - g_TrackSegmentCount--; - if (g_CurrentTrackSegment && (g_CurrentTrackSegment->m_StructType != TYPEVIA) ) - previous_layer = g_CurrentTrackSegment->m_Layer; - } - if( g_CurrentTrackSegment ) g_CurrentTrackSegment->Pnext = NULL; + // effacement de la piste en cours + ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE ); - // Rectification couche active qui a pu changer si une via - // a ete effacee - GetScreen()->m_Active_Layer = previous_layer; + // modification du trace + Track = g_CurrentTrackSegment; + g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; + delete Track; + g_TrackSegmentCount--; - Affiche_Status_Box(); - if ( g_TwoSegmentTrackBuild ) // We must have 2 segments or more, or 0 - { - if( ( g_TrackSegmentCount == 1 ) && - (g_CurrentTrackSegment->m_StructType != TYPEVIA) ) - { - delete g_CurrentTrackSegment; - g_TrackSegmentCount = 0; - } - } - if(g_TrackSegmentCount == 0 ) - { - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - if(g_HightLigt_Status) Hight_Light(DC); - g_CurrentTrackSegment = NULL; - g_FirstTrackSegment = NULL; - GetScreen()->m_CurrentItem = NULL; - return NULL; - } - else - { - if(DrawPanel->ManageCurseur) - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - return g_CurrentTrackSegment; - } - } - return NULL; - } // Fin traitement si trace en cours + if( g_TwoSegmentTrackBuild ) + { // g_CurrentTrackSegment->Pback must not be a via, or we want delete also the via + if( (g_TrackSegmentCount >= 2) + && (g_CurrentTrackSegment->m_StructType != TYPEVIA) + && (g_CurrentTrackSegment->Pback->m_StructType == TYPEVIA) ) + { + Track = g_CurrentTrackSegment; + g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; + delete Track; + g_TrackSegmentCount--; + } + } + + while( g_TrackSegmentCount && g_CurrentTrackSegment + && (g_CurrentTrackSegment->m_StructType == TYPEVIA) ) + { + Track = g_CurrentTrackSegment; + g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; + delete Track; + g_TrackSegmentCount--; + if( g_CurrentTrackSegment && (g_CurrentTrackSegment->m_StructType != TYPEVIA) ) + previous_layer = g_CurrentTrackSegment->m_Layer; + } + + if( g_CurrentTrackSegment ) + g_CurrentTrackSegment->Pnext = NULL; + + // Rectification couche active qui a pu changer si une via + // a ete effacee + GetScreen()->m_Active_Layer = previous_layer; + + Affiche_Status_Box(); + if( g_TwoSegmentTrackBuild ) // We must have 2 segments or more, or 0 + { + if( ( g_TrackSegmentCount == 1 ) + && (g_CurrentTrackSegment->m_StructType != TYPEVIA) ) + { + delete g_CurrentTrackSegment; + g_TrackSegmentCount = 0; + } + } + if( g_TrackSegmentCount == 0 ) + { + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + if( g_HightLigt_Status ) + Hight_Light( DC ); + g_CurrentTrackSegment = NULL; + g_FirstTrackSegment = NULL; + GetScreen()->SetCurItem( NULL ); + return NULL; + } + else + { + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + return g_CurrentTrackSegment; + } + } + return NULL; + } // Fin traitement si trace en cours - current_net_code = Track->m_NetCode; - Track->Draw(DrawPanel, DC, GR_XOR) ; + current_net_code = Track->m_NetCode; + Track->Draw( DrawPanel, DC, GR_XOR ); - SaveItemEfface( Track, 1); - GetScreen()->SetModify(); + SaveItemEfface( Track, 1 ); + GetScreen()->SetModify(); - test_1_net_connexion(DC, current_net_code); - Affiche_Infos_Status_Pcb(this); - return NULL; + test_1_net_connexion( DC, current_net_code ); + Affiche_Infos_Status_Pcb( this ); + return NULL; } - /**********************************************************/ -void WinEDA_PcbFrame::Delete_Track(wxDC * DC, TRACK *Track) +void WinEDA_PcbFrame::Delete_Track( wxDC* DC, TRACK* Track ) /**********************************************************/ { - if( Track != NULL ) - { - int current_net_code = Track->m_NetCode; - Supprime_Une_Piste(DC, Track) ; - GetScreen()->SetModify(); - test_1_net_connexion(DC, current_net_code); - Affiche_Infos_Status_Pcb(this); - } + if( Track != NULL ) + { + int current_net_code = Track->m_NetCode; + Supprime_Une_Piste( DC, Track ); + GetScreen()->SetModify(); + test_1_net_connexion( DC, current_net_code ); + Affiche_Infos_Status_Pcb( this ); + } } /********************************************************/ -void WinEDA_PcbFrame::Delete_net(wxDC * DC, TRACK *Track) +void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* Track ) /********************************************************/ { -TRACK *pt_segm, * pt_start; -int ii ; -int net_code_delete; + TRACK* pt_segm, * pt_start; + int ii; + int net_code_delete; - pt_segm = Track; + pt_segm = Track; - if ( pt_segm == NULL ) return; + if( pt_segm == NULL ) + return; - if ( IsOK(this, _("Delete NET ?") ) ) - { - net_code_delete = pt_segm->m_NetCode; - /* Recherche du debut de la zone des pistes du net_code courant */ - pt_start = m_Pcb->m_Track->GetStartNetCode(net_code_delete); + if( IsOK( this, _( "Delete NET ?" ) ) ) + { + net_code_delete = pt_segm->m_NetCode; + /* Recherche du debut de la zone des pistes du net_code courant */ + pt_start = m_Pcb->m_Track->GetStartNetCode( net_code_delete ); - /* Decompte du nombre de segments de la sous-chaine */ - pt_segm = pt_start; - for ( ii = 0 ; pt_segm != NULL; pt_segm = (TRACK*)pt_segm->Pnext ) - { - if( pt_segm->m_NetCode != net_code_delete ) break; - ii++; - } + /* Decompte du nombre de segments de la sous-chaine */ + pt_segm = pt_start; + for( ii = 0; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext ) + { + if( pt_segm->m_NetCode != net_code_delete ) + break; + ii++; + } - Trace_Une_Piste(DrawPanel, DC, pt_start,ii,GR_XOR); + Trace_Une_Piste( DrawPanel, DC, pt_start, ii, GR_XOR ); - SaveItemEfface( pt_start, ii); - GetScreen()->SetModify(); - test_1_net_connexion(DC, net_code_delete); - Affiche_Infos_Status_Pcb(this); - } + SaveItemEfface( pt_start, ii ); + GetScreen()->SetModify(); + test_1_net_connexion( DC, net_code_delete ); + Affiche_Infos_Status_Pcb( this ); + } } /********************************************************************/ -void WinEDA_PcbFrame::Supprime_Une_Piste(wxDC * DC, TRACK* pt_segm) +void WinEDA_PcbFrame::Supprime_Une_Piste( wxDC* DC, TRACK* pt_segm ) /********************************************************************/ + /* Routine de suppression de 1 piste: - le segment pointe est supprime puis les segments adjacents - jusqu'a un pad ou un point de jonction de plus de 2 segments -*/ + * le segment pointe est supprime puis les segments adjacents + * jusqu'a un pad ou un point de jonction de plus de 2 segments + */ { -TRACK * pt_track, * Struct; -int ii, nb_segm; + TRACK* pt_track, * Struct; + int ii, nb_segm; - if (pt_segm == NULL ) return ; + if( pt_segm == NULL ) + return; - pt_track = Marque_Une_Piste(this, DC, pt_segm, - & nb_segm, GR_OR | GR_SURBRILL); + pt_track = Marque_Une_Piste( this, DC, pt_segm, + &nb_segm, GR_OR | GR_SURBRILL ); - if(nb_segm) /* Il y a nb_segm segments de piste a effacer */ - { - Trace_Une_Piste(DrawPanel, DC, pt_track,nb_segm,GR_XOR | GR_SURBRILL); - /* Effacement flag BUSY */ - Struct = pt_track; ii = 0; - for ( ; ii < nb_segm; ii++, Struct = (TRACK*) Struct->Pnext ) - { - Struct->SetState(BUSY,OFF); - } - SaveItemEfface( pt_track, nb_segm); - } + if( nb_segm ) /* Il y a nb_segm segments de piste a effacer */ + { + Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_XOR | GR_SURBRILL ); + /* Effacement flag BUSY */ + Struct = pt_track; ii = 0; + for( ; ii < nb_segm; ii++, Struct = (TRACK*) Struct->Pnext ) + { + Struct->SetState( BUSY, OFF ); + } + + SaveItemEfface( pt_track, nb_segm ); + } } - diff --git a/pcbnew/dialog_edit_module.cpp b/pcbnew/dialog_edit_module.cpp index b499464865..f284a3ffd3 100644 --- a/pcbnew/dialog_edit_module.cpp +++ b/pcbnew/dialog_edit_module.cpp @@ -1,754 +1,802 @@ - /************************************************/ - /* Module editor: Dialog box for editing module */ - /* properties and carateristics */ - /* include in modedit.cpp */ - /************************************************/ +/************************************************/ +/* Module editor: Dialog box for editing module */ +/* properties and carateristics */ +/* include in modedit.cpp */ +/************************************************/ #include "dialog_edit_module.h" - /**************************************/ - /* class WinEDA_ModulePropertiesFrame */ - /**************************************/ - -BEGIN_EVENT_TABLE(WinEDA_ModulePropertiesFrame, wxDialog) - EVT_BUTTON(ID_ACCEPT_MODULE_PROPERTIES, - WinEDA_ModulePropertiesFrame::ModulePropertiesAccept) - EVT_BUTTON(ID_CLOSE_MODULE_PROPERTIES, WinEDA_ModulePropertiesFrame::OnQuit) - EVT_BUTTON(ID_MODULE_EDIT_ADD_TEXT, WinEDA_ModulePropertiesFrame::CreateTextModule) - EVT_BUTTON(ID_MODULE_EDIT_EDIT_TEXT, WinEDA_ModulePropertiesFrame::EditOrDelTextModule) - EVT_BUTTON(ID_MODULE_EDIT_DELETE_TEXT, WinEDA_ModulePropertiesFrame::EditOrDelTextModule) - EVT_BUTTON(ID_MODULE_PROPERTIES_EXCHANGE, WinEDA_ModulePropertiesFrame::ExchangeModule) - EVT_KICAD_CHOICEBOX(ID_MODULE_LISTBOX_SELECT, WinEDA_ModulePropertiesFrame::SelectTextListBox) - EVT_RADIOBOX(ID_LISTBOX_ORIENT_SELECT, WinEDA_ModulePropertiesFrame::ModuleOrientEvent) - EVT_BUTTON(ID_GOTO_MODULE_EDITOR, WinEDA_ModulePropertiesFrame::GotoModuleEditor) +/**************************************/ +/* class WinEDA_ModulePropertiesFrame */ +/**************************************/ +BEGIN_EVENT_TABLE( WinEDA_ModulePropertiesFrame, wxDialog ) + EVT_BUTTON( ID_ACCEPT_MODULE_PROPERTIES, + WinEDA_ModulePropertiesFrame::ModulePropertiesAccept ) + EVT_BUTTON( ID_CLOSE_MODULE_PROPERTIES, WinEDA_ModulePropertiesFrame::OnQuit ) + EVT_BUTTON( ID_MODULE_EDIT_ADD_TEXT, WinEDA_ModulePropertiesFrame::CreateTextModule ) + EVT_BUTTON( ID_MODULE_EDIT_EDIT_TEXT, WinEDA_ModulePropertiesFrame::EditOrDelTextModule ) + EVT_BUTTON( ID_MODULE_EDIT_DELETE_TEXT, WinEDA_ModulePropertiesFrame::EditOrDelTextModule ) + EVT_BUTTON( ID_MODULE_PROPERTIES_EXCHANGE, WinEDA_ModulePropertiesFrame::ExchangeModule ) + EVT_KICAD_CHOICEBOX( ID_MODULE_LISTBOX_SELECT, WinEDA_ModulePropertiesFrame::SelectTextListBox ) + EVT_RADIOBOX( ID_LISTBOX_ORIENT_SELECT, WinEDA_ModulePropertiesFrame::ModuleOrientEvent ) + EVT_BUTTON( ID_GOTO_MODULE_EDITOR, WinEDA_ModulePropertiesFrame::GotoModuleEditor ) END_EVENT_TABLE() /**********************/ /* class Panel3D_Ctrl */ /**********************/ -BEGIN_EVENT_TABLE(Panel3D_Ctrl, wxPanel) - EVT_BUTTON(ID_BROWSE_3D_LIB, Panel3D_Ctrl::Browse3DLib) - EVT_BUTTON(ID_ADD_3D_SHAPE, Panel3D_Ctrl::AddOrRemove3DShape) - EVT_BUTTON(ID_REMOVE_3D_SHAPE, Panel3D_Ctrl::AddOrRemove3DShape) +BEGIN_EVENT_TABLE( Panel3D_Ctrl, wxPanel ) + EVT_BUTTON( ID_BROWSE_3D_LIB, Panel3D_Ctrl::Browse3DLib ) + EVT_BUTTON( ID_ADD_3D_SHAPE, Panel3D_Ctrl::AddOrRemove3DShape ) + EVT_BUTTON( ID_REMOVE_3D_SHAPE, Panel3D_Ctrl::AddOrRemove3DShape ) END_EVENT_TABLE() /**************************************************************************************/ -WinEDA_ModulePropertiesFrame::WinEDA_ModulePropertiesFrame(WinEDA_BasePcbFrame *parent, - MODULE * Module,wxDC * DC, - const wxPoint & framepos): - wxDialog(parent, -1, _("Module properties"), framepos, wxDefaultSize, DIALOG_STYLE) +WinEDA_ModulePropertiesFrame::WinEDA_ModulePropertiesFrame( WinEDA_BasePcbFrame* parent, + MODULE* Module, wxDC* DC, + const wxPoint& framepos ) : + wxDialog( parent, -1, _( "Module properties" ), framepos, wxDefaultSize, DIALOG_STYLE ) /**************************************************************************************/ { -wxString number; + wxString number; - SetIcon( wxICON(icon_modedit) ); // Give an icon + SetIcon( wxICON( icon_modedit ) ); // Give an icon - m_Parent = parent; - SetFont(*g_DialogFont); - m_DC = DC; + m_Parent = parent; + SetFont( *g_DialogFont ); + m_DC = DC; - m_LayerCtrl = NULL; - m_OrientCtrl = NULL; - m_OrientValue = NULL; - m_Doc = m_Keyword = NULL; + m_LayerCtrl = NULL; + m_OrientCtrl = NULL; + m_OrientValue = NULL; + m_Doc = m_Keyword = NULL; - m_CurrentModule = Module; - m_DeleteFieddButton = NULL; + m_CurrentModule = Module; + m_DeleteFieddButton = NULL; - if ( m_CurrentModule ) - { - } + if( m_CurrentModule ) + { + } - CreateControls(); + CreateControls(); - GetSizer()->Fit(this); - GetSizer()->SetSizeHints(this); + GetSizer()->Fit( this ); + GetSizer()->SetSizeHints( this ); Centre(); } + /*****************************************************/ -void WinEDA_ModulePropertiesFrame::CreateControls(void) +void WinEDA_ModulePropertiesFrame::CreateControls( void ) /*****************************************************/ -{ -wxPoint pos; -wxButton * Button; -bool FullOptions = FALSE; +{ + wxPoint pos; + wxButton* Button; + bool FullOptions = FALSE; - if ( m_Parent->m_Ident == PCB_FRAME ) FullOptions = TRUE; + if( m_Parent->m_Ident == PCB_FRAME ) + FullOptions = TRUE; - m_GeneralBoxSizer = new wxBoxSizer(wxVERTICAL); - SetSizer(m_GeneralBoxSizer); + m_GeneralBoxSizer = new wxBoxSizer( wxVERTICAL ); + SetSizer( m_GeneralBoxSizer ); - m_NoteBook = new wxNotebook(this, ID_NOTEBOOK); - m_NoteBook->SetFont(*g_DialogFont); - m_GeneralBoxSizer->Add(m_NoteBook, 0, wxGROW|wxALL, 5); + m_NoteBook = new wxNotebook( this, ID_NOTEBOOK ); + m_NoteBook->SetFont( *g_DialogFont ); + m_GeneralBoxSizer->Add( m_NoteBook, 0, wxGROW | wxALL, 5 ); - // Add panels - m_PanelProperties = new wxPanel(m_NoteBook, -1); - m_PanelProperties->SetFont(*g_DialogFont); - m_PanelPropertiesBoxSizer = new wxBoxSizer(wxHORIZONTAL); - m_PanelProperties->SetSizer(m_PanelPropertiesBoxSizer); - BuildPanelModuleProperties(FullOptions); - m_NoteBook->AddPage(m_PanelProperties, _("Properties"), TRUE); + // Add panels + m_PanelProperties = new wxPanel( m_NoteBook, -1 ); + m_PanelProperties->SetFont( *g_DialogFont ); + m_PanelPropertiesBoxSizer = new wxBoxSizer( wxHORIZONTAL ); + m_PanelProperties->SetSizer( m_PanelPropertiesBoxSizer ); + BuildPanelModuleProperties( FullOptions ); + m_NoteBook->AddPage( m_PanelProperties, _( "Properties" ), TRUE ); - m_Panel3D = new Panel3D_Ctrl(this, m_NoteBook, -1, - m_CurrentModule->m_3D_Drawings); - m_NoteBook->AddPage(m_Panel3D, _("3D settings"), FALSE); + m_Panel3D = new Panel3D_Ctrl( this, m_NoteBook, -1, + m_CurrentModule->m_3D_Drawings ); + m_NoteBook->AddPage( m_Panel3D, _( "3D settings" ), FALSE ); - /* creation des autres formes 3D */ - Panel3D_Ctrl * panel3D = m_Panel3D, * nextpanel3D; - Struct3D_Master *draw3D = m_CurrentModule->m_3D_Drawings; - draw3D = (Struct3D_Master *) draw3D->Pnext; - for ( ; draw3D != NULL; draw3D = (Struct3D_Master *) draw3D->Pnext) - { - nextpanel3D = new Panel3D_Ctrl(this, m_NoteBook, -1, draw3D); - m_NoteBook->AddPage(nextpanel3D, _("3D settings"), FALSE); - panel3D->m_Pnext = nextpanel3D; - nextpanel3D->m_Pback = panel3D; - panel3D = nextpanel3D; - } + /* creation des autres formes 3D */ + Panel3D_Ctrl* panel3D = m_Panel3D, * nextpanel3D; + Struct3D_Master* draw3D = m_CurrentModule->m_3D_Drawings; + draw3D = (Struct3D_Master*) draw3D->Pnext; + for( ; draw3D != NULL; draw3D = (Struct3D_Master*) draw3D->Pnext ) + { + nextpanel3D = new Panel3D_Ctrl( this, m_NoteBook, -1, draw3D ); + m_NoteBook->AddPage( nextpanel3D, _( "3D settings" ), FALSE ); + panel3D->m_Pnext = nextpanel3D; + nextpanel3D->m_Pback = panel3D; + panel3D = nextpanel3D; + } + /* Creation des boutons de commande */ + wxBoxSizer* ButtonsBoxSizer = new wxBoxSizer( wxHORIZONTAL ); + m_GeneralBoxSizer->Add( ButtonsBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); - /* Creation des boutons de commande */ - wxBoxSizer* ButtonsBoxSizer = new wxBoxSizer(wxHORIZONTAL); - m_GeneralBoxSizer->Add(ButtonsBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + Button = new wxButton( this, ID_ACCEPT_MODULE_PROPERTIES, + _( "Ok" ) ); + Button->SetForegroundColour( *wxRED ); + ButtonsBoxSizer->Add( Button, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - Button = new wxButton(this, ID_ACCEPT_MODULE_PROPERTIES, - _("Ok")); - Button->SetForegroundColour(*wxRED); - ButtonsBoxSizer->Add(Button, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - - Button = new wxButton(this, ID_CLOSE_MODULE_PROPERTIES, - _("Cancel")); - Button->SetForegroundColour(*wxBLUE); - ButtonsBoxSizer->Add(Button, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + Button = new wxButton( this, ID_CLOSE_MODULE_PROPERTIES, + _( "Cancel" ) ); + Button->SetForegroundColour( *wxBLUE ); + ButtonsBoxSizer->Add( Button, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); } + /***********************************************************/ -void Panel3D_Ctrl::AddOrRemove3DShape(wxCommandEvent& event) +void Panel3D_Ctrl::AddOrRemove3DShape( wxCommandEvent& event ) /***********************************************************/ { - if( event.GetId() == ID_ADD_3D_SHAPE) - { - Panel3D_Ctrl * panel3D = new Panel3D_Ctrl(m_ParentFrame, m_Parent, - -1, NULL); - m_Parent->InsertPage(m_Parent->GetSelection()+1, - panel3D, _("3D settings"), TRUE); - panel3D->m_Pback = this; - panel3D->m_Pnext = m_Pnext; - if ( m_Pnext ) m_Pnext->m_Pback = panel3D; - m_Pnext = panel3D; - } + if( event.GetId() == ID_ADD_3D_SHAPE ) + { + Panel3D_Ctrl* panel3D = new Panel3D_Ctrl( m_ParentFrame, m_Parent, + -1, NULL ); + m_Parent->InsertPage( m_Parent->GetSelection() + 1, + panel3D, _( "3D settings" ), TRUE ); + panel3D->m_Pback = this; + panel3D->m_Pnext = m_Pnext; + if( m_Pnext ) + m_Pnext->m_Pback = panel3D; + m_Pnext = panel3D; + } - if( event.GetId() == ID_REMOVE_3D_SHAPE) - { - if ( m_Pback ) - { - m_Pback->m_Pnext = m_Pnext; - if ( m_Pnext ) m_Pnext->m_Pback = m_Pback; - m_Parent->DeletePage(m_Parent->GetSelection()); - m_ParentFrame->Refresh(TRUE); - } - } + if( event.GetId() == ID_REMOVE_3D_SHAPE ) + { + if( m_Pback ) + { + m_Pback->m_Pnext = m_Pnext; + if( m_Pnext ) + m_Pnext->m_Pback = m_Pback; + m_Parent->DeletePage( m_Parent->GetSelection() ); + m_ParentFrame->Refresh( TRUE ); + } + } } + /***************************************************************************/ -void WinEDA_ModulePropertiesFrame::BuildPanelModuleProperties(bool FullOptions) +void WinEDA_ModulePropertiesFrame::BuildPanelModuleProperties( bool FullOptions ) /***************************************************************************/ + /* creation du panel d'edition des proprietes du module -*/ + */ { -wxButton * Button; -wxStaticText* StaticText; -wxBoxSizer* PropLeftSizer; -wxBoxSizer* PropRightSizer; -wxString msg; - - /* Create a sizer for controls in the left column */ - PropLeftSizer = new wxBoxSizer(wxVERTICAL); - m_PanelPropertiesBoxSizer->Add(PropLeftSizer, 0, wxGROW|wxALL, 5); - /* Create a sizer for controls in the right column */ - PropRightSizer = new wxBoxSizer(wxVERTICAL); - m_PanelPropertiesBoxSizer->Add(PropRightSizer, 0, wxGROW|wxALL, 5); + wxButton* Button; + wxStaticText* StaticText; + wxBoxSizer* PropLeftSizer; + wxBoxSizer* PropRightSizer; + wxString msg; - if ( FullOptions ) // Module is on a board - { - Button = new wxButton(m_PanelProperties, ID_MODULE_PROPERTIES_EXCHANGE, - _("Change module(s)")); - Button->SetForegroundColour(wxColor(80,40,0)); - PropRightSizer->Add(Button, 0, wxGROW|wxALL, 5); - Button = new wxButton(m_PanelProperties, ID_GOTO_MODULE_EDITOR, - _("Goto Module Editor")); - Button->SetForegroundColour(wxColor(0,128,80) ); - PropRightSizer->Add(Button, 0, wxGROW|wxALL, 5); - } - else // Module is edited in libedit - { - StaticText = new wxStaticText( m_PanelProperties, wxID_STATIC, _("Doc"), wxDefaultPosition, wxDefaultSize, 0 ); - PropLeftSizer->Add(StaticText, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); - m_Doc = new wxTextCtrl(m_PanelProperties, -1, - m_CurrentModule->m_Doc); - PropLeftSizer->Add(m_Doc, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + /* Create a sizer for controls in the left column */ + PropLeftSizer = new wxBoxSizer( wxVERTICAL ); + m_PanelPropertiesBoxSizer->Add( PropLeftSizer, 0, wxGROW | wxALL, 5 ); + /* Create a sizer for controls in the right column */ + PropRightSizer = new wxBoxSizer( wxVERTICAL ); + m_PanelPropertiesBoxSizer->Add( PropRightSizer, 0, wxGROW | wxALL, 5 ); - StaticText = new wxStaticText( m_PanelProperties, wxID_STATIC, _("Keywords"), wxDefaultPosition, wxDefaultSize, 0 ); - PropLeftSizer->Add(StaticText, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); - m_Keyword = new wxTextCtrl(m_PanelProperties, -1, - m_CurrentModule->m_KeyWord ); - PropLeftSizer->Add(m_Keyword, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); - } + if( FullOptions ) // Module is on a board + { + Button = new wxButton( m_PanelProperties, ID_MODULE_PROPERTIES_EXCHANGE, + _( "Change module(s)" ) ); + Button->SetForegroundColour( wxColor( 80, 40, 0 ) ); + PropRightSizer->Add( Button, 0, wxGROW | wxALL, 5 ); + Button = new wxButton( m_PanelProperties, ID_GOTO_MODULE_EDITOR, + _( "Goto Module Editor" ) ); + Button->SetForegroundColour( wxColor( 0, 128, 80 ) ); + PropRightSizer->Add( Button, 0, wxGROW | wxALL, 5 ); + } + else // Module is edited in libedit + { + StaticText = new wxStaticText( m_PanelProperties, wxID_STATIC, _( + "Doc" ), wxDefaultPosition, wxDefaultSize, 0 ); + PropLeftSizer->Add( StaticText, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); + m_Doc = new wxTextCtrl( m_PanelProperties, -1, + m_CurrentModule->m_Doc ); + PropLeftSizer->Add( m_Doc, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); - wxStaticBox * box = new wxStaticBox(m_PanelProperties, -1, _("Fields:")); - m_TextListBox = new WinEDAChoiceBox(m_PanelProperties, ID_MODULE_LISTBOX_SELECT ); - ReCreateFieldListBox(); - m_TextListBox->SetSelection(0); - - wxStaticBoxSizer* StaticBoxSizer = new wxStaticBoxSizer(box, wxVERTICAL); - PropLeftSizer->Add(StaticBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); - StaticBoxSizer->Add(m_TextListBox, 0, wxGROW|wxALL, 5); + StaticText = new wxStaticText( m_PanelProperties, wxID_STATIC, _( + "Keywords" ), wxDefaultPosition, wxDefaultSize, 0 ); + PropLeftSizer->Add( StaticText, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); + m_Keyword = new wxTextCtrl( m_PanelProperties, -1, + m_CurrentModule->m_KeyWord ); + PropLeftSizer->Add( m_Keyword, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); + } - Button = new wxButton(m_PanelProperties, ID_MODULE_EDIT_ADD_TEXT, - _("Add Field")); - Button->SetForegroundColour(*wxBLACK); - StaticBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); + wxStaticBox* box = new wxStaticBox( m_PanelProperties, -1, _( "Fields:" ) ); + m_TextListBox = new WinEDAChoiceBox( m_PanelProperties, ID_MODULE_LISTBOX_SELECT ); + ReCreateFieldListBox(); + m_TextListBox->SetSelection( 0 ); - Button = new wxButton(m_PanelProperties, ID_MODULE_EDIT_EDIT_TEXT, - _("Edit Field")); - Button->SetForegroundColour(*wxBLACK); - StaticBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT, 5); + wxStaticBoxSizer* StaticBoxSizer = new wxStaticBoxSizer( box, wxVERTICAL ); + PropLeftSizer->Add( StaticBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); + StaticBoxSizer->Add( m_TextListBox, 0, wxGROW | wxALL, 5 ); - m_DeleteFieddButton = Button = new wxButton(m_PanelProperties, ID_MODULE_EDIT_DELETE_TEXT, - _("Delete Field")); - m_DeleteFieddButton->SetForegroundColour(*wxBLACK); - m_DeleteFieddButton->Enable(FALSE); // Enable pour fields autres que ref et valeur - StaticBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + Button = new wxButton( m_PanelProperties, ID_MODULE_EDIT_ADD_TEXT, + _( "Add Field" ) ); + Button->SetForegroundColour( *wxBLACK ); + StaticBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); - if ( FullOptions ) - { - wxString layer_list[2] = { _("Component"), _("Copper") }; - m_LayerCtrl = new wxRadioBox( m_PanelProperties, -1, _("Layer"), wxDefaultPosition, - wxSize(-1,-1), 2, layer_list, 1); - m_LayerCtrl->SetSelection( (m_CurrentModule->m_Layer == CUIVRE_N) ? 1 : 0); - PropLeftSizer->Add(m_LayerCtrl, 0, wxGROW|wxALL, 5); + Button = new wxButton( m_PanelProperties, ID_MODULE_EDIT_EDIT_TEXT, + _( "Edit Field" ) ); + Button->SetForegroundColour( *wxBLACK ); + StaticBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); - bool select = FALSE; - wxString orient_list[5] = { - _("Normal"), wxT("+ 90.0"), wxT("- 90.0"), wxT("180.0"), _("User") }; - m_OrientCtrl = new wxRadioBox( m_PanelProperties, ID_LISTBOX_ORIENT_SELECT, _("Orient"), - wxDefaultPosition, wxSize(-1,-1), 5, orient_list, 1); - PropLeftSizer->Add(m_OrientCtrl, 0, wxGROW|wxALL, 5); + m_DeleteFieddButton = Button = new wxButton( m_PanelProperties, ID_MODULE_EDIT_DELETE_TEXT, + _( "Delete Field" ) ); + m_DeleteFieddButton->SetForegroundColour( *wxBLACK ); + m_DeleteFieddButton->Enable( FALSE ); // Enable pour fields autres que ref et valeur + StaticBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); - switch (m_CurrentModule->m_Orient) - { - case 0: - m_OrientCtrl->SetSelection( 0 ); - break; + if( FullOptions ) + { + wxString layer_list[2] = { _( "Component" ), _( "Copper" ) }; + m_LayerCtrl = new wxRadioBox( m_PanelProperties, -1, _( "Layer" ), wxDefaultPosition, + wxSize( -1, -1 ), 2, layer_list, 1 ); + m_LayerCtrl->SetSelection( (m_CurrentModule->m_Layer == CUIVRE_N) ? 1 : 0 ); + PropLeftSizer->Add( m_LayerCtrl, 0, wxGROW | wxALL, 5 ); - case 900: - case -2700: - m_OrientCtrl->SetSelection( 1 ); - break; + bool select = FALSE; + + wxString orient_list[5] = { + _( "Normal" ), wxT( "+ 90.0" ), wxT( "- 90.0" ), wxT( "180.0" ), _( "User" ) + }; + + m_OrientCtrl = new wxRadioBox( m_PanelProperties, ID_LISTBOX_ORIENT_SELECT, _( "Orient" ), + wxDefaultPosition, wxSize( -1, -1 ), 5, orient_list, 1 ); + PropLeftSizer->Add( m_OrientCtrl, 0, wxGROW | wxALL, 5 ); - case -900: - case 2700: - m_OrientCtrl->SetSelection( 2 ); - break; + switch( m_CurrentModule->m_Orient ) + { + case 0: + m_OrientCtrl->SetSelection( 0 ); + break; - case -1800: - case 1800: - m_OrientCtrl->SetSelection( 3 ); - break; + case 900: + case -2700: + m_OrientCtrl->SetSelection( 1 ); + break; - default: - m_OrientCtrl->SetSelection( 4 ); - select = TRUE; - break; - } + case -900: + case 2700: + m_OrientCtrl->SetSelection( 2 ); + break; - StaticText = new wxStaticText( m_PanelProperties, - wxID_STATIC, _("Orient (0.1 deg)"), wxDefaultPosition, wxDefaultSize, 0 ); - PropLeftSizer->Add(StaticText, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); - msg << m_CurrentModule->m_Orient; - m_OrientValue = new wxTextCtrl(m_PanelProperties, -1, msg); - m_OrientValue->Enable(select); - PropLeftSizer->Add(m_OrientValue, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); - } + case -1800: + case 1800: + m_OrientCtrl->SetSelection( 3 ); + break; - /* Controls on right side of the dialog */ -wxString attribut_list[3] = { _("Normal"), _("Normal+Insert"), _("Virtual") }; - m_AttributsCtrl = new wxRadioBox( m_PanelProperties, -1, _("Attributs"), wxDefaultPosition, - wxSize(-1,-1), 3, attribut_list, 1); -#if wxCHECK_VERSION(2,8,0) - m_AttributsCtrl->SetItemToolTip(0, _("Use this attribute for most non smd components")); - m_AttributsCtrl->SetItemToolTip(1, - _("Use this attribute for smd components.\nOnly components with this option are put in the footprint position list file")); - m_AttributsCtrl->SetItemToolTip(2, - _("Use this attribute for \"virtual\" components drawn on board (like a old ISA PC bus connector)")); + default: + m_OrientCtrl->SetSelection( 4 ); + select = TRUE; + break; + } + + StaticText = new wxStaticText( m_PanelProperties, + wxID_STATIC, _( + "Orient (0.1 deg)" ), wxDefaultPosition, wxDefaultSize, + 0 ); + PropLeftSizer->Add( StaticText, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); + msg << m_CurrentModule->m_Orient; + m_OrientValue = new wxTextCtrl( m_PanelProperties, -1, msg ); + m_OrientValue->Enable( select ); + PropLeftSizer->Add( m_OrientValue, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); + } + + /* Controls on right side of the dialog */ + wxString attribut_list[3] = { _( "Normal" ), _( "Normal+Insert" ), _( "Virtual" ) }; + m_AttributsCtrl = new wxRadioBox( m_PanelProperties, -1, _( "Attributs" ), wxDefaultPosition, + wxSize( -1, -1 ), 3, attribut_list, 1 ); +#if wxCHECK_VERSION( 2, 8, 0 ) + m_AttributsCtrl->SetItemToolTip( 0, _( "Use this attribute for most non smd components" ) ); + m_AttributsCtrl->SetItemToolTip( 1, + _("Use this attribute for smd components.\nOnly components with this option are put in the footprint position list file")); + m_AttributsCtrl->SetItemToolTip( 2, + _("Use this attribute for \"virtual\" components drawn on board (like a old ISA PC bus connector)" )); #endif - PropRightSizer->Add(m_AttributsCtrl, 0, wxGROW|wxALL, 5); + PropRightSizer->Add( m_AttributsCtrl, 0, wxGROW | wxALL, 5 ); - switch (m_CurrentModule->m_Attributs & 255) - { - case 0: - m_AttributsCtrl->SetSelection( 0 ); - break; + switch( m_CurrentModule->m_Attributs & 255 ) + { + case 0: + m_AttributsCtrl->SetSelection( 0 ); + break; - case MOD_CMS: - m_AttributsCtrl->SetSelection( 1 ); - break; + case MOD_CMS: + m_AttributsCtrl->SetSelection( 1 ); + break; - case MOD_VIRTUAL: - m_AttributsCtrl->SetSelection( 2 ); - break; + case MOD_VIRTUAL: + m_AttributsCtrl->SetSelection( 2 ); + break; - default: - m_AttributsCtrl->SetSelection( 0 ); - break; - } + default: + m_AttributsCtrl->SetSelection( 0 ); + break; + } -wxString properties_list[2] = { _("Free"), _("Locked")}; - m_AutoPlaceCtrl = new wxRadioBox( m_PanelProperties, -1, _("Move and Auto Place"), wxDefaultPosition, - wxSize(-1,-1), 2, properties_list, 1); - m_AutoPlaceCtrl->SetSelection( - (m_CurrentModule->m_ModuleStatus & MODULE_is_LOCKED) ? 1 : 0); -#if wxCHECK_VERSION(2,8,0) - m_AutoPlaceCtrl->SetItemToolTip(0, _("Enable hotkey move commands and Auto Placement")); - m_AutoPlaceCtrl->SetItemToolTip(1, _("Disable hotkey move commands and Auto Placement")); + wxString properties_list[2] = { _( "Free" ), _( "Locked" ) }; + m_AutoPlaceCtrl = new wxRadioBox( m_PanelProperties, -1, _( + "Move and Auto Place" ), wxDefaultPosition, + wxSize( -1, -1 ), 2, properties_list, 1 ); + m_AutoPlaceCtrl->SetSelection( + (m_CurrentModule->m_ModuleStatus & MODULE_is_LOCKED) ? 1 : 0 ); +#if wxCHECK_VERSION( 2, 8, 0 ) + m_AutoPlaceCtrl->SetItemToolTip( 0, _( "Enable hotkey move commands and Auto Placement" ) ); + m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Disable hotkey move commands and Auto Placement" ) ); #endif - PropRightSizer->Add(m_AutoPlaceCtrl, 0, wxGROW|wxALL, 5); + PropRightSizer->Add( m_AutoPlaceCtrl, 0, wxGROW | wxALL, 5 ); - StaticText = new wxStaticText(m_PanelProperties, -1, _("Rot 90")); - PropRightSizer->Add(StaticText, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); - m_CostRot90Ctrl = new wxSlider(m_PanelProperties, -1, - m_CurrentModule->m_CntRot90, 0, 10, wxDefaultPosition, wxSize(100, -1), - wxSL_HORIZONTAL + wxSL_AUTOTICKS + wxSL_LABELS) ; - PropRightSizer->Add(m_CostRot90Ctrl, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + StaticText = new wxStaticText( m_PanelProperties, -1, _( "Rot 90" ) ); + PropRightSizer->Add( StaticText, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); + m_CostRot90Ctrl = new wxSlider( m_PanelProperties, -1, + m_CurrentModule->m_CntRot90, 0, 10, wxDefaultPosition, + wxSize( 100, -1 ), + wxSL_HORIZONTAL + wxSL_AUTOTICKS + wxSL_LABELS ); + PropRightSizer->Add( m_CostRot90Ctrl, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); - StaticText = new wxStaticText(m_PanelProperties, -1, _("Rot 180")); - PropRightSizer->Add(StaticText, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); - m_CostRot180Ctrl= new wxSlider(m_PanelProperties, -1, - m_CurrentModule->m_CntRot180, 0, 10, wxDefaultPosition, wxSize(100, -1), - wxSL_HORIZONTAL + wxSL_AUTOTICKS + wxSL_LABELS) ; - PropRightSizer->Add(m_CostRot180Ctrl, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + StaticText = new wxStaticText( m_PanelProperties, -1, _( "Rot 180" ) ); + PropRightSizer->Add( StaticText, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); + m_CostRot180Ctrl = new wxSlider( m_PanelProperties, + -1, + m_CurrentModule->m_CntRot180, + 0, + 10, + wxDefaultPosition, + wxSize( 100, -1 ), + wxSL_HORIZONTAL + wxSL_AUTOTICKS + wxSL_LABELS ); + PropRightSizer->Add( m_CostRot180Ctrl, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); } + /**************************************************************/ -Panel3D_Ctrl::Panel3D_Ctrl(WinEDA_ModulePropertiesFrame * parentframe, - wxNotebook * parent, - int id, Struct3D_Master * struct3D): - wxPanel(parent, id) +Panel3D_Ctrl::Panel3D_Ctrl( WinEDA_ModulePropertiesFrame* parentframe, + wxNotebook* parent, + int id, Struct3D_Master* struct3D ) : + wxPanel( parent, id ) /**************************************************************/ + /* create the dialog panel managing 3D shape infos -*/ + */ { -wxButton * button; -S3D_Vertex dummy_vertex; -wxBoxSizer* PropLeftSizer; -wxBoxSizer* PropRightSizer; + wxButton* button; + S3D_Vertex dummy_vertex; + wxBoxSizer* PropLeftSizer; + wxBoxSizer* PropRightSizer; - m_Pnext = m_Pback = NULL; + m_Pnext = m_Pback = NULL; - m_Parent = parent; - m_ParentFrame = parentframe; - SetFont(*g_DialogFont); - wxBoxSizer * Panel3DBoxSizer = new wxBoxSizer(wxVERTICAL); - SetSizer(Panel3DBoxSizer); + m_Parent = parent; + m_ParentFrame = parentframe; + SetFont( *g_DialogFont ); + wxBoxSizer* Panel3DBoxSizer = new wxBoxSizer( wxVERTICAL ); + SetSizer( Panel3DBoxSizer ); - wxStaticText* StaticText = new wxStaticText( this, wxID_STATIC, _("3D Shape Name"), - wxDefaultPosition, wxDefaultSize, 0 ); - Panel3DBoxSizer->Add(StaticText, 0, wxGROW|wxALL|wxADJUST_MINSIZE, 5); - m_3D_ShapeName = new wxTextCtrl(this, -1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); - if ( struct3D ) m_3D_ShapeName->SetValue(struct3D->m_Shape3DName); - Panel3DBoxSizer->Add(m_3D_ShapeName, 0, wxGROW|wxALL, 5); + wxStaticText* StaticText = new wxStaticText( this, wxID_STATIC, _( "3D Shape Name" ), + wxDefaultPosition, wxDefaultSize, 0 ); + Panel3DBoxSizer->Add( StaticText, 0, wxGROW | wxALL | wxADJUST_MINSIZE, 5 ); + m_3D_ShapeName = new wxTextCtrl( this, -1, _T( "" ), wxDefaultPosition, wxDefaultSize, 0 ); + if( struct3D ) + m_3D_ShapeName->SetValue( struct3D->m_Shape3DName ); + Panel3DBoxSizer->Add( m_3D_ShapeName, 0, wxGROW | wxALL, 5 ); - wxBoxSizer * LowerBoxSizer = new wxBoxSizer(wxHORIZONTAL); - Panel3DBoxSizer->Add(LowerBoxSizer, 0, wxGROW|wxALL, 5); - /* Create a sizer for controls in the left column */ - PropLeftSizer = new wxBoxSizer(wxVERTICAL); - LowerBoxSizer->Add(PropLeftSizer, 0, wxGROW|wxALL, 5); - /* Create a sizer for controls in the right column */ - PropRightSizer = new wxBoxSizer(wxVERTICAL); - LowerBoxSizer->Add(PropRightSizer, 0, wxGROW|wxALL, 5); + wxBoxSizer* LowerBoxSizer = new wxBoxSizer( wxHORIZONTAL ); + Panel3DBoxSizer->Add( LowerBoxSizer, 0, wxGROW | wxALL, 5 ); + /* Create a sizer for controls in the left column */ + PropLeftSizer = new wxBoxSizer( wxVERTICAL ); + LowerBoxSizer->Add( PropLeftSizer, 0, wxGROW | wxALL, 5 ); + /* Create a sizer for controls in the right column */ + PropRightSizer = new wxBoxSizer( wxVERTICAL ); + LowerBoxSizer->Add( PropRightSizer, 0, wxGROW | wxALL, 5 ); - button = new wxButton(this, ID_BROWSE_3D_LIB, _("Browse")); - button->SetForegroundColour(*wxBLUE); - PropRightSizer->Add(button, 0, wxGROW|wxLEFT|wxRIGHT, 5); + button = new wxButton( this, ID_BROWSE_3D_LIB, _( "Browse" ) ); + button->SetForegroundColour( *wxBLUE ); + PropRightSizer->Add( button, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); - button = new wxButton(this, ID_ADD_3D_SHAPE, _("Add 3D Shape")); - button->SetForegroundColour(*wxRED); - PropRightSizer->Add(button, 0, wxGROW|wxLEFT|wxRIGHT, 5); + button = new wxButton( this, ID_ADD_3D_SHAPE, _( "Add 3D Shape" ) ); + button->SetForegroundColour( *wxRED ); + PropRightSizer->Add( button, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); - if ( (struct3D == NULL) || (struct3D->Pback != NULL) ) - { - button = new wxButton(this, ID_REMOVE_3D_SHAPE, _("Remove 3D Shape")); - button->SetForegroundColour(*wxRED); - PropRightSizer->Add(button, 0, wxGROW|wxLEFT|wxRIGHT, 5); - } + if( (struct3D == NULL) || (struct3D->Pback != NULL) ) + { + button = new wxButton( this, ID_REMOVE_3D_SHAPE, _( "Remove 3D Shape" ) ); + button->SetForegroundColour( *wxRED ); + PropRightSizer->Add( button, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); + } - wxBoxSizer * BoxSizer = new wxBoxSizer(wxVERTICAL); - m_3D_Scale = new WinEDA_VertexCtrl(this, _("Shape Scale:"), BoxSizer, - 2, 1); - if ( struct3D ) m_3D_Scale->SetValue(struct3D->m_MatScale); - PropLeftSizer->Add(BoxSizer, 0, wxGROW|wxALL, 5); + wxBoxSizer* BoxSizer = new wxBoxSizer( wxVERTICAL ); + m_3D_Scale = new WinEDA_VertexCtrl( this, _( "Shape Scale:" ), BoxSizer, + 2, 1 ); + if( struct3D ) + m_3D_Scale->SetValue( struct3D->m_MatScale ); + PropLeftSizer->Add( BoxSizer, 0, wxGROW | wxALL, 5 ); - BoxSizer = new wxBoxSizer(wxVERTICAL); - m_3D_Offset = new WinEDA_VertexCtrl(this, _("Shape Offset:"), BoxSizer, - 2, 1); - if ( struct3D ) m_3D_Offset->SetValue(struct3D->m_MatPosition); - else m_3D_Offset->SetValue(dummy_vertex); - PropLeftSizer->Add(BoxSizer, 0, wxGROW|wxALL, 5); + BoxSizer = new wxBoxSizer( wxVERTICAL ); + m_3D_Offset = new WinEDA_VertexCtrl( this, _( "Shape Offset:" ), BoxSizer, + 2, 1 ); + if( struct3D ) + m_3D_Offset->SetValue( struct3D->m_MatPosition ); + else + m_3D_Offset->SetValue( dummy_vertex ); + PropLeftSizer->Add( BoxSizer, 0, wxGROW | wxALL, 5 ); - BoxSizer = new wxBoxSizer(wxVERTICAL); - m_3D_Rotation = new WinEDA_VertexCtrl(this, _("Shape Rotation:"), BoxSizer, - 2, 1); - if ( struct3D ) m_3D_Rotation->SetValue(struct3D->m_MatRotation); - else m_3D_Rotation->SetValue(dummy_vertex); - PropLeftSizer->Add(BoxSizer, 0, wxGROW|wxALL, 5); + BoxSizer = new wxBoxSizer( wxVERTICAL ); + m_3D_Rotation = new WinEDA_VertexCtrl( this, _( "Shape Rotation:" ), BoxSizer, + 2, 1 ); + if( struct3D ) + m_3D_Rotation->SetValue( struct3D->m_MatRotation ); + else + m_3D_Rotation->SetValue( dummy_vertex ); + PropLeftSizer->Add( BoxSizer, 0, wxGROW | wxALL, 5 ); - if ( struct3D == NULL ) - { - dummy_vertex.x = dummy_vertex.y = dummy_vertex.z = 1.0; - m_3D_Scale->SetValue(dummy_vertex); - } + if( struct3D == NULL ) + { + dummy_vertex.x = dummy_vertex.y = dummy_vertex.z = 1.0; + m_3D_Scale->SetValue( dummy_vertex ); + } } + /********************************/ -Panel3D_Ctrl::~Panel3D_Ctrl(void) +Panel3D_Ctrl::~Panel3D_Ctrl( void ) /********************************/ { - delete m_3D_ShapeName; - delete m_3D_Scale; - delete m_3D_Offset; - delete m_3D_Rotation; + delete m_3D_ShapeName; + delete m_3D_Scale; + delete m_3D_Offset; + delete m_3D_Rotation; } /***************************************************/ -void Panel3D_Ctrl::Browse3DLib(wxCommandEvent& event) +void Panel3D_Ctrl::Browse3DLib( wxCommandEvent& event ) /***************************************************/ { -wxString fullfilename, shortfilename; -wxString fullpath = g_RealLibDirBuffer; -wxString mask = wxT("*"); + wxString fullfilename, shortfilename; + wxString fullpath = g_RealLibDirBuffer; + wxString mask = wxT( "*" ); - fullpath += LIB3D_PATH; - mask += g_Shapes3DExtBuffer; + fullpath += LIB3D_PATH; + mask += g_Shapes3DExtBuffer; #ifdef __WINDOWS__ - fullpath.Replace( wxT("/"), wxT("\\") ); + fullpath.Replace( wxT( "/" ), wxT( "\\" ) ); #endif - fullfilename = EDA_FileSelector( _("3D Shape:"), - fullpath, /* Chemin par defaut */ - wxEmptyString, /* nom fichier par defaut */ - g_Shapes3DExtBuffer, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_OPEN, - TRUE - ); + fullfilename = EDA_FileSelector( _( "3D Shape:" ), + fullpath, /* Chemin par defaut */ + wxEmptyString, /* nom fichier par defaut */ + g_Shapes3DExtBuffer, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_OPEN, + TRUE + ); - if ( fullfilename == wxEmptyString ) return; + if( fullfilename == wxEmptyString ) + return; - shortfilename = MakeReducedFileName( fullfilename, - fullpath, wxEmptyString); - m_3D_ShapeName->SetValue(shortfilename); + shortfilename = MakeReducedFileName( fullfilename, + fullpath, wxEmptyString ); + m_3D_ShapeName->SetValue( shortfilename ); } /**********************************************************************/ -void WinEDA_ModulePropertiesFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +void WinEDA_ModulePropertiesFrame::OnQuit( wxCommandEvent& WXUNUSED (event) ) /**********************************************************************/ { - Close(true); // true is to force the frame to close + Close( true ); // true is to force the frame to close } /******************************************************************************/ -void WinEDA_ModulePropertiesFrame::ModulePropertiesAccept(wxCommandEvent& event) +void WinEDA_ModulePropertiesFrame::ModulePropertiesAccept( wxCommandEvent& event ) /******************************************************************************/ { -bool change_layer = FALSE; + bool change_layer = FALSE; - if ( m_DC ) m_Parent->DrawPanel->CursorOff(m_DC); + if( m_DC ) + m_Parent->DrawPanel->CursorOff( m_DC ); - if ( m_DC ) - m_CurrentModule->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0), GR_XOR); + if( m_DC ) + m_CurrentModule->Draw( m_Parent->DrawPanel, m_DC, wxPoint( 0, 0 ), GR_XOR ); - if ( m_OrientValue ) - { - long orient = 0; wxString msg = m_OrientValue->GetValue(); - msg.ToLong(&orient); - if( m_CurrentModule->m_Orient != orient) - m_Parent->Rotate_Module(m_DC, m_CurrentModule, - orient, FALSE); - } + if( m_OrientValue ) + { + long orient = 0; wxString msg = m_OrientValue->GetValue(); + msg.ToLong( &orient ); + if( m_CurrentModule->m_Orient != orient ) + m_Parent->Rotate_Module( m_DC, m_CurrentModule, + orient, FALSE ); + } - if ( m_LayerCtrl ) - { - if ( m_LayerCtrl->GetSelection() == 0 ) // layer req = COMPONENT - { - if( m_CurrentModule->m_Layer == CUIVRE_N) change_layer = TRUE; - } - else if( m_CurrentModule->m_Layer == CMP_N ) change_layer = TRUE; - } + if( m_LayerCtrl ) + { + if( m_LayerCtrl->GetSelection() == 0 ) // layer req = COMPONENT + { + if( m_CurrentModule->m_Layer == CUIVRE_N ) + change_layer = TRUE; + } + else if( m_CurrentModule->m_Layer == CMP_N ) + change_layer = TRUE; + } - if ( change_layer ) - { - m_Parent->Change_Side_Module(m_CurrentModule, m_DC); - } + if( change_layer ) + { + m_Parent->Change_Side_Module( m_CurrentModule, m_DC ); + } - if (m_AutoPlaceCtrl->GetSelection() == 1) - m_CurrentModule->m_ModuleStatus |= MODULE_is_LOCKED; - else m_CurrentModule->m_ModuleStatus &= ~MODULE_is_LOCKED; + if( m_AutoPlaceCtrl->GetSelection() == 1 ) + m_CurrentModule->m_ModuleStatus |= MODULE_is_LOCKED; + else + m_CurrentModule->m_ModuleStatus &= ~MODULE_is_LOCKED; - switch (m_AttributsCtrl->GetSelection()) - { - case 0: - m_CurrentModule->m_Attributs = 0; - break; + switch( m_AttributsCtrl->GetSelection() ) + { + case 0: + m_CurrentModule->m_Attributs = 0; + break; - case 1: - m_CurrentModule->m_Attributs = MOD_CMS; - break; + case 1: + m_CurrentModule->m_Attributs = MOD_CMS; + break; - case 2: - m_CurrentModule->m_Attributs = MOD_VIRTUAL; - break; - } + case 2: + m_CurrentModule->m_Attributs = MOD_VIRTUAL; + break; + } - m_CurrentModule->m_CntRot90 = m_CostRot90Ctrl->GetValue(); - m_CurrentModule->m_CntRot180 = m_CostRot180Ctrl->GetValue(); - if ( m_Doc ) m_CurrentModule->m_Doc = m_Doc->GetValue(); - if ( m_Keyword ) m_CurrentModule->m_KeyWord = m_Keyword->GetValue(); + m_CurrentModule->m_CntRot90 = m_CostRot90Ctrl->GetValue(); + m_CurrentModule->m_CntRot180 = m_CostRot180Ctrl->GetValue(); + if( m_Doc ) + m_CurrentModule->m_Doc = m_Doc->GetValue(); + if( m_Keyword ) + m_CurrentModule->m_KeyWord = m_Keyword->GetValue(); - /* Mise a jour des parametres 3D */ - Panel3D_Ctrl * panel3D = m_Panel3D; - Struct3D_Master *draw3D = m_CurrentModule->m_3D_Drawings, - * nextdraw3D; - for ( ; panel3D != NULL; panel3D = panel3D->m_Pnext ) - { - draw3D->m_Shape3DName = panel3D->m_3D_ShapeName->GetValue(); - draw3D->m_MatScale = panel3D->m_3D_Scale->GetValue(); - draw3D->m_MatRotation = panel3D->m_3D_Rotation->GetValue(); - draw3D->m_MatPosition = panel3D->m_3D_Offset->GetValue(); - if ( (draw3D->m_Shape3DName.IsEmpty() ) && - (draw3D != m_CurrentModule->m_3D_Drawings) ) - continue; - if ( (draw3D->Pnext == NULL) && panel3D->m_Pnext ) - { - nextdraw3D = new Struct3D_Master(draw3D); - nextdraw3D->Pback = draw3D; - draw3D->Pnext = nextdraw3D; - } - draw3D = (Struct3D_Master *) draw3D->Pnext; - } + /* Mise a jour des parametres 3D */ + Panel3D_Ctrl* panel3D = m_Panel3D; + Struct3D_Master* draw3D = m_CurrentModule->m_3D_Drawings, + * nextdraw3D; + for( ; panel3D != NULL; panel3D = panel3D->m_Pnext ) + { + draw3D->m_Shape3DName = panel3D->m_3D_ShapeName->GetValue(); + draw3D->m_MatScale = panel3D->m_3D_Scale->GetValue(); + draw3D->m_MatRotation = panel3D->m_3D_Rotation->GetValue(); + draw3D->m_MatPosition = panel3D->m_3D_Offset->GetValue(); + if( ( draw3D->m_Shape3DName.IsEmpty() ) + && (draw3D != m_CurrentModule->m_3D_Drawings) ) + continue; + if( (draw3D->Pnext == NULL) && panel3D->m_Pnext ) + { + nextdraw3D = new Struct3D_Master( draw3D ); + nextdraw3D->Pback = draw3D; + draw3D->Pnext = nextdraw3D; + } + draw3D = (Struct3D_Master*) draw3D->Pnext; + } - for ( ; draw3D != NULL; draw3D = nextdraw3D ) - { - nextdraw3D = (Struct3D_Master *)draw3D->Pnext; - (draw3D->Pback)->Pnext = NULL; - delete draw3D; - } + for( ; draw3D != NULL; draw3D = nextdraw3D ) + { + nextdraw3D = (Struct3D_Master*) draw3D->Pnext; + (draw3D->Pback)->Pnext = NULL; + delete draw3D; + } + m_CurrentModule->Set_Rectangle_Encadrement(); - m_CurrentModule->Set_Rectangle_Encadrement(); + m_Parent->GetScreen()->SetModify(); - m_Parent->GetScreen()->SetModify(); + Close( TRUE ); - Close(TRUE); - - if ( m_DC ) - m_CurrentModule->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0), GR_OR); - if ( m_DC ) m_Parent->DrawPanel->CursorOn(m_DC); + if( m_DC ) + m_CurrentModule->Draw( m_Parent->DrawPanel, m_DC, wxPoint( 0, 0 ), GR_OR ); + if( m_DC ) + m_Parent->DrawPanel->CursorOn( m_DC ); } /************************************************************************/ -void WinEDA_ModulePropertiesFrame::GotoModuleEditor(wxCommandEvent& event) +void WinEDA_ModulePropertiesFrame::GotoModuleEditor( wxCommandEvent& event ) /************************************************************************/ { - GoToEditor = TRUE; - if ( m_CurrentModule->m_TimeStamp == 0 ) // Module Editor needs a non null timestamp - { - m_CurrentModule->m_TimeStamp = GetTimeStamp(); - m_Parent->GetScreen()->SetModify(); - } + GoToEditor = TRUE; + if( m_CurrentModule->m_TimeStamp == 0 ) // Module Editor needs a non null timestamp + { + m_CurrentModule->m_TimeStamp = GetTimeStamp(); + m_Parent->GetScreen()->SetModify(); + } - Close(TRUE); + Close( TRUE ); } /**********************************************************************/ -void WinEDA_ModulePropertiesFrame::ExchangeModule(wxCommandEvent& event) +void WinEDA_ModulePropertiesFrame::ExchangeModule( wxCommandEvent& event ) /**********************************************************************/ { - m_Parent->InstallExchangeModuleFrame( m_CurrentModule, - m_DC, wxPoint(-1,-1) ); - // Attention: si il y a eu echange, m_CurrentModule a �t� delete! - m_Parent->GetScreen()->m_CurrentItem = NULL; - Close(TRUE); + m_Parent->InstallExchangeModuleFrame( m_CurrentModule, + m_DC, wxPoint( -1, -1 ) ); + + // Attention: si il y a eu echange, m_CurrentModule a �t� delete! + m_Parent->GetScreen()->SetCurItem( NULL ); + Close( TRUE ); } /*************************************************************************/ -void WinEDA_ModulePropertiesFrame::ModuleOrientEvent(wxCommandEvent& event) +void WinEDA_ModulePropertiesFrame::ModuleOrientEvent( wxCommandEvent& event ) /*************************************************************************/ { - switch ( m_OrientCtrl->GetSelection() ) - { - case 0: - m_OrientValue->Enable(FALSE); - m_OrientValue->SetValue( wxT("0") ); - break; + switch( m_OrientCtrl->GetSelection() ) + { + case 0: + m_OrientValue->Enable( FALSE ); + m_OrientValue->SetValue( wxT( "0" ) ); + break; - case 1: - m_OrientValue->Enable(FALSE); - m_OrientValue->SetValue( wxT("900") ); - break; + case 1: + m_OrientValue->Enable( FALSE ); + m_OrientValue->SetValue( wxT( "900" ) ); + break; - case 2: - m_OrientValue->Enable(FALSE); - m_OrientValue->SetValue( wxT("2700") ); - break; + case 2: + m_OrientValue->Enable( FALSE ); + m_OrientValue->SetValue( wxT( "2700" ) ); + break; - case 3: - m_OrientValue->Enable(FALSE); - m_OrientValue->SetValue( wxT("1800") ); - break; + case 3: + m_OrientValue->Enable( FALSE ); + m_OrientValue->SetValue( wxT( "1800" ) ); + break; - default: - m_OrientValue->Enable(FALSE); - m_OrientValue->Enable(TRUE); - break; - } + default: + m_OrientValue->Enable( FALSE ); + m_OrientValue->Enable( TRUE ); + break; + } } /*************************************************************************/ -void WinEDA_ModulePropertiesFrame::SelectTextListBox(wxCommandEvent& event) +void WinEDA_ModulePropertiesFrame::SelectTextListBox( wxCommandEvent& event ) /*************************************************************************/ { - SetTextListButtons(); + SetTextListButtons(); } + /*************************************************************************/ -void WinEDA_ModulePropertiesFrame::SetTextListButtons(void) +void WinEDA_ModulePropertiesFrame::SetTextListButtons( void ) /*************************************************************************/ { -int choice = m_TextListBox->GetChoice(); + int choice = m_TextListBox->GetChoice(); - if ( m_DeleteFieddButton == NULL ) return; + if( m_DeleteFieddButton == NULL ) + return; - if ( choice > 1 ) // Texte autre que ref ou valeur selectionne - { - m_DeleteFieddButton->Enable(TRUE); - } - else m_DeleteFieddButton->Enable(FALSE); + if( choice > 1 ) // Texte autre que ref ou valeur selectionne + { + m_DeleteFieddButton->Enable( TRUE ); + } + else + m_DeleteFieddButton->Enable( FALSE ); } /***********************************************************/ -void WinEDA_ModulePropertiesFrame::ReCreateFieldListBox(void) +void WinEDA_ModulePropertiesFrame::ReCreateFieldListBox( void ) /***********************************************************/ { - m_TextListBox->Clear(); + m_TextListBox->Clear(); - m_TextListBox->Append(m_CurrentModule->m_Reference->m_Text); - m_TextListBox->Append(m_CurrentModule->m_Value->m_Text); + m_TextListBox->Append( m_CurrentModule->m_Reference->m_Text ); + m_TextListBox->Append( m_CurrentModule->m_Value->m_Text ); - EDA_BaseStruct * item = m_CurrentModule->m_Drawings; - while ( item ) - { - if( item->m_StructType == TYPETEXTEMODULE ) - m_TextListBox->Append( ((TEXTE_MODULE*)item)->m_Text ); - item = item->Pnext; - } - - SetTextListButtons(); + EDA_BaseStruct* item = m_CurrentModule->m_Drawings; + while( item ) + { + if( item->m_StructType == TYPETEXTEMODULE ) + m_TextListBox->Append( ( (TEXTE_MODULE*) item )->m_Text ); + item = item->Pnext; + } + + SetTextListButtons(); } /************************************************************************/ -void WinEDA_ModulePropertiesFrame::CreateTextModule(wxCommandEvent& event) +void WinEDA_ModulePropertiesFrame::CreateTextModule( wxCommandEvent& event ) /************************************************************************/ + /* Cree un nouveau texte sur le module actif - Le texte sera mis en fonction Move -*/ + * Le texte sera mis en fonction Move + */ { -TEXTE_MODULE * Text; + TEXTE_MODULE* Text; - /* Creation de la place en memoire : */ - Text = m_Parent->CreateTextModule(m_CurrentModule, m_DC); + /* Creation de la place en memoire : */ + Text = m_Parent->CreateTextModule( m_CurrentModule, m_DC ); - ReCreateFieldListBox(); - m_TextListBox->SetSelection(2); - SetTextListButtons(); + ReCreateFieldListBox(); + m_TextListBox->SetSelection( 2 ); + SetTextListButtons(); } /****************************************************************************/ -void WinEDA_ModulePropertiesFrame::EditOrDelTextModule(wxCommandEvent& event) +void WinEDA_ModulePropertiesFrame::EditOrDelTextModule( wxCommandEvent& event ) /****************************************************************************/ { -int TextType = m_TextListBox->GetChoice(); -TEXTE_MODULE * Text = NULL; + int TextType = m_TextListBox->GetChoice(); + TEXTE_MODULE* Text = NULL; - if ( TextType < 0 ) return; //No selection - - - if ( m_DC ) m_Parent->DrawPanel->CursorOff(m_DC); + if( TextType < 0 ) + return; //No selection - // Get a pointer on the field - if ( TextType == 0 ) Text = m_CurrentModule->m_Reference; - else if ( TextType == 1 ) Text = m_CurrentModule->m_Value; - else // Search the field 2 or more, because field 0 and 1 are ref and value - { - EDA_BaseStruct * item = m_CurrentModule->m_Drawings; - int jj = 2; - while ( item ) - { - if( item->m_StructType == TYPETEXTEMODULE ) - { - if ( jj == TextType ) // Texte trouv� - { - Text = (TEXTE_MODULE*)item; - break; - } - } - item = item->Pnext; jj++; - } - } + if( m_DC ) + m_Parent->DrawPanel->CursorOff( m_DC ); - if ( Text ) - { - if ( event.GetId() == ID_MODULE_EDIT_DELETE_TEXT ) - { - if ( TextType < 2 ) // Ref or Value cannot be deleted - { - DisplayError(this, _("Reference or Value cannot be deleted") ); - goto out; - } - wxString Line; - Line.Printf( _("Delete [%s]"), Text->m_Text.GetData() ); - if ( !IsOK(this, Line ) ) goto out; - m_Parent->DeleteTextModule(Text, m_DC); - ReCreateFieldListBox(); - m_TextListBox->SetSelection(0); - } - else // Edition du champ - { - m_Parent->InstallTextModOptionsFrame(Text, m_DC, wxPoint(-1,-1) ); - ReCreateFieldListBox(); - m_TextListBox->SetSelection(TextType); - } - } - - else DisplayError(this, - wxT("WinEDA_ModulePropertiesFrame::EditOrDelTextModule() error: Field not found")); - out: - if ( m_DC ) m_Parent->DrawPanel->CursorOn(m_DC); - SetTextListButtons(); + // Get a pointer on the field + if( TextType == 0 ) + Text = m_CurrentModule->m_Reference; + else if( TextType == 1 ) + Text = m_CurrentModule->m_Value; + else // Search the field 2 or more, because field 0 and 1 are ref and value + { + EDA_BaseStruct* item = m_CurrentModule->m_Drawings; + int jj = 2; + while( item ) + { + if( item->m_StructType == TYPETEXTEMODULE ) + { + if( jj == TextType ) // Texte trouv� + { + Text = (TEXTE_MODULE*) item; + break; + } + } + item = item->Pnext; jj++; + } + } + + if( Text ) + { + if( event.GetId() == ID_MODULE_EDIT_DELETE_TEXT ) + { + if( TextType < 2 ) // Ref or Value cannot be deleted + { + DisplayError( this, _( "Reference or Value cannot be deleted" ) ); + goto out; + } + wxString Line; + Line.Printf( _( "Delete [%s]" ), Text->m_Text.GetData() ); + if( !IsOK( this, Line ) ) + goto out; + m_Parent->DeleteTextModule( Text, m_DC ); + ReCreateFieldListBox(); + m_TextListBox->SetSelection( 0 ); + } + else // Edition du champ + { + m_Parent->InstallTextModOptionsFrame( Text, m_DC, wxPoint( -1, -1 ) ); + ReCreateFieldListBox(); + m_TextListBox->SetSelection( TextType ); + } + } + else + DisplayError( this, + wxT( + "WinEDA_ModulePropertiesFrame::EditOrDelTextModule() error: Field not found" ) + ); + +out: + if( m_DC ) + m_Parent->DrawPanel->CursorOn( m_DC ); + SetTextListButtons(); } diff --git a/pcbnew/edgemod.cpp b/pcbnew/edgemod.cpp index bf115370c5..a0add3f0d7 100644 --- a/pcbnew/edgemod.cpp +++ b/pcbnew/edgemod.cpp @@ -1,16 +1,16 @@ - /******************************************************/ - /* Edition des contours d'un module: Routines */ - /* d'effacement et d'edition de segments et contours */ - /* appartenant aux modules */ - /******************************************************/ +/******************************************************/ +/* Edition des contours d'un module: Routines */ +/* d'effacement et d'edition de segments et contours */ +/* appartenant aux modules */ +/******************************************************/ - /* fichier edgemod.cpp */ +/* fichier edgemod.cpp */ /* Routines d'edition des contours d'un module. - La correction des Arcs de cercle n'est pas traitee ( mais - les menus en routines sont prevus -*/ + * La correction des Arcs de cercle n'est pas traitee ( mais + * les menus en routines sont prevus + */ #include "fctsys.h" #include "gr_basic.h" @@ -24,377 +24,397 @@ /* Routines Locales */ -static void ShowEdgeModule(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); -static void Exit_EditEdge_Module(WinEDA_DrawPanel * Panel, wxDC * DC); -static void Move_Segment(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); +static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC ); +static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); /* Variables locales : */ -int ArcValue = 900; -static wxPoint MoveVector; // Move vector for move edge -static wxPoint CursorInitialPosition; // Mouse cursor inital position for move command +int ArcValue = 900; +static wxPoint MoveVector; // Move vector for move edge +static wxPoint CursorInitialPosition; // Mouse cursor inital position for move command /****************************************************************************/ -void WinEDA_ModuleEditFrame::Start_Move_EdgeMod(EDGE_MODULE * Edge, wxDC * DC) +void WinEDA_ModuleEditFrame::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC ) /****************************************************************************/ - /* Routine de preparation du deplacement d'un element graphique type DRAWSEGMENT -*/ + +/* Routine de preparation du deplacement d'un element graphique type DRAWSEGMENT + */ { - if( Edge == NULL ) return; - Edge->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); - Edge->m_Flags |= IS_MOVED; - MoveVector.x = MoveVector.y = 0; - CursorInitialPosition = GetScreen()->m_Curseur; - DrawPanel->ManageCurseur = Move_Segment; - DrawPanel->ForceCloseManageCurseur = Exit_EditEdge_Module; - GetScreen()->m_CurrentItem = Edge; - DrawPanel->ManageCurseur( DrawPanel, DC, FALSE); + if( Edge == NULL ) + return; + Edge->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + Edge->m_Flags |= IS_MOVED; + MoveVector.x = MoveVector.y = 0; + CursorInitialPosition = GetScreen()->m_Curseur; + DrawPanel->ManageCurseur = Move_Segment; + DrawPanel->ForceCloseManageCurseur = Exit_EditEdge_Module; + GetScreen()->SetCurItem( Edge ); + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); } + /*********************************************************************/ -void WinEDA_ModuleEditFrame::Place_EdgeMod(EDGE_MODULE * Edge, wxDC * DC) +void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC ) /*********************************************************************/ + /* - Routine de placement de l'element graphique type EDGE_MODULE en cours de deplacement -*/ + * Routine de placement de l'element graphique type EDGE_MODULE en cours de deplacement + */ { - if( Edge == NULL ) return; - Edge->m_Start.x -= MoveVector.x; - Edge->m_Start.y -= MoveVector.y; - Edge->m_End.x -= MoveVector.x; - Edge->m_End.y -= MoveVector.y; + if( Edge == NULL ) + return; + Edge->m_Start.x -= MoveVector.x; + Edge->m_Start.y -= MoveVector.y; + Edge->m_End.x -= MoveVector.x; + Edge->m_End.y -= MoveVector.y; - Edge->m_Start0.x -= MoveVector.x; - Edge->m_Start0.y -= MoveVector.y; - Edge->m_End0.x -= MoveVector.x; - Edge->m_End0.y -= MoveVector.y; + Edge->m_Start0.x -= MoveVector.x; + Edge->m_Start0.y -= MoveVector.y; + Edge->m_End0.x -= MoveVector.x; + Edge->m_End0.y -= MoveVector.y; - Edge->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR); - Edge->m_Flags = 0; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->m_CurrentItem = NULL; - GetScreen()->SetModify(); -MODULE * Module = (MODULE*) Edge->m_Parent; - Module->Set_Rectangle_Encadrement(); + Edge->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + Edge->m_Flags = 0; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->SetCurItem( NULL ); + GetScreen()->SetModify(); + MODULE* Module = (MODULE*) Edge->m_Parent; + Module->Set_Rectangle_Encadrement(); } /************************************************************************/ -static void Move_Segment(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /************************************************************************/ /* redessin du contour du Segment Edge lors des deplacements de la souris */ { -BASE_SCREEN * screen = panel->GetScreen(); -EDGE_MODULE * Edge = (EDGE_MODULE * ) screen->m_CurrentItem; + BASE_SCREEN* screen = panel->GetScreen(); + EDGE_MODULE* Edge = (EDGE_MODULE*) screen->GetCurItem(); - if( Edge == NULL ) return; + if( Edge == NULL ) + return; -MODULE * Module = (MODULE*) Edge->m_Parent; + MODULE* Module = (MODULE*) Edge->m_Parent; - if( erase ) - { - Edge->Draw(panel, DC, MoveVector, GR_XOR); - } + if( erase ) + { + Edge->Draw( panel, DC, MoveVector, GR_XOR ); + } - MoveVector.x = -(screen->m_Curseur.x - CursorInitialPosition.x); - MoveVector.y = -(screen->m_Curseur.y - CursorInitialPosition.y); + MoveVector.x = -(screen->m_Curseur.x - CursorInitialPosition.x); + MoveVector.y = -(screen->m_Curseur.y - CursorInitialPosition.y); - Edge->Draw(panel, DC, MoveVector, GR_XOR); + Edge->Draw( panel, DC, MoveVector, GR_XOR ); - Module->Set_Rectangle_Encadrement(); + Module->Set_Rectangle_Encadrement(); } /************************************************************************/ -static void ShowEdgeModule(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /************************************************************************/ + /* Affiche le segment Edge Module en cours de trace -*/ + */ { -BASE_SCREEN * screen = panel->GetScreen(); -EDGE_MODULE * Edge = (EDGE_MODULE * ) screen->m_CurrentItem; + BASE_SCREEN* screen = panel->GetScreen(); + EDGE_MODULE* Edge = (EDGE_MODULE*) screen->GetCurItem(); - if( Edge == NULL ) return; + if( Edge == NULL ) + return; -MODULE * Module = (MODULE*) Edge->m_Parent; + MODULE* Module = (MODULE*) Edge->m_Parent; - // if( erase ) - { - Edge->Draw(panel, DC, wxPoint(0, 0), GR_XOR); - } + // if( erase ) + { + Edge->Draw( panel, DC, wxPoint( 0, 0 ), GR_XOR ); + } - Edge->m_End = screen->m_Curseur; + Edge->m_End = screen->m_Curseur; - /* Mise a jour des coord relatives */ - Edge->m_End0.x = Edge->m_End.x - Module->m_Pos.x; - Edge->m_End0.y = Edge->m_End.y - Module->m_Pos.y ; - RotatePoint((int*)&Edge->m_End0.x, - (int*)&Edge->m_End0.y, - Module->m_Orient); + /* Mise a jour des coord relatives */ + Edge->m_End0.x = Edge->m_End.x - Module->m_Pos.x; + Edge->m_End0.y = Edge->m_End.y - Module->m_Pos.y; + RotatePoint( (int*) &Edge->m_End0.x, + (int*) &Edge->m_End0.y, -Module->m_Orient ); - Edge->Draw(panel, DC, wxPoint(0, 0), GR_XOR); + Edge->Draw( panel, DC, wxPoint( 0, 0 ), GR_XOR ); - Module->Set_Rectangle_Encadrement(); + Module->Set_Rectangle_Encadrement(); } /***************************************************************************/ -void WinEDA_ModuleEditFrame::Edit_Edge_Width(EDGE_MODULE * Edge, wxDC * DC) +void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* Edge, wxDC* DC ) /***************************************************************************/ + /* change la largeur du EDGE_MODULE Edge, ou de tous si Edge == NULL -*/ + */ { -MODULE* Module = m_Pcb->m_Modules; + MODULE* Module = m_Pcb->m_Modules; - SaveCopyInUndoList(Module); + SaveCopyInUndoList( Module ); - if ( Edge == NULL ) - { - Edge = (EDGE_MODULE *) Module->m_Drawings; - for( ; Edge != NULL ; Edge = (EDGE_MODULE*)Edge->Pnext) - { - if(Edge->m_StructType != TYPEEDGEMODULE) continue; - Edge->m_Width = ModuleSegmentWidth; - } - } - else Edge->m_Width = ModuleSegmentWidth; + if( Edge == NULL ) + { + Edge = (EDGE_MODULE*) Module->m_Drawings; + for( ; Edge != NULL; Edge = (EDGE_MODULE*) Edge->Pnext ) + { + if( Edge->m_StructType != TYPEEDGEMODULE ) + continue; + Edge->m_Width = ModuleSegmentWidth; + } + } + else + Edge->m_Width = ModuleSegmentWidth; - GetScreen()->SetModify(); - DrawPanel->Refresh(TRUE); - Module->Set_Rectangle_Encadrement(); - Module->m_LastEdit_Time = time(NULL); + GetScreen()->SetModify(); + DrawPanel->Refresh( TRUE ); + Module->Set_Rectangle_Encadrement(); + Module->m_LastEdit_Time = time( NULL ); } + /***************************************************************************/ -void WinEDA_ModuleEditFrame::Edit_Edge_Layer(EDGE_MODULE * Edge, wxDC * DC) +void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge, wxDC* DC ) /***************************************************************************/ + /* change la couche du EDGE_MODULE Edge, ou de tous si Edge == NULL -*/ + */ { -MODULE* Module = m_Pcb->m_Modules; -int new_layer = SILKSCREEN_N_CMP; - + MODULE* Module = m_Pcb->m_Modules; + int new_layer = SILKSCREEN_N_CMP; - new_layer = SelectLayer(SILKSCREEN_N_CMP, LAYER_CUIVRE_N, LAST_NO_COPPER_LAYER); - if ( new_layer < 0 ) return; - - SaveCopyInUndoList(Module); - if ( Edge == NULL ) - { - Edge = (EDGE_MODULE *) Module->m_Drawings; - for( ; Edge != NULL ; Edge = (EDGE_MODULE*)Edge->Pnext) - { - if(Edge->m_StructType != TYPEEDGEMODULE) continue; - Edge->m_Layer = new_layer; - } - } - else Edge->m_Layer = new_layer; + new_layer = SelectLayer( SILKSCREEN_N_CMP, LAYER_CUIVRE_N, LAST_NO_COPPER_LAYER ); + if( new_layer < 0 ) + return; - GetScreen()->SetModify(); - Module->Set_Rectangle_Encadrement(); - Module->m_LastEdit_Time = time(NULL); - DrawPanel->Refresh(TRUE); + SaveCopyInUndoList( Module ); + + if( Edge == NULL ) + { + Edge = (EDGE_MODULE*) Module->m_Drawings; + for( ; Edge != NULL; Edge = (EDGE_MODULE*) Edge->Pnext ) + { + if( Edge->m_StructType != TYPEEDGEMODULE ) + continue; + Edge->m_Layer = new_layer; + } + } + else + Edge->m_Layer = new_layer; + + GetScreen()->SetModify(); + Module->Set_Rectangle_Encadrement(); + Module->m_LastEdit_Time = time( NULL ); + DrawPanel->Refresh( TRUE ); } /*************************************************************************/ -void WinEDA_ModuleEditFrame::Enter_Edge_Width(EDGE_MODULE * Edge, wxDC * DC) +void WinEDA_ModuleEditFrame::Enter_Edge_Width( EDGE_MODULE* Edge, wxDC* DC ) /*************************************************************************/ + /* - Entre la nouvelle valeur pour ModuleSegmentWidth. - change la largeur du EDGE_MODULE Edge si Edge != NULL -*/ + * Entre la nouvelle valeur pour ModuleSegmentWidth. + * change la largeur du EDGE_MODULE Edge si Edge != NULL + */ { -wxString buffer; -long ll; - - buffer << ModuleSegmentWidth; - if ( Get_Message( _("New Width (1/10000\"):"),buffer, this) ) return; + wxString buffer; + long ll; - if ( buffer.ToLong(&ll) ) ModuleSegmentWidth = ll; - else - { - DisplayError(this,_("Incorrect number, no change")); - return; - } - if ( Edge ) - { - MODULE* Module = m_Pcb->m_Modules; - Module->DrawEdgesOnly(DrawPanel, DC,wxPoint(0, 0), GR_XOR); - Edge->m_Width = ModuleSegmentWidth; - Module->DrawEdgesOnly(DrawPanel, DC,wxPoint(0, 0),GR_XOR); - Module->Set_Rectangle_Encadrement(); - GetScreen()->SetModify(); - } + buffer << ModuleSegmentWidth; + if( Get_Message( _( "New Width (1/10000\"):" ), buffer, this ) ) + return; -} - -/****************************************************************************/ -void WinEDA_ModuleEditFrame::Delete_Edge_Module(EDGE_MODULE * Edge, wxDC * DC) -/****************************************************************************/ -{ - if(Edge == NULL ) return; - if ( Edge->m_StructType != TYPEEDGEMODULE ) - { - DisplayError(this, wxT("StructType error: TYPEEDGEMODULE expected")); - return; - } - -MODULE* Module = (MODULE*) Edge->m_Parent; - Edge->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR) ; - - /* suppression d'un segment */ - DeleteStructure(Edge); - Module->m_LastEdit_Time = time(NULL); - Module->Set_Rectangle_Encadrement(); - GetScreen()->SetModify(); + if( buffer.ToLong( &ll ) ) + ModuleSegmentWidth = ll; + else + { + DisplayError( this, _( "Incorrect number, no change" ) ); + return; + } + if( Edge ) + { + MODULE* Module = m_Pcb->m_Modules; + Module->DrawEdgesOnly( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + Edge->m_Width = ModuleSegmentWidth; + Module->DrawEdgesOnly( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + Module->Set_Rectangle_Encadrement(); + GetScreen()->SetModify(); + } } +/****************************************************************************/ +void WinEDA_ModuleEditFrame::Delete_Edge_Module( EDGE_MODULE* Edge, wxDC* DC ) +/****************************************************************************/ +{ + if( Edge == NULL ) + return; + if( Edge->m_StructType != TYPEEDGEMODULE ) + { + DisplayError( this, wxT( "StructType error: TYPEEDGEMODULE expected" ) ); + return; + } + + MODULE* Module = (MODULE*) Edge->m_Parent; + Edge->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + + /* suppression d'un segment */ + DeleteStructure( Edge ); + Module->m_LastEdit_Time = time( NULL ); + Module->Set_Rectangle_Encadrement(); + GetScreen()->SetModify(); +} + /******************************************************************/ -static void Exit_EditEdge_Module(WinEDA_DrawPanel * Panel, wxDC * DC) +static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC ) /******************************************************************/ { -EDGE_MODULE * Edge = (EDGE_MODULE * ) Panel->GetScreen()->m_CurrentItem; + EDGE_MODULE* Edge = (EDGE_MODULE*) Panel->GetScreen()->GetCurItem(); - if( Edge && (Edge->m_StructType == TYPEEDGEMODULE) ) /* error si non */ - { - if (Edge->m_Flags & IS_NEW) /* effacement du nouveau contour */ - { - MODULE * Module = (MODULE *) Edge->m_Parent; - Edge->Draw(Panel, DC, MoveVector, GR_XOR); - DeleteStructure(Edge); - Module->Set_Rectangle_Encadrement(); - } - - else - { - Edge->Draw(Panel, DC, MoveVector, GR_XOR); - Edge->m_Flags = 0; - Edge->Draw(Panel, DC, wxPoint(0, 0), GR_OR); - } - } - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; - Panel->GetScreen()->m_CurrentItem = NULL; + if( Edge && (Edge->m_StructType == TYPEEDGEMODULE) ) /* error si non */ + { + if( Edge->m_Flags & IS_NEW ) /* effacement du nouveau contour */ + { + MODULE* Module = (MODULE*) Edge->m_Parent; + Edge->Draw( Panel, DC, MoveVector, GR_XOR ); + DeleteStructure( Edge ); + Module->Set_Rectangle_Encadrement(); + } + else + { + Edge->Draw( Panel, DC, MoveVector, GR_XOR ); + Edge->m_Flags = 0; + Edge->Draw( Panel, DC, wxPoint( 0, 0 ), GR_OR ); + } + } + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + Panel->GetScreen()->SetCurItem( NULL ); } /*************************************************************************/ -EDGE_MODULE * WinEDA_ModuleEditFrame::Begin_Edge_Module(EDGE_MODULE * Edge, - wxDC * DC, int type_edge) +EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, + wxDC* DC, int type_edge ) /*************************************************************************/ /* Fonction de debut de trace d'un nouveau contour. - - Cree la place en memoire du nouveau contour - - Prepare les coord des differents points - - Met a jour la variable type_edge (= S_SEGMENT,S_ARC ...) -*/ + * - Cree la place en memoire du nouveau contour + * - Prepare les coord des differents points + * - Met a jour la variable type_edge (= S_SEGMENT,S_ARC ...) + */ { -MODULE* Module = m_Pcb->m_Modules; -int angle = 0; + MODULE* Module = m_Pcb->m_Modules; + int angle = 0; - if ( Module == NULL ) return NULL; + if( Module == NULL ) + return NULL; - if(Edge == NULL ) /* debut reel du trace */ - { - SaveCopyInUndoList(Module); - Edge = new EDGE_MODULE( Module ); - MoveVector.x = MoveVector.y = 0; + if( Edge == NULL ) /* debut reel du trace */ + { + SaveCopyInUndoList( Module ); + Edge = new EDGE_MODULE( Module ); + MoveVector.x = MoveVector.y = 0; - /* Chainage du nouvel element, en tete de liste Drawings */ - Edge->Pback = Module; - Edge->Pnext = Module->m_Drawings; - if( Module->m_Drawings ) Module->m_Drawings->Pback = Edge; - Module->m_Drawings = Edge; + /* Chainage du nouvel element, en tete de liste Drawings */ + Edge->Pback = Module; + Edge->Pnext = Module->m_Drawings; + if( Module->m_Drawings ) + Module->m_Drawings->Pback = Edge; + Module->m_Drawings = Edge; - /* Mise a jour des caracteristiques du segment ou de l'arc */ - Edge->m_Flags = IS_NEW; - Edge->m_Angle = angle; - Edge->m_Shape = type_edge; - if ( Edge->m_Shape == S_ARC ) Edge->m_Angle = ArcValue; - Edge->m_Width = ModuleSegmentWidth; - Edge->m_Layer = Module->m_Layer; - if(Module->m_Layer == CMP_N) Edge->m_Layer = SILKSCREEN_N_CMP; - if(Module->m_Layer == CUIVRE_N) Edge->m_Layer = SILKSCREEN_N_CU; - /* Mise a jour du point de depart du segment ou de l'arc */ - Edge->m_Start = GetScreen()->m_Curseur; - /* Mise a jour de la fin du segment , rectangle ou de l'arc*/ - Edge->m_End = Edge->m_Start; + /* Mise a jour des caracteristiques du segment ou de l'arc */ + Edge->m_Flags = IS_NEW; + Edge->m_Angle = angle; + Edge->m_Shape = type_edge; + if( Edge->m_Shape == S_ARC ) + Edge->m_Angle = ArcValue; + Edge->m_Width = ModuleSegmentWidth; + Edge->m_Layer = Module->m_Layer; + if( Module->m_Layer == CMP_N ) + Edge->m_Layer = SILKSCREEN_N_CMP; + if( Module->m_Layer == CUIVRE_N ) + Edge->m_Layer = SILKSCREEN_N_CU; + /* Mise a jour du point de depart du segment ou de l'arc */ + Edge->m_Start = GetScreen()->m_Curseur; + /* Mise a jour de la fin du segment , rectangle ou de l'arc*/ + Edge->m_End = Edge->m_Start; - /* Mise a jour des coord relatives */ - Edge->m_Start0.x = Edge->m_Start.x - Module->m_Pos.x; - Edge->m_Start0.y = Edge->m_Start.y - Module->m_Pos.y; - RotatePoint((int*)&(Edge->m_Start0.x), - (int*)&(Edge->m_Start0.y), - Module->m_Orient); - Edge->m_End0 = Edge->m_Start0; - Module->Set_Rectangle_Encadrement(); + /* Mise a jour des coord relatives */ + Edge->m_Start0.x = Edge->m_Start.x - Module->m_Pos.x; + Edge->m_Start0.y = Edge->m_Start.y - Module->m_Pos.y; + RotatePoint( (int*) &(Edge->m_Start0.x), + (int*) &(Edge->m_Start0.y), -Module->m_Orient ); + Edge->m_End0 = Edge->m_Start0; + Module->Set_Rectangle_Encadrement(); - DrawPanel->ManageCurseur = ShowEdgeModule; - DrawPanel->ForceCloseManageCurseur = Exit_EditEdge_Module; - } + DrawPanel->ManageCurseur = ShowEdgeModule; + DrawPanel->ForceCloseManageCurseur = Exit_EditEdge_Module; + } + else /* trace en cours : les coord du point d'arrivee ont ete mises + * a jour par la routine Montre_Position_New_Edge_Module*/ + { + if( type_edge == S_SEGMENT ) + { + if( (Edge->m_Start0.x) != (Edge->m_End0.x) + || (Edge->m_Start0.y) != (Edge->m_End0.y) ) + { + Edge->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + EDGE_MODULE* newedge = new EDGE_MODULE( Module ); + newedge->Copy( Edge ); + newedge->AddToChain( Edge ); + Edge->m_Flags = 0; + Edge = newedge; - else /* trace en cours : les coord du point d'arrivee ont ete mises - a jour par la routine Montre_Position_New_Edge_Module*/ - { - if( type_edge == S_SEGMENT ) - { - if( (Edge->m_Start0.x) != (Edge->m_End0.x) || - (Edge->m_Start0.y) != (Edge->m_End0.y) ) - { - Edge->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR); - EDGE_MODULE * newedge = new EDGE_MODULE(Module); - newedge->Copy(Edge); - newedge->AddToChain(Edge); - Edge->m_Flags = 0; - Edge = newedge; + Edge->m_Flags = IS_NEW; + Edge->m_Width = ModuleSegmentWidth; + Edge->m_Start = GetScreen()->m_Curseur; + Edge->m_End = Edge->m_Start; - Edge->m_Flags = IS_NEW; - Edge->m_Width = ModuleSegmentWidth; - Edge->m_Start = GetScreen()->m_Curseur; - Edge->m_End = Edge->m_Start; + /* Mise a jour des coord relatives */ + Edge->m_Start0.x = Edge->m_Start.x - Module->m_Pos.x; + Edge->m_Start0.y = Edge->m_Start.y - Module->m_Pos.y; + RotatePoint( (int*) &(Edge->m_Start0.x), + (int*) &(Edge->m_Start0.y), -Module->m_Orient ); + Edge->m_End0 = Edge->m_Start0; - /* Mise a jour des coord relatives */ - Edge->m_Start0.x = Edge->m_Start.x - Module->m_Pos.x; - Edge->m_Start0.y = Edge->m_Start.y - Module->m_Pos.y; - RotatePoint((int*)&(Edge->m_Start0.x), - (int*)&(Edge->m_Start0.y), -Module->m_Orient); - Edge->m_End0 = Edge->m_Start0; - - Module->Set_Rectangle_Encadrement(); - Module->m_LastEdit_Time = time(NULL); - GetScreen()->SetModify(); - } - } - else - DisplayError(this, wxT("Begin_Edge() error")); - } - return Edge; + Module->Set_Rectangle_Encadrement(); + Module->m_LastEdit_Time = time( NULL ); + GetScreen()->SetModify(); + } + } + else + DisplayError( this, wxT( "Begin_Edge() error" ) ); + } + return Edge; } /*************************************************************************/ -void WinEDA_ModuleEditFrame::End_Edge_Module(EDGE_MODULE * Edge,wxDC * DC) +void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC ) /*************************************************************************/ { -MODULE* Module = m_Pcb->m_Modules; + MODULE* Module = m_Pcb->m_Modules; - /* test du dernier segment: si null: suppression */ - if(Edge) - { - if( (Edge->m_Start.x == Edge->m_End.x) - && (Edge->m_Start.y == Edge->m_End.y) ) - { - DeleteStructure( Edge); - } - } - Edge->m_Flags = 0; - Module->Set_Rectangle_Encadrement(); - Module->m_LastEdit_Time = time(NULL); - GetScreen()->SetModify(); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + /* test du dernier segment: si null: suppression */ + if( Edge ) + { + if( (Edge->m_Start.x == Edge->m_End.x) + && (Edge->m_Start.y == Edge->m_End.y) ) + { + DeleteStructure( Edge ); + } + } + Edge->m_Flags = 0; + Module->Set_Rectangle_Encadrement(); + Module->m_LastEdit_Time = time( NULL ); + GetScreen()->SetModify(); + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; } - - diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 57975a84a5..b141a67511 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -15,7 +15,7 @@ #include "eda_dde.h" -#define CURRENT_ITEM (GetScreen()->m_CurrentItem) +#define CURRENT_ITEM (GetScreen()->GetCurItem()) static void Process_Move_Item( WinEDA_PcbFrame* frame, @@ -43,7 +43,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) { case TYPETRACK: case TYPEVIA: - if( CURRENT_ITEM->m_Flags & IS_DRAGGED ) + if( DrawStruct->m_Flags & IS_DRAGGED ) { PlaceDraggedTrackSegment( (TRACK*) DrawStruct, DC ); goto out; @@ -139,7 +139,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) case ID_PCB_MIRE_BUTT: if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { - GetScreen()->m_CurrentItem = Create_Mire( DC ); + GetScreen()->SetCurItem( Create_Mire( DC ) ); DrawPanel->MouseToCursorSchema(); } else if( DrawStruct->m_StructType == TYPEMIRE ) @@ -167,17 +167,16 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) } if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { - GetScreen()->m_CurrentItem = DrawStruct = - Begin_DrawSegment( NULL, shape, DC ); + DrawStruct = Begin_DrawSegment( NULL, shape, DC ); + GetScreen()->SetCurItem( DrawStruct ); DrawPanel->m_AutoPAN_Request = TRUE; } else if( DrawStruct && (DrawStruct->m_StructType == TYPEDRAWSEGMENT) && (DrawStruct->m_Flags & IS_NEW) ) { - GetScreen()->m_CurrentItem = DrawStruct = - Begin_DrawSegment( (DRAWSEGMENT*) DrawStruct, shape, - DC ); + DrawStruct = Begin_DrawSegment( (DRAWSEGMENT*) DrawStruct, shape, DC ); + GetScreen()->SetCurItem( DrawStruct ); DrawPanel->m_AutoPAN_Request = TRUE; } break; @@ -192,8 +191,8 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { - GetScreen()->m_CurrentItem = DrawStruct = - Begin_Route( NULL, DC ); + DrawStruct = Begin_Route( NULL, DC ); + GetScreen()->SetCurItem( DrawStruct ); if( DrawStruct ) DrawPanel->m_AutoPAN_Request = TRUE; } @@ -204,7 +203,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) { TRACK* track = Begin_Route( (TRACK*) DrawStruct, DC ); if( track ) // c'est a dire si OK - GetScreen()->m_CurrentItem = DrawStruct = track; + GetScreen()->SetCurItem( DrawStruct = track ); DrawPanel->m_AutoPAN_Request = TRUE; } break; @@ -213,15 +212,13 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) case ID_PCB_ZONES_BUTT: if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { - GetScreen()->m_CurrentItem = DrawStruct = - Begin_Zone(); + GetScreen()->SetCurItem( DrawStruct = Begin_Zone() ); } else if( DrawStruct && (DrawStruct->m_StructType == TYPEEDGEZONE) && (DrawStruct->m_Flags & IS_NEW) ) { - GetScreen()->m_CurrentItem = DrawStruct = - Begin_Zone(); + GetScreen()->SetCurItem( DrawStruct = Begin_Zone() ); } else DisplayError( this, wxT( "Edit: zone internal error" ) ); @@ -230,7 +227,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) case ID_TEXT_COMMENT_BUTT: if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { - GetScreen()->m_CurrentItem = Create_Texte_Pcb( DC ); + GetScreen()->SetCurItem( Create_Texte_Pcb( DC ) ); DrawPanel->MouseToCursorSchema(); DrawPanel->m_AutoPAN_Request = TRUE; } @@ -247,8 +244,8 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { DrawPanel->MouseToCursorSchema(); - GetScreen()->m_CurrentItem = DrawStruct = - Load_Module_From_Library( wxEmptyString, DC ); + DrawStruct = Load_Module_From_Library( wxEmptyString, DC ); + GetScreen()->SetCurItem( DrawStruct ); if( DrawStruct ) StartMove_Module( (MODULE*) DrawStruct, DC ); } @@ -269,16 +266,16 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) } if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { - GetScreen()->m_CurrentItem = DrawStruct = - Begin_Cotation( NULL, DC ); + DrawStruct = Begin_Cotation( NULL, DC ); + GetScreen()->SetCurItem( DrawStruct ); DrawPanel->m_AutoPAN_Request = TRUE; } else if( DrawStruct && (DrawStruct->m_StructType == TYPECOTATION) && (DrawStruct->m_Flags & IS_NEW) ) { - GetScreen()->m_CurrentItem = DrawStruct = - Begin_Cotation( (COTATION*) DrawStruct, DC ); + DrawStruct = Begin_Cotation( (COTATION*) DrawStruct, DC ); + GetScreen()->SetCurItem( DrawStruct ); DrawPanel->m_AutoPAN_Request = TRUE; } else @@ -292,7 +289,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) if( DrawStruct && (DrawStruct->m_Flags == 0) ) { RemoveStruct( DrawStruct, DC ); - GetScreen()->m_CurrentItem = DrawStruct = NULL; + GetScreen()->SetCurItem( DrawStruct = NULL ); } } break; @@ -557,7 +554,6 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_GET_TOOLS: - // InstalloolsFrame(this, wxPoint(-1,-1) ); break; @@ -707,7 +703,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) if( CURRENT_ITEM == NULL ) break; DrawPanel->MouseToCursorSchema(); - GetScreen()->m_CurrentItem = Delete_Segment( &dc, (TRACK*) CURRENT_ITEM ); + GetScreen()->SetCurItem( Delete_Segment( &dc, (TRACK*) CURRENT_ITEM ) ); GetScreen()->SetModify(); break; @@ -716,14 +712,14 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; DrawPanel->MouseToCursorSchema(); Delete_Track( &dc, (TRACK*) CURRENT_ITEM ); - GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetCurItem( NULL ); GetScreen()->SetModify(); break; case ID_POPUP_PCB_DELETE_TRACKNET: DrawPanel->MouseToCursorSchema(); Delete_net( &dc, (TRACK*) CURRENT_ITEM ); - GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetCurItem( NULL ); GetScreen()->SetModify(); break; @@ -759,7 +755,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) if( CURRENT_ITEM == NULL ) break; Delete_Zone( &dc, (SEGZONE*) CURRENT_ITEM ); - GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetCurItem( NULL ); break; case ID_POPUP_PCB_EDIT_ZONE: @@ -790,7 +786,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) // If the current Item is a pad, text module ...: Get the parent if( CURRENT_ITEM->m_StructType != TYPEMODULE ) - CURRENT_ITEM = (MODULE*) CURRENT_ITEM->m_Parent; + GetScreen()->SetCurItem( CURRENT_ITEM->m_Parent ); if( !CURRENT_ITEM || CURRENT_ITEM->m_StructType != TYPEMODULE ) { g_Drag_Pistes_On = FALSE; @@ -801,7 +797,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: /* get module by name and move it */ - CURRENT_ITEM = GetModuleByName(); + GetScreen()->SetCurItem( GetModuleByName() ); if( CURRENT_ITEM ) { DrawPanel->MouseToCursorSchema(); @@ -814,12 +810,13 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) // If the current Item is a pad, text module ...: Get the parent if( CURRENT_ITEM->m_StructType != TYPEMODULE ) - CURRENT_ITEM = (MODULE*) CURRENT_ITEM->m_Parent; + GetScreen()->SetCurItem( CURRENT_ITEM->m_Parent ); + if( !CURRENT_ITEM || CURRENT_ITEM->m_StructType != TYPEMODULE ) break; if( Delete_Module( (MODULE*) CURRENT_ITEM, &dc ) ) { - GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetCurItem( NULL ); } break; @@ -828,7 +825,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) // If the current Item is a pad, text module ...: Get the parent if( CURRENT_ITEM->m_StructType != TYPEMODULE ) - CURRENT_ITEM = (MODULE*) CURRENT_ITEM->m_Parent; + GetScreen()->SetCurItem( CURRENT_ITEM->m_Parent ); + if( !CURRENT_ITEM || CURRENT_ITEM->m_StructType != TYPEMODULE ) break; Rotate_Module( &dc, (MODULE*) CURRENT_ITEM, -900, TRUE ); @@ -839,7 +837,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) // If the current Item is a pad, text module ...: Get the parent if( CURRENT_ITEM->m_StructType != TYPEMODULE ) - CURRENT_ITEM = (MODULE*) CURRENT_ITEM->m_Parent; + GetScreen()->SetCurItem( CURRENT_ITEM->m_Parent ); + if( !CURRENT_ITEM || CURRENT_ITEM->m_StructType != TYPEMODULE ) break; Rotate_Module( &dc, (MODULE*) CURRENT_ITEM, 900, TRUE ); @@ -850,21 +849,19 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) // If the current Item is a pad, text module ...: Get the parent if( CURRENT_ITEM->m_StructType != TYPEMODULE ) - CURRENT_ITEM = (MODULE*) CURRENT_ITEM->m_Parent; + GetScreen()->SetCurItem( CURRENT_ITEM->m_Parent ); if( !CURRENT_ITEM || CURRENT_ITEM->m_StructType != TYPEMODULE ) break; Change_Side_Module( (MODULE*) CURRENT_ITEM, &dc ); break; case ID_POPUP_PCB_EDIT_MODULE: - // If the current Item is a pad, text module ...: Get the parent if( CURRENT_ITEM->m_StructType != TYPEMODULE ) - CURRENT_ITEM = (MODULE*) CURRENT_ITEM->m_Parent; + GetScreen()->SetCurItem( CURRENT_ITEM->m_Parent ); if( !CURRENT_ITEM || CURRENT_ITEM->m_StructType != TYPEMODULE ) break; - InstallModuleOptionsFrame( (MODULE*) CURRENT_ITEM, - &dc, pos ); + InstallModuleOptionsFrame( (MODULE*) CURRENT_ITEM, &dc, pos ); DrawPanel->MouseToCursorSchema(); break; @@ -877,8 +874,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_EDIT_PAD: - InstallPadOptionsFrame( (D_PAD*) CURRENT_ITEM, - &dc, pos ); + InstallPadOptionsFrame( (D_PAD*) CURRENT_ITEM, &dc, pos ); DrawPanel->MouseToCursorSchema(); break; @@ -899,20 +895,18 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_DELETE_PAD: DeletePad( (D_PAD*) CURRENT_ITEM, &dc ); - GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetCurItem( NULL ); DrawPanel->MouseToCursorSchema(); break; case ID_POPUP_PCB_EDIT_TEXTMODULE: - InstallTextModOptionsFrame( (TEXTE_MODULE*) CURRENT_ITEM, - &dc, pos ); + InstallTextModOptionsFrame( (TEXTE_MODULE*) CURRENT_ITEM, &dc, pos ); DrawPanel->MouseToCursorSchema(); break; case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST: DrawPanel->MouseToCursorSchema(); - StartMoveTexteModule( (TEXTE_MODULE*) CURRENT_ITEM, - &dc ); + StartMoveTexteModule( (TEXTE_MODULE*) CURRENT_ITEM, &dc ); break; case ID_POPUP_PCB_ROTATE_TEXTMODULE: @@ -922,9 +916,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_DELETE_TEXTMODULE: - DeleteTextModule( (TEXTE_MODULE*) CURRENT_ITEM, - &dc ); - GetScreen()->m_CurrentItem = NULL; + DeleteTextModule( (TEXTE_MODULE*) CURRENT_ITEM, &dc ); + GetScreen()->SetCurItem( NULL ); DrawPanel->MouseToCursorSchema(); break; @@ -993,13 +986,13 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_DELETE_MIRE: DrawPanel->MouseToCursorSchema(); Delete_Mire( (MIREPCB*) CURRENT_ITEM, &dc ); - GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetCurItem( NULL ); break; case ID_POPUP_PCB_DELETE_COTATION: DrawPanel->MouseToCursorSchema(); Delete_Cotation( (COTATION*) CURRENT_ITEM, &dc ); - GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetCurItem( NULL ); break; case ID_POPUP_PCB_EDIT_COTATION: @@ -1014,7 +1007,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_DELETE_DRAWING_LAYER: Delete_Drawings_All_Layer( (DRAWSEGMENT*) CURRENT_ITEM, &dc ); - GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetCurItem( NULL ); DrawPanel->MouseToCursorSchema(); break; @@ -1033,7 +1026,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) if( CURRENT_ITEM && (CURRENT_ITEM->m_Flags & IS_NEW) ) { End_Edge( (DRAWSEGMENT*) CURRENT_ITEM, &dc ); - GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetCurItem( NULL ); } break; @@ -1042,7 +1035,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) if( CURRENT_ITEM && (CURRENT_ITEM->m_Flags & IS_NEW) ) { End_Zone( &dc ); - GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetCurItem( NULL ); } break; @@ -1050,8 +1043,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) DrawPanel->MouseToCursorSchema(); if( CURRENT_ITEM && (CURRENT_ITEM->m_Flags & IS_NEW) ) { - GetScreen()->m_CurrentItem = Del_SegmEdgeZone( &dc, - (EDGE_ZONE*) CURRENT_ITEM ); + GetScreen()->SetCurItem( Del_SegmEdgeZone( &dc, + (EDGE_ZONE*) CURRENT_ITEM ) ); } break; @@ -1122,32 +1115,32 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_VIA_HOLE_EXPORT: case ID_POPUP_PCB_VIA_HOLE_RESET_TO_DEFAULT: case ID_POPUP_PCB_VIA_HOLE_EXPORT_TO_OTHERS: - Via_Edit_Control( &dc, id, (SEGVIA*) GetScreen()->m_CurrentItem ); + Via_Edit_Control( &dc, id, (SEGVIA*) GetScreen()->GetCurItem() ); break; case ID_POPUP_PCB_MOVE_TRACK_SEGMENT: DrawPanel->MouseToCursorSchema(); - Start_MoveOneNodeOrSegment( (TRACK*) GetScreen()->m_CurrentItem, + Start_MoveOneNodeOrSegment( (TRACK*) GetScreen()->GetCurItem(), &dc, id ); break; case ID_POPUP_PCB_DRAG_TRACK_SEGMENT: case ID_POPUP_PCB_MOVE_TRACK_NODE: DrawPanel->MouseToCursorSchema(); - Start_MoveOneNodeOrSegment( (TRACK*) GetScreen()->m_CurrentItem, + Start_MoveOneNodeOrSegment( (TRACK*) GetScreen()->GetCurItem(), &dc, id ); break; case ID_POPUP_PCB_DRAG_TRACK_SEGMENT_KEEP_SLOPE: DrawPanel->MouseToCursorSchema(); - Start_DragTrackSegmentAndKeepSlope( (TRACK*) GetScreen()->m_CurrentItem, + Start_DragTrackSegmentAndKeepSlope( (TRACK*) GetScreen()->GetCurItem(), &dc ); break; case ID_POPUP_PCB_BREAK_TRACK: DrawPanel->MouseToCursorSchema(); { - TRACK* track = (TRACK*) GetScreen()->m_CurrentItem; + TRACK* track = (TRACK*) GetScreen()->GetCurItem(); wxPoint pos = GetScreen()->m_Curseur; track->Draw( DrawPanel, &dc, GR_XOR ); TRACK* newtrack = CreateLockPoint( &pos.x, &pos.y, track, NULL ); @@ -1194,11 +1187,9 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; default: - { DisplayError( this, wxT( "WinEDA_PcbFrame::Process_Special_Functions() id error" ) ); break; } - } SetToolbars(); DrawPanel->CursorOn( &dc ); @@ -1262,7 +1253,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) break; // Element localis� - GetScreen()->m_CurrentItem = DrawStruct; + GetScreen()->SetCurItem( DrawStruct ); switch( DrawStruct->m_StructType ) { @@ -1329,7 +1320,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) case ID_PCB_ZONES_BUTT: End_Zone( DC ); DrawPanel->m_AutoPAN_Request = FALSE; - GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetCurItem( NULL ); break; case ID_LINE_COMMENT_BUTT: @@ -1347,7 +1338,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) { End_Edge( (DRAWSEGMENT*) DrawStruct, &dc ); DrawPanel->m_AutoPAN_Request = FALSE; - GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetCurItem( NULL ); } break; } @@ -1434,7 +1425,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer ) { if( preslayer == layer ) return; - EDA_BaseStruct* current = GetScreen()->m_CurrentItem; + EDA_BaseStruct* current = GetScreen()->GetCurItem(); //see if we are drawing a segment; if so, add a via? if( m_ID_current_state == ID_TRACK_BUTT && current != NULL ) @@ -1447,7 +1438,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer ) GetScreen()->m_Route_Layer_TOP = preslayer; GetScreen()->m_Route_Layer_BOTTOM = layer; GetScreen()->m_Active_Layer = preslayer; - Other_Layer_Route( (TRACK*) GetScreen()->m_CurrentItem, DC ); + Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ); } } diff --git a/pcbnew/editedge.cpp b/pcbnew/editedge.cpp index 3be638a403..e0f336da1c 100644 --- a/pcbnew/editedge.cpp +++ b/pcbnew/editedge.cpp @@ -1,8 +1,8 @@ - /******************************************************/ - /* Edition des contours du pcb: Routines */ - /* d'effacement et d'edition de segments et contours */ - /* du type PCB, draw, edgePCB */ - /******************************************************/ +/******************************************************/ +/* Edition des contours du pcb: Routines */ +/* d'effacement et d'edition de segments et contours */ +/* du type PCB, draw, edgePCB */ +/******************************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -13,366 +13,378 @@ #include "protos.h" /* Routines Locales */ -static void Exit_EditEdge(WinEDA_DrawPanel * Panel, wxDC * DC); -static void Montre_Position_NewSegment(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); -static void Move_Segment(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC ); +static void Montre_Position_NewSegment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); +static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); /* Variables locales : */ -static wxPoint cursor_pos; // position originelle du curseur souris (fct deplacement) -static wxPoint cursor_pos0; // position courante du curseur souris +static wxPoint cursor_pos; // position originelle du curseur souris (fct deplacement) +static wxPoint cursor_pos0; // position courante du curseur souris /****************************************************************************/ -void WinEDA_PcbFrame::Start_Move_DrawItem(DRAWSEGMENT * drawitem, wxDC * DC) +void WinEDA_PcbFrame::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ) /****************************************************************************/ - /* Routine de preparation du deplacement d'un element graphique type DRAWSEGMENT -*/ + +/* Routine de preparation du deplacement d'un element graphique type DRAWSEGMENT + */ { - if( drawitem == NULL ) return; - Trace_DrawSegmentPcb(DrawPanel, DC, drawitem,GR_XOR) ; - drawitem->m_Flags |= IS_MOVED; - cursor_pos = cursor_pos0 = GetScreen()->m_Curseur; - Affiche_Infos_DrawSegment(this, drawitem); - DrawPanel->ManageCurseur = Move_Segment; - DrawPanel->ForceCloseManageCurseur = Exit_EditEdge; - GetScreen()->m_CurrentItem = drawitem; - DrawPanel->ManageCurseur( DrawPanel, DC, FALSE); + if( drawitem == NULL ) + return; + Trace_DrawSegmentPcb( DrawPanel, DC, drawitem, GR_XOR ); + drawitem->m_Flags |= IS_MOVED; + cursor_pos = cursor_pos0 = GetScreen()->m_Curseur; + Affiche_Infos_DrawSegment( this, drawitem ); + DrawPanel->ManageCurseur = Move_Segment; + DrawPanel->ForceCloseManageCurseur = Exit_EditEdge; + GetScreen()->SetCurItem( drawitem ); + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); } + /*********************************************************************/ -void WinEDA_PcbFrame::Place_DrawItem(DRAWSEGMENT * drawitem, wxDC * DC) +void WinEDA_PcbFrame::Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ) /*********************************************************************/ + /* - Routine de placement de l'element graphique type DRAWSEGMENT en cours de deplacement -*/ + * Routine de placement de l'element graphique type DRAWSEGMENT en cours de deplacement + */ { - if( drawitem == NULL ) return; + if( drawitem == NULL ) + return; - Trace_DrawSegmentPcb(DrawPanel, DC, drawitem,GR_OR) ; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->m_CurrentItem = NULL; - GetScreen()->SetModify(); - drawitem->m_Flags = 0; + Trace_DrawSegmentPcb( DrawPanel, DC, drawitem, GR_OR ); + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->SetCurItem( NULL ); + GetScreen()->SetModify(); + drawitem->m_Flags = 0; } /************************************************************************/ -static void Move_Segment(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /************************************************************************/ /* redessin du contour du Segment Edge lors des deplacements de la souris */ { -DRAWSEGMENT * Segment = ( DRAWSEGMENT * ) - panel->GetScreen()->m_CurrentItem ; -int t_fill = DisplayOpt.DisplayDrawItems; + DRAWSEGMENT* Segment = (DRAWSEGMENT*) + panel->GetScreen()->GetCurItem(); + int t_fill = DisplayOpt.DisplayDrawItems; - if(Segment == NULL) return ; + if( Segment == NULL ) + return; - DisplayOpt.DisplayDrawItems = SKETCH ; + DisplayOpt.DisplayDrawItems = SKETCH; - /* efface ancienne position */ - if( erase ) - Trace_DrawSegmentPcb(panel, DC, Segment, GR_XOR); + /* efface ancienne position */ + if( erase ) + Trace_DrawSegmentPcb( panel, DC, Segment, GR_XOR ); -wxPoint delta; - delta.x = panel->GetScreen()->m_Curseur.x - cursor_pos.x; - delta.y = panel->GetScreen()->m_Curseur.y - cursor_pos.y; - Segment->m_Start.x += delta.x; - Segment->m_Start.y += delta.y; - Segment->m_End.x += delta.x; - Segment->m_End.y += delta.y; - cursor_pos = panel->GetScreen()->m_Curseur; + wxPoint delta; + delta.x = panel->GetScreen()->m_Curseur.x - cursor_pos.x; + delta.y = panel->GetScreen()->m_Curseur.y - cursor_pos.y; + Segment->m_Start.x += delta.x; + Segment->m_Start.y += delta.y; + Segment->m_End.x += delta.x; + Segment->m_End.y += delta.y; + cursor_pos = panel->GetScreen()->m_Curseur; - Trace_DrawSegmentPcb(panel, DC, Segment,GR_XOR); - DisplayOpt.DisplayDrawItems = t_fill ; + Trace_DrawSegmentPcb( panel, DC, Segment, GR_XOR ); + DisplayOpt.DisplayDrawItems = t_fill; } - /**************************************************************************/ -void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC * DC) +void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) /**************************************************************************/ { -EDA_BaseStruct * PtStruct; -int track_fill_copy = DisplayOpt.DisplayDrawItems; + EDA_BaseStruct* PtStruct; + int track_fill_copy = DisplayOpt.DisplayDrawItems; - if (Segment == NULL ) return; + if( Segment == NULL ) + return; - if(Segment->m_Flags & IS_NEW) // Trace en cours, on peut effacer le dernier segment - { - /* effacement du segment en cours de trace */ - DisplayOpt.DisplayDrawItems = SKETCH ; - Trace_DrawSegmentPcb(DrawPanel, DC, Segment,GR_XOR) ; - PtStruct = Segment->Pback; - DeleteStructure(Segment); - if( PtStruct && (PtStruct->m_StructType == TYPEDRAWSEGMENT ) ) - Segment = (DRAWSEGMENT*) PtStruct; - DisplayOpt.DisplayDrawItems = track_fill_copy ; - GetScreen()->m_CurrentItem = NULL; - } - - else - { - Trace_DrawSegmentPcb(DrawPanel, DC, (DRAWSEGMENT *)Segment,GR_XOR) ; - Segment->m_Flags = 0; - DeleteStructure(Segment); - GetScreen()->m_CurrentItem = NULL; - GetScreen()->SetModify(); - } + if( Segment->m_Flags & IS_NEW ) // Trace en cours, on peut effacer le dernier segment + { + /* effacement du segment en cours de trace */ + DisplayOpt.DisplayDrawItems = SKETCH; + Trace_DrawSegmentPcb( DrawPanel, DC, Segment, GR_XOR ); + PtStruct = Segment->Pback; + DeleteStructure( Segment ); + if( PtStruct && (PtStruct->m_StructType == TYPEDRAWSEGMENT ) ) + Segment = (DRAWSEGMENT*) PtStruct; + DisplayOpt.DisplayDrawItems = track_fill_copy; + GetScreen()->SetCurItem( NULL ); + } + else + { + Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) Segment, GR_XOR ); + Segment->m_Flags = 0; + DeleteStructure( Segment ); + GetScreen()->SetCurItem( NULL ); + GetScreen()->SetModify(); + } } /*************************************************************************/ -void WinEDA_PcbFrame::Drawing_SetNewWidth(DRAWSEGMENT *DrawSegm, wxDC * DC) +void WinEDA_PcbFrame::Drawing_SetNewWidth( DRAWSEGMENT* DrawSegm, wxDC* DC ) /*************************************************************************/ + /* Met a la largeur courante le segment pointe part la souris -*/ + */ { + if( DrawSegm == NULL ) + return; - if( DrawSegm == NULL ) return; + Trace_DrawSegmentPcb( DrawPanel, DC, DrawSegm, GR_XOR ); - Trace_DrawSegmentPcb(DrawPanel, DC, DrawSegm, GR_XOR); + if( DrawSegm->m_Layer == EDGE_N ) + DrawSegm->m_Width = g_DesignSettings.m_EdgeSegmentWidth; + else + DrawSegm->m_Width = g_DesignSettings.m_DrawSegmentWidth; - if(DrawSegm->m_Layer == EDGE_N) DrawSegm->m_Width = g_DesignSettings.m_EdgeSegmentWidth; - else DrawSegm->m_Width = g_DesignSettings.m_DrawSegmentWidth; + Trace_DrawSegmentPcb( DrawPanel, DC, DrawSegm, GR_OR ); - Trace_DrawSegmentPcb(DrawPanel, DC, DrawSegm, GR_OR); + Affiche_Infos_DrawSegment( this, DrawSegm ); - Affiche_Infos_DrawSegment(this, DrawSegm); - - GetScreen()->SetModify(); + GetScreen()->SetModify(); } /******************************************************************************/ -void WinEDA_PcbFrame::Delete_Drawings_All_Layer(DRAWSEGMENT *Segment, wxDC * DC) +void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC ) /******************************************************************************/ { -DRAWSEGMENT * pt_segm; -TEXTE_PCB* pt_txt; -EDA_BaseStruct * PtStruct, *PtNext; -COTATION * Cotation; -int layer = Segment->m_Layer; + DRAWSEGMENT* pt_segm; + TEXTE_PCB* pt_txt; + EDA_BaseStruct* PtStruct, * PtNext; + COTATION* Cotation; + int layer = Segment->m_Layer; - if(layer <= CMP_N) - { - DisplayError(this, _("Copper layer global delete not allowed!"), 20); - return; - } + if( layer <= CMP_N ) + { + DisplayError( this, _( "Copper layer global delete not allowed!" ), 20 ); + return; + } - if ( Segment->m_Flags ) - { - DisplayError(this, _("Segment is being edited"), 10); - return; - } + if( Segment->m_Flags ) + { + DisplayError( this, _( "Segment is being edited" ), 10 ); + return; + } - wxString msg = _("Delete Layer ") + ReturnPcbLayerName(layer); - if( !IsOK(this, msg) ) return ; + wxString msg = _( "Delete Layer " ) + ReturnPcbLayerName( layer ); + if( !IsOK( this, msg ) ) + return; - PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtNext ) - { - GetScreen()->SetModify(); - PtNext = PtStruct->Pnext; - switch( PtStruct->m_StructType) - { - case TYPEDRAWSEGMENT: - pt_segm = (DRAWSEGMENT*) PtStruct; - if(pt_segm->m_Layer == layer) - { - Trace_DrawSegmentPcb(DrawPanel, DC, pt_segm,GR_XOR); - DeleteStructure(PtStruct); - } - break; + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtNext ) + { + GetScreen()->SetModify(); + PtNext = PtStruct->Pnext; - case TYPETEXTE: - pt_txt = (TEXTE_PCB*)PtStruct; - if(pt_txt->m_Layer == layer) - { - pt_txt->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); - DeleteStructure( PtStruct ); - } - break; + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + pt_segm = (DRAWSEGMENT*) PtStruct; + if( pt_segm->m_Layer == layer ) + { + Trace_DrawSegmentPcb( DrawPanel, DC, pt_segm, GR_XOR ); + DeleteStructure( PtStruct ); + } + break; + + case TYPETEXTE: + pt_txt = (TEXTE_PCB*) PtStruct; + if( pt_txt->m_Layer == layer ) + { + pt_txt->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + DeleteStructure( PtStruct ); + } + break; - case TYPECOTATION: - Cotation = (COTATION*)PtStruct; - if(Cotation->m_Layer == layer) - { - Cotation->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); - DeleteStructure(PtStruct); - } - break; + case TYPECOTATION: + Cotation = (COTATION*) PtStruct; + if( Cotation->m_Layer == layer ) + { + Cotation->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + DeleteStructure( PtStruct ); + } + break; - default: DisplayError(this, wxT("Type Drawing Inconnu") ); - break; - } - } + default: + DisplayError( this, wxT( "Type Drawing Inconnu" ) ); + break; + } + } } /*************************************************************/ -static void Exit_EditEdge(WinEDA_DrawPanel * Panel, wxDC * DC) +static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC ) /*************************************************************/ { -DRAWSEGMENT *Segment = (DRAWSEGMENT *) Panel->GetScreen()->m_CurrentItem ; + DRAWSEGMENT* Segment = (DRAWSEGMENT*) Panel->GetScreen()->GetCurItem(); - if (Segment == NULL) return; + if( Segment == NULL ) + return; - if( Segment->m_Flags & IS_NEW ) - { - Panel->ManageCurseur(Panel, DC, FALSE); - DeleteStructure(Segment); - Segment = NULL; - } - - else - { - wxPoint pos = Panel->GetScreen()->m_Curseur; - Panel->GetScreen()->m_Curseur = cursor_pos0; - Panel->ManageCurseur(Panel, DC, TRUE); - Panel->GetScreen()->m_Curseur = pos; - Segment->m_Flags = 0; - Trace_DrawSegmentPcb(Panel, DC, Segment,GR_OR) ; - } - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; - Panel->GetScreen()->m_CurrentItem = NULL; + if( Segment->m_Flags & IS_NEW ) + { + Panel->ManageCurseur( Panel, DC, FALSE ); + DeleteStructure( Segment ); + Segment = NULL; + } + else + { + wxPoint pos = Panel->GetScreen()->m_Curseur; + Panel->GetScreen()->m_Curseur = cursor_pos0; + Panel->ManageCurseur( Panel, DC, TRUE ); + Panel->GetScreen()->m_Curseur = pos; + Segment->m_Flags = 0; + Trace_DrawSegmentPcb( Panel, DC, Segment, GR_OR ); + } + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + Panel->GetScreen()->SetCurItem( NULL ); } + /**********************************************************************/ -DRAWSEGMENT * WinEDA_PcbFrame::Begin_DrawSegment(DRAWSEGMENT * Segment, - int shape, wxDC * DC) +DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment, + int shape, wxDC* DC ) /**********************************************************************/ + /* Routine d'initialisation du trace d'un segment de type autre que piste -*/ + */ { -int s_large; -int angle = 0; -DRAWSEGMENT * DrawItem; + int s_large; + int angle = 0; + DRAWSEGMENT* DrawItem; - s_large = g_DesignSettings.m_DrawSegmentWidth; - if(GetScreen()->m_Active_Layer == EDGE_N) - { - s_large = g_DesignSettings.m_EdgeSegmentWidth; - } + s_large = g_DesignSettings.m_DrawSegmentWidth; + if( GetScreen()->m_Active_Layer == EDGE_N ) + { + s_large = g_DesignSettings.m_EdgeSegmentWidth; + } - if ( shape == S_ARC ) angle = 900; + if( shape == S_ARC ) + angle = 900; - if(Segment == NULL ) /* debut reel du trace */ - { - GetScreen()->m_CurrentItem = Segment = new DRAWSEGMENT( m_Pcb); - Segment->m_Flags = IS_NEW; - Segment->m_Layer = GetScreen()->m_Active_Layer; - Segment->m_Width = s_large; - Segment->m_Shape = shape; - Segment->m_Angle = 900; - Segment->m_Start = Segment->m_End = GetScreen()->m_Curseur ; - DrawPanel->ManageCurseur = Montre_Position_NewSegment; - DrawPanel->ForceCloseManageCurseur = Exit_EditEdge; - } + if( Segment == NULL ) /* debut reel du trace */ + { + GetScreen()->SetCurItem( Segment = new DRAWSEGMENT( m_Pcb ) ); + Segment->m_Flags = IS_NEW; + Segment->m_Layer = GetScreen()->m_Active_Layer; + Segment->m_Width = s_large; + Segment->m_Shape = shape; + Segment->m_Angle = 900; + Segment->m_Start = Segment->m_End = GetScreen()->m_Curseur; + DrawPanel->ManageCurseur = Montre_Position_NewSegment; + DrawPanel->ForceCloseManageCurseur = Exit_EditEdge; + } + else /* trace en cours : les coord du point d'arrivee ont ete mises + * a jour par la routine Montre_Position_NewSegment*/ + { + if( (Segment->m_Start.x != Segment->m_End.x ) + || (Segment->m_Start.y != Segment->m_End.y ) ) + { + if( Segment->m_Shape == S_SEGMENT ) + { + Segment->Pnext = m_Pcb->m_Drawings; + Segment->Pback = m_Pcb; + if( m_Pcb->m_Drawings ) + m_Pcb->m_Drawings->Pback = Segment; + m_Pcb->m_Drawings = Segment; + GetScreen()->SetModify(); + Segment->m_Flags = 0; - else /* trace en cours : les coord du point d'arrivee ont ete mises - a jour par la routine Montre_Position_NewSegment*/ - { - if( (Segment->m_Start.x != Segment->m_End.x ) - || (Segment->m_Start.y != Segment->m_End.y ) ) - { - if ( Segment->m_Shape == S_SEGMENT ) - { - Segment->Pnext = m_Pcb->m_Drawings; - Segment->Pback = m_Pcb; - if( m_Pcb->m_Drawings ) - m_Pcb->m_Drawings->Pback = Segment; - m_Pcb->m_Drawings = Segment; - GetScreen()->SetModify(); - Segment->m_Flags = 0; + Trace_DrawSegmentPcb( DrawPanel, DC, Segment, GR_OR ); - Trace_DrawSegmentPcb(DrawPanel, DC, Segment,GR_OR); + DrawItem = Segment; - DrawItem = Segment; + GetScreen()->SetCurItem( Segment = new DRAWSEGMENT( m_Pcb ) ); - GetScreen()->m_CurrentItem = Segment = new DRAWSEGMENT( m_Pcb ); - - Segment->m_Flags = IS_NEW; - Segment->m_Layer = DrawItem->m_Layer; - Segment->m_Width = s_large; - Segment->m_Shape = DrawItem->m_Shape; - Segment->m_Type = DrawItem->m_Type; - Segment->m_Angle = DrawItem->m_Angle; - Segment->m_Start = Segment->m_End = DrawItem->m_End; - Montre_Position_NewSegment(DrawPanel, DC, FALSE); - } - else - { - End_Edge(Segment, DC); - Segment = NULL; - } - } - } - return Segment; + Segment->m_Flags = IS_NEW; + Segment->m_Layer = DrawItem->m_Layer; + Segment->m_Width = s_large; + Segment->m_Shape = DrawItem->m_Shape; + Segment->m_Type = DrawItem->m_Type; + Segment->m_Angle = DrawItem->m_Angle; + Segment->m_Start = Segment->m_End = DrawItem->m_End; + Montre_Position_NewSegment( DrawPanel, DC, FALSE ); + } + else + { + End_Edge( Segment, DC ); + Segment = NULL; + } + } + } + return Segment; } /***************************************************************/ -void WinEDA_PcbFrame::End_Edge(DRAWSEGMENT * Segment, wxDC * DC) +void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC ) /***************************************************************/ { + if( Segment == NULL ) + return; + Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) Segment, GR_OR ); - if( Segment == NULL ) return ; - Trace_DrawSegmentPcb(DrawPanel, DC, (DRAWSEGMENT *)Segment,GR_OR); + /* Effacement si Longueur nulle */ + if( (Segment->m_Start.x == Segment->m_End.x) + && (Segment->m_Start.y == Segment->m_End.y) ) + DeleteStructure( Segment ); - /* Effacement si Longueur nulle */ - if( (Segment->m_Start.x == Segment->m_End.x) && - (Segment->m_Start.y == Segment->m_End.y) ) - DeleteStructure(Segment); + else + { + Segment->m_Flags = 0; + Segment->Pnext = m_Pcb->m_Drawings; + Segment->Pback = m_Pcb; + if( m_Pcb->m_Drawings ) + m_Pcb->m_Drawings->Pback = Segment; + m_Pcb->m_Drawings = Segment; + GetScreen()->SetModify(); + } - else - { - Segment->m_Flags = 0; - Segment->Pnext = m_Pcb->m_Drawings; - Segment->Pback = m_Pcb; - if( m_Pcb->m_Drawings ) m_Pcb->m_Drawings->Pback = Segment; - m_Pcb->m_Drawings = Segment; - GetScreen()->SetModify(); - } - - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->m_CurrentItem = NULL; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->SetCurItem( NULL ); } /************************************************************/ -static void Montre_Position_NewSegment(WinEDA_DrawPanel * panel, - wxDC * DC, bool erase) +static void Montre_Position_NewSegment( WinEDA_DrawPanel* panel, + wxDC* DC, bool erase ) /************************************************************/ /* redessin du contour du Segment Edge lors des deplacements de la souris */ { -DRAWSEGMENT * Segment = ( DRAWSEGMENT * ) - panel->GetScreen()->m_CurrentItem ; -int t_fill = DisplayOpt.DisplayDrawItems; + DRAWSEGMENT* Segment = (DRAWSEGMENT*) + panel->GetScreen()->GetCurItem(); + int t_fill = DisplayOpt.DisplayDrawItems; - if(Segment == NULL) return ; + if( Segment == NULL ) + return; - DisplayOpt.DisplayDrawItems = SKETCH ; + DisplayOpt.DisplayDrawItems = SKETCH; - /* efface ancienne position */ - if( erase ) - Trace_DrawSegmentPcb(panel, DC, Segment, GR_XOR); + /* efface ancienne position */ + if( erase ) + Trace_DrawSegmentPcb( panel, DC, Segment, GR_XOR ); - if( Segments_45_Only && (Segment->m_Shape == S_SEGMENT ) ) - { - Calcule_Coord_Extremite_45(Segment->m_Start.x,Segment->m_Start.y, - &Segment->m_End.x, &Segment->m_End.y); - } + if( Segments_45_Only && (Segment->m_Shape == S_SEGMENT ) ) + { + Calcule_Coord_Extremite_45( Segment->m_Start.x, Segment->m_Start.y, + &Segment->m_End.x, &Segment->m_End.y ); + } + else /* ici l'angle d'inclinaison est quelconque */ + { + Segment->m_End = panel->GetScreen()->m_Curseur; + } - else /* ici l'angle d'inclinaison est quelconque */ - { - Segment->m_End = panel->GetScreen()->m_Curseur; - } - - Trace_DrawSegmentPcb(panel, DC, Segment,GR_XOR); - DisplayOpt.DisplayDrawItems = t_fill ; + Trace_DrawSegmentPcb( panel, DC, Segment, GR_XOR ); + DisplayOpt.DisplayDrawItems = t_fill; } - - diff --git a/pcbnew/editmod.cpp b/pcbnew/editmod.cpp index 568685ff9a..c894ca18e9 100644 --- a/pcbnew/editmod.cpp +++ b/pcbnew/editmod.cpp @@ -1,7 +1,7 @@ - /************************************************/ - /* Module editor: Dialog box for editing module */ - /* properties and carateristics */ - /************************************************/ +/************************************************/ +/* Module editor: Dialog box for editing module */ +/* properties and carateristics */ +/************************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -18,149 +18,155 @@ /* Variables locales: */ bool GoToEditor = FALSE; - /**************************************/ - /* class WinEDA_ModulePropertiesFrame */ - /**************************************/ +/**************************************/ +/* class WinEDA_ModulePropertiesFrame */ +/**************************************/ #include "dialog_edit_module.cpp" /*******************************************************************/ -void WinEDA_BasePcbFrame::InstallModuleOptionsFrame(MODULE * Module, - wxDC * DC, const wxPoint & pos) +void WinEDA_BasePcbFrame::InstallModuleOptionsFrame( MODULE* Module, + wxDC* DC, const wxPoint& pos ) /*******************************************************************/ + /* Fonction relai d'installation de la frame d'�dition des proprietes -du module*/ + * du module*/ { - WinEDA_ModulePropertiesFrame * frame = new WinEDA_ModulePropertiesFrame(this, - Module, DC, pos); - frame->ShowModal(); frame->Destroy(); + WinEDA_ModulePropertiesFrame* frame = new WinEDA_ModulePropertiesFrame( this, + Module, DC, pos ); - if ( GoToEditor && GetScreen()->m_CurrentItem ) - { - if (m_Parent->m_ModuleEditFrame == NULL ) - { - m_Parent->m_ModuleEditFrame = new WinEDA_ModuleEditFrame(this, - m_Parent,_("Module Editor"), - wxPoint(-1, -1), wxSize(600,400) ); - } + frame->ShowModal(); frame->Destroy(); - m_Parent->m_ModuleEditFrame->Load_Module_Module_From_BOARD( - (MODULE*)GetScreen()->m_CurrentItem); - GetScreen()->m_CurrentItem = NULL; + if( GoToEditor && GetScreen()->GetCurItem() ) + { + if( m_Parent->m_ModuleEditFrame == NULL ) + { + m_Parent->m_ModuleEditFrame = new WinEDA_ModuleEditFrame( this, + m_Parent, _( "Module Editor" ), + wxPoint( -1, + -1 ), + wxSize( 600, 400 ) ); + } - GoToEditor = FALSE; - m_Parent->m_ModuleEditFrame->Show(TRUE); - m_Parent->m_ModuleEditFrame->Iconize(FALSE); - } + m_Parent->m_ModuleEditFrame->Load_Module_Module_From_BOARD( + (MODULE*) GetScreen()->GetCurItem() ); + GetScreen()->SetCurItem( NULL ); + + GoToEditor = FALSE; + m_Parent->m_ModuleEditFrame->Show( TRUE ); + m_Parent->m_ModuleEditFrame->Iconize( FALSE ); + } } - - /*******************************************************************/ -void WinEDA_ModuleEditFrame::Place_Ancre(MODULE* pt_mod , wxDC * DC) +void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod, wxDC* DC ) /*******************************************************************/ + /* - Repositionne l'ancre sous le curseur souris - Le module doit etre d'abort selectionne -*/ + * Repositionne l'ancre sous le curseur souris + * Le module doit etre d'abort selectionne + */ { -int deltaX, deltaY; -EDA_BaseStruct * PtStruct; -D_PAD * pt_pad; + int deltaX, deltaY; + EDA_BaseStruct* PtStruct; + D_PAD* pt_pad; - if(pt_mod == NULL) return ; + if( pt_mod == NULL ) + return; - pt_mod->DrawAncre(DrawPanel, DC, wxPoint(0,0), DIM_ANCRE_MODULE, GR_XOR); + pt_mod->DrawAncre( DrawPanel, DC, wxPoint( 0, 0 ), DIM_ANCRE_MODULE, GR_XOR ); - deltaX = pt_mod->m_Pos.x - GetScreen()->m_Curseur.x; - deltaY = pt_mod->m_Pos.y - GetScreen()->m_Curseur.y; + deltaX = pt_mod->m_Pos.x - GetScreen()->m_Curseur.x; + deltaY = pt_mod->m_Pos.y - GetScreen()->m_Curseur.y; - pt_mod->m_Pos = GetScreen()->m_Curseur; + pt_mod->m_Pos = GetScreen()->m_Curseur; - /* Mise a jour des coord relatives des elements: - les coordonnees relatives sont relatives a l'ancre, pour orient 0. - il faut donc recalculer deltaX et deltaY en orientation 0 */ - RotatePoint(&deltaX, &deltaY, - pt_mod->m_Orient); + /* Mise a jour des coord relatives des elements: + * les coordonnees relatives sont relatives a l'ancre, pour orient 0. + * il faut donc recalculer deltaX et deltaY en orientation 0 */ + RotatePoint( &deltaX, &deltaY, -pt_mod->m_Orient ); - /* Mise a jour des coord relatives des pads */ - pt_pad = (D_PAD*)pt_mod->m_Pads; - for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext) - { - pt_pad->m_Pos0.x += deltaX; pt_pad->m_Pos0.y += deltaY; - } + /* Mise a jour des coord relatives des pads */ + pt_pad = (D_PAD*) pt_mod->m_Pads; + for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + { + pt_pad->m_Pos0.x += deltaX; pt_pad->m_Pos0.y += deltaY; + } - /* Mise a jour des coord relatives contours .. */ - PtStruct = pt_mod->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext) - { - switch( PtStruct->m_StructType) - { - case TYPEEDGEMODULE: - #undef STRUCT - #define STRUCT ((EDGE_MODULE*) PtStruct) - STRUCT->m_Start0.x += deltaX; STRUCT->m_Start0.y += deltaY; - STRUCT->m_End0.x += deltaX; STRUCT->m_End0.y += deltaY; - break; + /* Mise a jour des coord relatives contours .. */ + PtStruct = pt_mod->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEEDGEMODULE: + #undef STRUCT + #define STRUCT ( (EDGE_MODULE*) PtStruct ) + STRUCT->m_Start0.x += deltaX; STRUCT->m_Start0.y += deltaY; + STRUCT->m_End0.x += deltaX; STRUCT->m_End0.y += deltaY; + break; - case TYPETEXTEMODULE: - #undef STRUCT - #define STRUCT ((TEXTE_MODULE*) PtStruct) - STRUCT->m_Pos0.x += deltaX; STRUCT->m_Pos0.y += deltaY; - break; + case TYPETEXTEMODULE: + #undef STRUCT + #define STRUCT ( (TEXTE_MODULE*) PtStruct ) + STRUCT->m_Pos0.x += deltaX; STRUCT->m_Pos0.y += deltaY; + break; - default: - break; - } - } - pt_mod->Set_Rectangle_Encadrement(); - pt_mod->DrawAncre(DrawPanel, DC, wxPoint(0,0), DIM_ANCRE_MODULE, GR_OR); + default: + break; + } + } + + pt_mod->Set_Rectangle_Encadrement(); + pt_mod->DrawAncre( DrawPanel, DC, wxPoint( 0, 0 ), DIM_ANCRE_MODULE, GR_OR ); } + /**********************************************************************/ -void WinEDA_ModuleEditFrame::RemoveStruct(EDA_BaseStruct * Item, wxDC * DC) +void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item, wxDC* DC ) /**********************************************************************/ { - if ( Item == NULL ) return; + if( Item == NULL ) + return; - switch( Item->m_StructType ) - { - case TYPEPAD: - DeletePad( (D_PAD*) Item, DC); - break; + switch( Item->m_StructType ) + { + case TYPEPAD: + DeletePad( (D_PAD*) Item, DC ); + break; - case TYPETEXTEMODULE: - { - TEXTE_MODULE * text = (TEXTE_MODULE *) Item; - if ( text->m_Type == TEXT_is_REFERENCE ) - { - DisplayError(this, _("Text is REFERENCE!") ); - break; - } - if ( text->m_Type == TEXT_is_VALUE ) - { - DisplayError(this, _("Text is VALUE!") ); - break; - } - DeleteTextModule(text, DC); - } - break; + case TYPETEXTEMODULE: + { + TEXTE_MODULE* text = (TEXTE_MODULE*) Item; + if( text->m_Type == TEXT_is_REFERENCE ) + { + DisplayError( this, _( "Text is REFERENCE!" ) ); + break; + } + if( text->m_Type == TEXT_is_VALUE ) + { + DisplayError( this, _( "Text is VALUE!" ) ); + break; + } + DeleteTextModule( text, DC ); + } + break; - case TYPEEDGEMODULE: - Delete_Edge_Module((EDGE_MODULE *) Item, DC); - break; + case TYPEEDGEMODULE: + Delete_Edge_Module( (EDGE_MODULE*) Item, DC ); + break; - case TYPEMODULE: - break; + case TYPEMODULE: + break; - default: - { - wxString Line; - Line.Printf( wxT(" Remove: StructType %d Inattendu"), - Item->m_StructType); - DisplayError(this, Line); - } - break; - } + default: + { + wxString Line; + Line.Printf( wxT( " Remove: StructType %d Inattendu" ), + Item->m_StructType ); + DisplayError( this, Line ); + } + break; + } } - diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index e1ef297f3d..94dbdde6d8 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -1,7 +1,7 @@ - /*******************************/ - /* Edition des pistes */ - /* Routines de trace de pistes */ - /*******************************/ +/*******************************/ +/* Edition des pistes */ +/* Routines de trace de pistes */ +/*******************************/ #include "fctsys.h" #include "gr_basic.h" @@ -14,14 +14,14 @@ /* Routines Locales */ -static void Exit_Editrack(WinEDA_DrawPanel * panel, wxDC *DC); -void ShowNewTrackWhenMovingCursor(WinEDA_DrawPanel * panel, - wxDC * DC, bool erase); -static int Add_45_degrees_Segment(WinEDA_BasePcbFrame * frame, wxDC * DC, - TRACK * ptfinsegment); -static void ComputeBreakPoint( TRACK * track, int n ); -static TRACK * DeleteNullTrackSegments(BOARD * pcb, TRACK * track, int * segmcount); -static void EnsureEndTrackOnPad(D_PAD * Pad); +static void Exit_Editrack( WinEDA_DrawPanel* panel, wxDC* DC ); +void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, + wxDC* DC, bool erase ); +static int Add_45_degrees_Segment( WinEDA_BasePcbFrame* frame, wxDC* DC, + TRACK* ptfinsegment ); +static void ComputeBreakPoint( TRACK* track, int n ); +static TRACK* DeleteNullTrackSegments( BOARD* pcb, TRACK* track, int* segmcount ); +static void EnsureEndTrackOnPad( D_PAD* Pad ); /* variables locales */ static int OldNetCodeSurbrillance; @@ -29,725 +29,780 @@ static int OldEtatSurbrillance; /************************************************************/ -static void Exit_Editrack(WinEDA_DrawPanel * Panel, wxDC *DC) +static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC ) /************************************************************/ + /* routine d'annulation de la Commande Begin_Route si une piste est en cours - de tracage, ou de sortie de l'application EDITRACK. + * de tracage, ou de sortie de l'application EDITRACK. */ { -WinEDA_PcbFrame * frame = (WinEDA_PcbFrame *) Panel->m_Parent; -TRACK * track = (TRACK * ) frame->GetScreen()->m_CurrentItem; + WinEDA_PcbFrame* frame = (WinEDA_PcbFrame*) Panel->m_Parent; + TRACK* track = (TRACK*) frame->GetScreen()->GetCurItem(); - if( track != NULL ) - { - /* Erase the current drawing */ - ShowNewTrackWhenMovingCursor(Panel, DC, FALSE); - if(g_HightLigt_Status) frame->Hight_Light(DC); - g_HightLigth_NetCode = OldNetCodeSurbrillance; - if(OldEtatSurbrillance) frame->Hight_Light(DC); + if( track != NULL ) + { + /* Erase the current drawing */ + ShowNewTrackWhenMovingCursor( Panel, DC, FALSE ); + if( g_HightLigt_Status ) + frame->Hight_Light( DC ); + g_HightLigth_NetCode = OldNetCodeSurbrillance; + if( OldEtatSurbrillance ) + frame->Hight_Light( DC ); - frame->MsgPanel->EraseMsgBox(); - TRACK * previoustrack; - // Delete current (new) track - for( ;track != NULL; track = previoustrack) - { - previoustrack = (TRACK*) track->Pback; - delete track; - } - } - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; - frame->GetScreen()->m_CurrentItem = NULL; + frame->MsgPanel->EraseMsgBox(); + TRACK* previoustrack; + + // Delete current (new) track + for( ; track != NULL; track = previoustrack ) + { + previoustrack = (TRACK*) track->Pback; + delete track; + } + } + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + frame->GetScreen()->SetCurItem( NULL ); } /*************************************************************/ -TRACK * WinEDA_PcbFrame::Begin_Route(TRACK * track, wxDC * DC) +TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC ) /*************************************************************/ + /* -Routine d'initialisation d'un trace de piste et/ou de mise en place d'un -nouveau point piste - - Si pas de piste en cours de trace: - - Recherche de netname de la nouvelle piste ( pad de depart out netname - de la piste si depart sur une ancienne piste - - Met en surbrillance tout le net - - Initilise les divers pointeurs de trace - Si piste en cours: - - controle DRC - - si DRC OK : addition d'un nouveau point piste -*/ + * Routine d'initialisation d'un trace de piste et/ou de mise en place d'un + * nouveau point piste + * + * Si pas de piste en cours de trace: + * - Recherche de netname de la nouvelle piste ( pad de depart out netname + * de la piste si depart sur une ancienne piste + * - Met en surbrillance tout le net + * - Initilise les divers pointeurs de trace + * Si piste en cours: + * - controle DRC + * - si DRC OK : addition d'un nouveau point piste + */ { -D_PAD * pt_pad = NULL; -TRACK * adr_buf = NULL, * Track; -int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; -EDA_BaseStruct * LockPoint; -wxPoint pos = GetScreen()->m_Curseur; + D_PAD* pt_pad = NULL; + TRACK* adr_buf = NULL, * Track; + int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; + EDA_BaseStruct* LockPoint; + wxPoint pos = GetScreen()->m_Curseur; - DrawPanel->ManageCurseur = ShowNewTrackWhenMovingCursor; - DrawPanel->ForceCloseManageCurseur = Exit_Editrack; + DrawPanel->ManageCurseur = ShowNewTrackWhenMovingCursor; + DrawPanel->ForceCloseManageCurseur = Exit_Editrack; - if(track == NULL ) /* debut reel du trace */ - { - /* effacement surbrillance ancienne */ - OldNetCodeSurbrillance = g_HightLigth_NetCode; - OldEtatSurbrillance = g_HightLigt_Status; + if( track == NULL ) /* debut reel du trace */ + { + /* effacement surbrillance ancienne */ + OldNetCodeSurbrillance = g_HightLigth_NetCode; + OldEtatSurbrillance = g_HightLigt_Status; - if(g_HightLigt_Status) Hight_Light(DC); + if( g_HightLigt_Status ) + Hight_Light( DC ); - g_FirstTrackSegment = g_CurrentTrackSegment = new TRACK(m_Pcb); - g_CurrentTrackSegment->m_Flags = IS_NEW; - g_TrackSegmentCount = 1; - g_HightLigth_NetCode = 0; + g_FirstTrackSegment = g_CurrentTrackSegment = new TRACK( m_Pcb ); + g_CurrentTrackSegment->m_Flags = IS_NEW; + g_TrackSegmentCount = 1; + g_HightLigth_NetCode = 0; - /* Localisation de la pastille de reference de la piste: */ - LockPoint = LocateLockPoint(m_Pcb, pos, masquelayer); + /* Localisation de la pastille de reference de la piste: */ + LockPoint = LocateLockPoint( m_Pcb, pos, masquelayer ); - if( LockPoint ) - { - if( LockPoint->m_StructType == TYPEPAD ) - { - pt_pad = (D_PAD *) LockPoint; - /* le debut de la piste est remis sur le centre du pad */ - pos = pt_pad->m_Pos; - g_HightLigth_NetCode = pt_pad->m_NetCode; - } + if( LockPoint ) + { + if( LockPoint->m_StructType == TYPEPAD ) + { + pt_pad = (D_PAD*) LockPoint; + /* le debut de la piste est remis sur le centre du pad */ + pos = pt_pad->m_Pos; + g_HightLigth_NetCode = pt_pad->m_NetCode; + } + else /* le point d'accrochage est un segment */ + { + adr_buf = (TRACK*) LockPoint; + g_HightLigth_NetCode = adr_buf->m_NetCode; + CreateLockPoint( &pos.x, &pos.y, adr_buf, NULL ); + } + } - else /* le point d'accrochage est un segment */ - { - adr_buf = (TRACK *) LockPoint; - g_HightLigth_NetCode = adr_buf->m_NetCode; - CreateLockPoint( &pos.x, &pos.y, adr_buf, NULL); - } - } + build_ratsnest_pad( LockPoint, wxPoint( 0, 0 ), TRUE ); + Hight_Light( DC ); - build_ratsnest_pad(LockPoint, wxPoint(0,0), TRUE); - Hight_Light(DC); + g_CurrentTrackSegment->m_Flags = IS_NEW; + g_CurrentTrackSegment->m_Layer = GetScreen()->m_Active_Layer; + g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; + g_CurrentTrackSegment->m_Start = pos; + g_CurrentTrackSegment->m_End = g_CurrentTrackSegment->m_Start; + g_CurrentTrackSegment->m_NetCode = g_HightLigth_NetCode; + if( pt_pad ) + { + g_CurrentTrackSegment->start = pt_pad; + g_CurrentTrackSegment->SetState( BEGIN_ONPAD, ON ); + } + else + g_CurrentTrackSegment->start = adr_buf; - g_CurrentTrackSegment->m_Flags = IS_NEW; - g_CurrentTrackSegment->m_Layer = GetScreen()->m_Active_Layer; - g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth ; - g_CurrentTrackSegment->m_Start = pos; - g_CurrentTrackSegment->m_End = g_CurrentTrackSegment->m_Start; - g_CurrentTrackSegment->m_NetCode = g_HightLigth_NetCode ; - if(pt_pad) - { - g_CurrentTrackSegment->start = pt_pad ; - g_CurrentTrackSegment->SetState(BEGIN_ONPAD,ON); - } - else g_CurrentTrackSegment->start = adr_buf ; + if( g_TwoSegmentTrackBuild ) + { // Create 2 segments + g_CurrentTrackSegment = new TRACK( *g_CurrentTrackSegment ); + g_TrackSegmentCount++; + g_CurrentTrackSegment->Pback = g_FirstTrackSegment; + g_FirstTrackSegment->Pnext = g_CurrentTrackSegment; + g_CurrentTrackSegment->start = g_FirstTrackSegment; + g_FirstTrackSegment->end = g_CurrentTrackSegment; + g_FirstTrackSegment->SetState( BEGIN_ONPAD | END_ONPAD, OFF ); + } + Affiche_Infos_Piste( this, g_CurrentTrackSegment ); + GetScreen()->SetCurItem( g_CurrentTrackSegment ); + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + if( Drc_On && (Drc( this, DC, g_CurrentTrackSegment, m_Pcb->m_Track, 1 ) == BAD_DRC) ) + { + return g_CurrentTrackSegment; + } + } + else /* Track in progress : segment coordinates are updated by ShowNewTrackWhenMovingCursor*/ + { + /* Tst for a D.R.C. error: */ + if( Drc_On ) + { + if( Drc( this, DC, g_CurrentTrackSegment, m_Pcb->m_Track, 1 ) == BAD_DRC ) + return NULL; + if( g_TwoSegmentTrackBuild // We must handle 2 segments + && g_CurrentTrackSegment->Back() ) + { + if( Drc( this, DC, g_CurrentTrackSegment->Back(), m_Pcb->m_Track, 1 ) == BAD_DRC ) + return NULL; + } + } - if ( g_TwoSegmentTrackBuild ) - { // Create 2 segments - g_CurrentTrackSegment = new TRACK(*g_CurrentTrackSegment); - g_TrackSegmentCount++; - g_CurrentTrackSegment->Pback = g_FirstTrackSegment; - g_FirstTrackSegment->Pnext = g_CurrentTrackSegment; - g_CurrentTrackSegment->start = g_FirstTrackSegment; - g_FirstTrackSegment->end = g_CurrentTrackSegment; - g_FirstTrackSegment->SetState(BEGIN_ONPAD|END_ONPAD,OFF); - } - Affiche_Infos_Piste(this, g_CurrentTrackSegment) ; - GetScreen()->m_CurrentItem = g_CurrentTrackSegment; - DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); - if( Drc_On && (Drc(this, DC,g_CurrentTrackSegment,m_Pcb->m_Track,1 ) == BAD_DRC) ) - { - return g_CurrentTrackSegment; - } + /* Current track is Ok: current segment is kept, and a new one is created + * unless the current segment is null, or 2 last are null if a 2 segments track build + */ + bool CanCreateNewSegment = TRUE; + if( !g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() ) + CanCreateNewSegment = FALSE; + if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() + && g_CurrentTrackSegment->Back() && g_CurrentTrackSegment->Back()->IsNull() ) + CanCreateNewSegment = FALSE; + if( CanCreateNewSegment ) + { + /* Erase old track on screen */ + ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE ); - } + if( g_Raccord_45_Auto ) + { + if( Add_45_degrees_Segment( this, DC, g_CurrentTrackSegment ) != 0 ) + g_TrackSegmentCount++; + } + Track = g_CurrentTrackSegment->Copy(); + Track->Insert( m_Pcb, g_CurrentTrackSegment ); - else /* Track in progress : segment coordinates are updated by ShowNewTrackWhenMovingCursor*/ - { - /* Tst for a D.R.C. error: */ - if ( Drc_On ) - { - if ( Drc(this, DC,g_CurrentTrackSegment,m_Pcb->m_Track,1 ) == BAD_DRC) - return NULL; - if ( g_TwoSegmentTrackBuild && // We must handle 2 segments - g_CurrentTrackSegment->Back() ) - { - if( Drc(this, DC,g_CurrentTrackSegment->Back(),m_Pcb->m_Track,1 ) == BAD_DRC ) - return NULL; - } - } + Track->SetState( BEGIN_ONPAD | END_ONPAD, OFF ); + g_CurrentTrackSegment->end = Locate_Pad_Connecte( m_Pcb, g_CurrentTrackSegment, END ); + if( g_CurrentTrackSegment->end ) + { + g_CurrentTrackSegment->SetState( END_ONPAD, ON ); + Track->SetState( BEGIN_ONPAD, ON ); + } + Track->start = g_CurrentTrackSegment->end; - /* Current track is Ok: current segment is kept, and a new one is created - unless the current segment is null, or 2 last are null if a 2 segments track build - */ - bool CanCreateNewSegment = TRUE; - if( ! g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() ) - CanCreateNewSegment = FALSE; - if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() && - g_CurrentTrackSegment->Back() && g_CurrentTrackSegment->Back()->IsNull() ) - CanCreateNewSegment = FALSE; - if ( CanCreateNewSegment ) - { - /* Erase old track on screen */ - ShowNewTrackWhenMovingCursor(DrawPanel, DC, FALSE); + g_CurrentTrackSegment = Track; + g_CurrentTrackSegment->m_Flags = IS_NEW; + g_TrackSegmentCount++; + g_CurrentTrackSegment->m_Start = g_CurrentTrackSegment->m_End; + g_CurrentTrackSegment->m_Layer = GetScreen()->m_Active_Layer; + g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; + /* Show the new position */ + ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE ); + } + Affiche_Infos_Piste( this, g_CurrentTrackSegment ); + } - if( g_Raccord_45_Auto ) - { - if( Add_45_degrees_Segment(this, DC, g_CurrentTrackSegment) != 0 ) - g_TrackSegmentCount++; - } - Track = g_CurrentTrackSegment->Copy(); - Track->Insert(m_Pcb, g_CurrentTrackSegment); - - Track->SetState(BEGIN_ONPAD|END_ONPAD,OFF); - g_CurrentTrackSegment->end = Locate_Pad_Connecte(m_Pcb, g_CurrentTrackSegment, END); - if( g_CurrentTrackSegment->end ) - { - g_CurrentTrackSegment->SetState(END_ONPAD,ON); - Track->SetState(BEGIN_ONPAD,ON); - } - Track->start = g_CurrentTrackSegment->end; - - g_CurrentTrackSegment = Track; - g_CurrentTrackSegment->m_Flags = IS_NEW; - g_TrackSegmentCount++ ; - g_CurrentTrackSegment->m_Start = g_CurrentTrackSegment->m_End; - g_CurrentTrackSegment->m_Layer = GetScreen()->m_Active_Layer; - g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth ; - /* Show the new position */ - ShowNewTrackWhenMovingCursor(DrawPanel, DC, FALSE); - } - Affiche_Infos_Piste(this, g_CurrentTrackSegment) ; - } - - GetScreen()->m_CurrentItem = g_CurrentTrackSegment; - return g_CurrentTrackSegment; + GetScreen()->SetCurItem( g_CurrentTrackSegment ); + return g_CurrentTrackSegment; } /**************************************************************************/ -int Add_45_degrees_Segment(WinEDA_BasePcbFrame * frame, wxDC * DC, TRACK * pt_segm) +int Add_45_degrees_Segment( WinEDA_BasePcbFrame* frame, wxDC* DC, TRACK* pt_segm ) /***************************************************************************/ + /* rectifie un virage a 90 et le modifie par 2 coudes a 45 - n'opere que sur des segments horizontaux ou verticaux. - - entree : pointeur sur le segment qui vient d'etre trace - On suppose que le segment precedent est celui qui a ete - precedement trace - retourne: - 1 si ok - 0 si impossible -*/ + * n'opere que sur des segments horizontaux ou verticaux. + * + * entree : pointeur sur le segment qui vient d'etre trace + * On suppose que le segment precedent est celui qui a ete + * precedement trace + * retourne: + * 1 si ok + * 0 si impossible + */ { -TRACK * Previous; -TRACK *NewTrack; -int pas_45; -int dx0, dy0, dx1, dy1 ; + TRACK* Previous; + TRACK* NewTrack; + int pas_45; + int dx0, dy0, dx1, dy1; - if(g_TrackSegmentCount < 2 ) return(0) ; /* il faut au moins 2 segments */ + if( g_TrackSegmentCount < 2 ) + return 0; /* il faut au moins 2 segments */ - Previous = (TRACK*)pt_segm->Pback; // pointe le segment precedent + Previous = (TRACK*) pt_segm->Pback; // pointe le segment precedent - // Test s'il y a 2 segments consecutifs a raccorder - if( (pt_segm->m_StructType != TYPETRACK ) || - (Previous->m_StructType != TYPETRACK) ) - { - return(0) ; - } + // Test s'il y a 2 segments consecutifs a raccorder + if( (pt_segm->m_StructType != TYPETRACK ) + || (Previous->m_StructType != TYPETRACK) ) + { + return 0; + } - pas_45 = frame->GetScreen()->GetGrid().x / 2 ; - if( pas_45 < pt_segm->m_Width ) - pas_45 = frame->GetScreen()->GetGrid().x; - while(pas_45 < pt_segm->m_Width) pas_45 *= 2; + pas_45 = frame->GetScreen()->GetGrid().x / 2; + if( pas_45 < pt_segm->m_Width ) + pas_45 = frame->GetScreen()->GetGrid().x; + while( pas_45 < pt_segm->m_Width ) + pas_45 *= 2; - // OK : tst si les segments sont a 90 degre et vertic ou horiz - dx0 = Previous->m_End.x - Previous->m_Start.x; - dy0 = Previous->m_End.y - Previous->m_Start.y; - dx1 = pt_segm->m_End.x - pt_segm->m_Start.x; - dy1 = pt_segm->m_End.y - pt_segm->m_Start.y; - // les segments doivent etre de longueur suffisante: - if(max(abs(dx0),abs(dy0)) < (pas_45*2) ) return(0); - if(max(abs(dx1),abs(dy1)) < (pas_45*2) ) return(0); + // OK : tst si les segments sont a 90 degre et vertic ou horiz + dx0 = Previous->m_End.x - Previous->m_Start.x; + dy0 = Previous->m_End.y - Previous->m_Start.y; + dx1 = pt_segm->m_End.x - pt_segm->m_Start.x; + dy1 = pt_segm->m_End.y - pt_segm->m_Start.y; - /* creation du nouveau segment, raccordant des 2 segm: */ - NewTrack = pt_segm->Copy(); + // les segments doivent etre de longueur suffisante: + if( max( abs( dx0 ), abs( dy0 ) ) < (pas_45 * 2) ) + return 0; + if( max( abs( dx1 ), abs( dy1 ) ) < (pas_45 * 2) ) + return 0; - NewTrack->m_Start.x = Previous->m_End.x; - NewTrack->m_Start.y = Previous->m_End.y; - NewTrack->m_End.x = pt_segm->m_Start.x; - NewTrack->m_End.y = pt_segm->m_Start.y; + /* creation du nouveau segment, raccordant des 2 segm: */ + NewTrack = pt_segm->Copy(); - if( dx0 == 0 ) // Segment precedent Vertical - { - if(dy1 != 0 ) // les 2 segments ne sont pas a 90 ; - { - delete NewTrack; - return(0); - } + NewTrack->m_Start.x = Previous->m_End.x; + NewTrack->m_Start.y = Previous->m_End.y; + NewTrack->m_End.x = pt_segm->m_Start.x; + NewTrack->m_End.y = pt_segm->m_Start.y; - /* Calcul des coordonnees du point de raccord : - le nouveau segment raccorde le 1er segment Vertical - au 2eme segment Horizontal */ + if( dx0 == 0 ) // Segment precedent Vertical + { + if( dy1 != 0 ) // les 2 segments ne sont pas a 90 ; + { + delete NewTrack; + return 0; + } - if(dy0 > 0 ) NewTrack->m_Start.y -= pas_45 ; - else NewTrack->m_Start.y += pas_45 ; + /* Calcul des coordonnees du point de raccord : + * le nouveau segment raccorde le 1er segment Vertical + * au 2eme segment Horizontal */ - if(dx1 > 0 ) NewTrack->m_End.x += pas_45 ; - else NewTrack->m_End.x -= pas_45 ; + if( dy0 > 0 ) + NewTrack->m_Start.y -= pas_45; + else + NewTrack->m_Start.y += pas_45; - if ( Drc_On && (Drc(frame, DC, pt_segm, frame->m_Pcb->m_Track, 1) == BAD_DRC) ) - { - delete NewTrack; - return(0) ; - } + if( dx1 > 0 ) + NewTrack->m_End.x += pas_45; + else + NewTrack->m_End.x -= pas_45; - Previous->m_End = NewTrack->m_Start; - pt_segm->m_Start = NewTrack->m_End; - NewTrack->Insert(frame->m_Pcb, Previous); - return(1) ; - } + if( Drc_On && (Drc( frame, DC, pt_segm, frame->m_Pcb->m_Track, 1 ) == BAD_DRC) ) + { + delete NewTrack; + return 0; + } - if (dy0 == 0 ) // Segment precedent Horizontal : dy0 = 0 - { - if (dx1 != 0 ) // les 2 segments ne sont pas a 90 ; - { - delete NewTrack; - return(0); - } + Previous->m_End = NewTrack->m_Start; + pt_segm->m_Start = NewTrack->m_End; + NewTrack->Insert( frame->m_Pcb, Previous ); + return 1; + } - // Segments a 90 - /* Modif des coordonnees du point de raccord : - un nouveau segment a ete cree, raccordant le 1er segment Horizontal - au 2eme segment Vertical */ + if( dy0 == 0 ) // Segment precedent Horizontal : dy0 = 0 + { + if( dx1 != 0 ) // les 2 segments ne sont pas a 90 ; + { + delete NewTrack; + return 0; + } - if(dx0 > 0 ) NewTrack->m_Start.x -= pas_45 ; - else NewTrack->m_Start.x += pas_45 ; + // Segments a 90 - if(dy1 > 0 ) NewTrack->m_End.y += pas_45 ; - else NewTrack->m_End.y -= pas_45 ; + /* Modif des coordonnees du point de raccord : + * un nouveau segment a ete cree, raccordant le 1er segment Horizontal + * au 2eme segment Vertical */ - if ( Drc_On && (Drc(frame, DC, NewTrack, frame->m_Pcb->m_Track, 1) == BAD_DRC) ) - { - delete NewTrack; - return(0); - } + if( dx0 > 0 ) + NewTrack->m_Start.x -= pas_45; + else + NewTrack->m_Start.x += pas_45; - Previous->m_End = NewTrack->m_Start; - pt_segm->m_Start = NewTrack->m_End; - NewTrack->Insert(frame->m_Pcb, Previous); - return(1) ; - } + if( dy1 > 0 ) + NewTrack->m_End.y += pas_45; + else + NewTrack->m_End.y -= pas_45; - return(0); + if( Drc_On && (Drc( frame, DC, NewTrack, frame->m_Pcb->m_Track, 1 ) == BAD_DRC) ) + { + delete NewTrack; + return 0; + } + + Previous->m_End = NewTrack->m_Start; + pt_segm->m_Start = NewTrack->m_End; + NewTrack->Insert( frame->m_Pcb, Previous ); + return 1; + } + + return 0; } /**************************************************************/ -void WinEDA_PcbFrame::End_Route(TRACK * track, wxDC * DC) +void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC ) /*************************************************************/ + /* - Routine de fin de trace d'une piste (succession de segments) -*/ + * Routine de fin de trace d'une piste (succession de segments) + */ { -TRACK * pt_track; -int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; -wxPoint pos; -EDA_BaseStruct * LockPoint; -TRACK * adr_buf; + TRACK* pt_track; + int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; + wxPoint pos; + EDA_BaseStruct* LockPoint; + TRACK* adr_buf; - if( track == NULL ) return; + if( track == NULL ) + return; - if ( Drc_On && ( Drc(this, DC,g_CurrentTrackSegment,m_Pcb->m_Track,1 ) == BAD_DRC) ) - return ; + if( Drc_On && ( Drc( this, DC, g_CurrentTrackSegment, m_Pcb->m_Track, 1 ) == BAD_DRC) ) + return; - /* Sauvegarde des coord du point terminal de la piste */ - pos = g_CurrentTrackSegment->m_End; + /* Sauvegarde des coord du point terminal de la piste */ + pos = g_CurrentTrackSegment->m_End; - if ( Begin_Route(track, DC) == NULL ) return; + if( Begin_Route( track, DC ) == NULL ) + return; - ShowNewTrackWhenMovingCursor(DrawPanel, DC, TRUE); /* mise a jour trace reel */ - ShowNewTrackWhenMovingCursor(DrawPanel, DC, FALSE); /* efface trace piste*/ - trace_ratsnest_pad(DC); /* efface trace chevelu*/ + ShowNewTrackWhenMovingCursor( DrawPanel, DC, TRUE ); /* mise a jour trace reel */ + ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE ); /* efface trace piste*/ + trace_ratsnest_pad( DC ); /* efface trace chevelu*/ - // cleanup - if (g_CurrentTrackSegment->Pnext != NULL){ - delete g_CurrentTrackSegment->Pnext; - g_CurrentTrackSegment->Pnext = NULL; - } + // cleanup + if( g_CurrentTrackSegment->Pnext != NULL ) + { + delete g_CurrentTrackSegment->Pnext; + g_CurrentTrackSegment->Pnext = NULL; + } - /* La piste est ici non chainee a la liste des segments de piste. - Il faut la replacer dans la zone de net, - le plus pres possible du segment d'attache ( ou de fin ), car - ceci contribue a la reduction du temps de calcul */ + /* La piste est ici non chainee a la liste des segments de piste. + * Il faut la replacer dans la zone de net, + * le plus pres possible du segment d'attache ( ou de fin ), car + * ceci contribue a la reduction du temps de calcul */ - /* Accrochage de la fin de la piste */ - LockPoint = LocateLockPoint(m_Pcb, pos, masquelayer); + /* Accrochage de la fin de la piste */ + LockPoint = LocateLockPoint( m_Pcb, pos, masquelayer ); - if ( LockPoint ) /* La fin de la piste est sur un PAD */ - { - if( LockPoint->m_StructType == TYPEPAD ) - { - EnsureEndTrackOnPad( (D_PAD *) LockPoint); - } - - else /* la fin de la piste est sur une autre piste: il faudra - peut-etre creer un point d'ancrage */ - { - adr_buf = (TRACK *) LockPoint; - g_HightLigth_NetCode = adr_buf->m_NetCode; - /* creation eventuelle d'un point d'accrochage */ - LockPoint = CreateLockPoint(&g_CurrentTrackSegment->m_End.x, &g_CurrentTrackSegment->m_End.y, - adr_buf, g_CurrentTrackSegment); - } - } + if( LockPoint ) /* La fin de la piste est sur un PAD */ + { + if( LockPoint->m_StructType == TYPEPAD ) + { + EnsureEndTrackOnPad( (D_PAD*) LockPoint ); + } + else /* la fin de la piste est sur une autre piste: il faudra + * peut-etre creer un point d'ancrage */ + { + adr_buf = (TRACK*) LockPoint; + g_HightLigth_NetCode = adr_buf->m_NetCode; + /* creation eventuelle d'un point d'accrochage */ + LockPoint = CreateLockPoint( &g_CurrentTrackSegment->m_End.x, + &g_CurrentTrackSegment->m_End.y, + adr_buf, + g_CurrentTrackSegment ); + } + } - // Delete Null segments: - g_FirstTrackSegment = DeleteNullTrackSegments(m_Pcb, g_FirstTrackSegment, & g_TrackSegmentCount); - /* Test if no segment left. Can happend on a double click on the start point */ - if ( g_FirstTrackSegment != NULL ) - { + // Delete Null segments: + g_FirstTrackSegment = DeleteNullTrackSegments( m_Pcb, + g_FirstTrackSegment, + &g_TrackSegmentCount ); + /* Test if no segment left. Can happend on a double click on the start point */ + if( g_FirstTrackSegment != NULL ) + { + /* Put new track in buffer: search the best insertion poinr */ + pt_track = g_FirstTrackSegment->GetBestInsertPoint( m_Pcb ); - /* Put new track in buffer: search the best insertion poinr */ - pt_track = g_FirstTrackSegment->GetBestInsertPoint(m_Pcb); - - /* Uut track in linked list */ - g_FirstTrackSegment->Insert(m_Pcb, pt_track); - - trace_ratsnest_pad(DC); - Trace_Une_Piste(DrawPanel, DC, g_FirstTrackSegment, g_TrackSegmentCount,GR_OR) ; - - // Reset flags: - TRACK * ptr = g_FirstTrackSegment; int ii; - for ( ii = 0; (ptr != NULL) && (ii < g_TrackSegmentCount) ; ii++ ) - { - ptr->m_Flags = 0; ptr = ptr->Next(); - } - - /* Delete the old track, if exists */ - if(g_AutoDeleteOldTrack) - { - EraseOldTrack(this, m_Pcb, DC, g_FirstTrackSegment, g_TrackSegmentCount); - } - - /* compute the new rastnest : */ - test_1_net_connexion(DC, g_FirstTrackSegment->m_NetCode ); - - GetScreen()->SetModify(); - Affiche_Infos_Status_Pcb(this); - } - /* Finish the work, clear used variables */ - g_FirstTrackSegment = NULL; + /* Uut track in linked list */ + g_FirstTrackSegment->Insert( m_Pcb, pt_track ); - if(g_HightLigt_Status) Hight_Light(DC); + trace_ratsnest_pad( DC ); + Trace_Une_Piste( DrawPanel, DC, g_FirstTrackSegment, g_TrackSegmentCount, GR_OR ); - g_HightLigth_NetCode = OldNetCodeSurbrillance; - if(OldEtatSurbrillance) Hight_Light(DC); + // Reset flags: + TRACK* ptr = g_FirstTrackSegment; int ii; + for( ii = 0; (ptr != NULL) && (ii < g_TrackSegmentCount); ii++ ) + { + ptr->m_Flags = 0; ptr = ptr->Next(); + } - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->m_CurrentItem = NULL; + /* Delete the old track, if exists */ + if( g_AutoDeleteOldTrack ) + { + EraseOldTrack( this, m_Pcb, DC, g_FirstTrackSegment, g_TrackSegmentCount ); + } + + /* compute the new rastnest : */ + test_1_net_connexion( DC, g_FirstTrackSegment->m_NetCode ); + + GetScreen()->SetModify(); + Affiche_Infos_Status_Pcb( this ); + } + /* Finish the work, clear used variables */ + g_FirstTrackSegment = NULL; + + if( g_HightLigt_Status ) + Hight_Light( DC ); + + g_HightLigth_NetCode = OldNetCodeSurbrillance; + if( OldEtatSurbrillance ) + Hight_Light( DC ); + + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->SetCurItem( NULL ); } /****************************************************************************/ -void ShowNewTrackWhenMovingCursor(WinEDA_DrawPanel * panel,wxDC * DC, bool erase) +void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /****************************************************************************/ + /* redessin du contour de la piste lors des deplacements de la souris - Cette routine est utilisee comme .ManageCurseur() - si ShowIsolDuringCreateTrack_Item.State == RUN la marge d'isolation - est aussi affichee -*/ + * Cette routine est utilisee comme .ManageCurseur() + * si ShowIsolDuringCreateTrack_Item.State == RUN la marge d'isolation + * est aussi affichee + */ { -int IsolTmp, Track_fill_copy; -PCB_SCREEN * screen = (PCB_SCREEN *) panel->GetScreen(); + int IsolTmp, Track_fill_copy; + PCB_SCREEN* screen = (PCB_SCREEN*) panel->GetScreen(); - Track_fill_copy = DisplayOpt.DisplayPcbTrackFill; - DisplayOpt.DisplayPcbTrackFill = SKETCH; - IsolTmp = DisplayOpt.DisplayTrackIsol; + Track_fill_copy = DisplayOpt.DisplayPcbTrackFill; + DisplayOpt.DisplayPcbTrackFill = SKETCH; + IsolTmp = DisplayOpt.DisplayTrackIsol; - if ( g_ShowIsolDuringCreateTrack) - DisplayOpt.DisplayTrackIsol = TRUE; + if( g_ShowIsolDuringCreateTrack ) + DisplayOpt.DisplayTrackIsol = TRUE; - /* efface ancienne position si elle a ete deja dessinee */ - if( erase ) - { - Trace_Une_Piste(panel, DC, g_FirstTrackSegment,g_TrackSegmentCount,GR_XOR) ; - ((WinEDA_BasePcbFrame*)(panel->m_Parent))->trace_ratsnest_pad( DC); - } + /* efface ancienne position si elle a ete deja dessinee */ + if( erase ) + { + Trace_Une_Piste( panel, DC, g_FirstTrackSegment, g_TrackSegmentCount, GR_XOR ); + ( (WinEDA_BasePcbFrame*) (panel->m_Parent) )->trace_ratsnest_pad( DC ); + } - /* dessin de la nouvelle piste : mise a jour du point d'arrivee */ - g_CurrentTrackSegment->m_Layer = screen->m_Active_Layer; - g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; - if ( g_TwoSegmentTrackBuild ) - { - TRACK * previous_track = (TRACK *)g_CurrentTrackSegment->Pback; - if ( previous_track && (previous_track->m_StructType == TYPETRACK) ) - { - previous_track->m_Layer = screen->m_Active_Layer; - previous_track->m_Width = g_DesignSettings.m_CurrentTrackWidth; - } - } + /* dessin de la nouvelle piste : mise a jour du point d'arrivee */ + g_CurrentTrackSegment->m_Layer = screen->m_Active_Layer; + g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; + if( g_TwoSegmentTrackBuild ) + { + TRACK* previous_track = (TRACK*) g_CurrentTrackSegment->Pback; + if( previous_track && (previous_track->m_StructType == TYPETRACK) ) + { + previous_track->m_Layer = screen->m_Active_Layer; + previous_track->m_Width = g_DesignSettings.m_CurrentTrackWidth; + } + } - if (Track_45_Only) - { - if ( g_TwoSegmentTrackBuild ) - ComputeBreakPoint(g_CurrentTrackSegment, g_TrackSegmentCount); - else - { - /* Calcul de l'extremite de la piste pour orientations permises: - horiz,vertical ou 45 degre */ - Calcule_Coord_Extremite_45(g_CurrentTrackSegment->m_Start.x,g_CurrentTrackSegment->m_Start.y, - &g_CurrentTrackSegment->m_End.x, &g_CurrentTrackSegment->m_End.y); + if( Track_45_Only ) + { + if( g_TwoSegmentTrackBuild ) + ComputeBreakPoint( g_CurrentTrackSegment, g_TrackSegmentCount ); + else + { + /* Calcul de l'extremite de la piste pour orientations permises: + * horiz,vertical ou 45 degre */ + Calcule_Coord_Extremite_45( g_CurrentTrackSegment->m_Start.x, + g_CurrentTrackSegment->m_Start.y, + &g_CurrentTrackSegment->m_End.x, + &g_CurrentTrackSegment->m_End.y ); + } + } + else /* ici l'angle d'inclinaison est quelconque */ + { + g_CurrentTrackSegment->m_End = screen->m_Curseur; + } - } - } + Trace_Une_Piste( panel, DC, g_FirstTrackSegment, g_TrackSegmentCount, GR_XOR ); - else /* ici l'angle d'inclinaison est quelconque */ - { - g_CurrentTrackSegment->m_End = screen->m_Curseur; - } + DisplayOpt.DisplayTrackIsol = IsolTmp; + DisplayOpt.DisplayPcbTrackFill = Track_fill_copy; - Trace_Une_Piste(panel, DC, g_FirstTrackSegment,g_TrackSegmentCount,GR_XOR) ; + ( (WinEDA_BasePcbFrame*) (panel->m_Parent) )-> + build_ratsnest_pad( NULL, g_CurrentTrackSegment->m_End, FALSE ); - DisplayOpt.DisplayTrackIsol = IsolTmp; - DisplayOpt.DisplayPcbTrackFill = Track_fill_copy ; - - ((WinEDA_BasePcbFrame*)(panel->m_Parent))-> - build_ratsnest_pad(NULL, g_CurrentTrackSegment->m_End, FALSE); - - ((WinEDA_BasePcbFrame*)(panel->m_Parent))->trace_ratsnest_pad(DC); + ( (WinEDA_BasePcbFrame*) (panel->m_Parent) )->trace_ratsnest_pad( DC ); } /*****************************************************************/ -void Calcule_Coord_Extremite_45(int ox, int oy, int* fx, int* fy ) +void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy ) /*****************************************************************/ + /* determine les parametres .fx et .fy du segment pointe par pt_segm - pour avoir un segment oriente a 0, 90 ou 45 degres, selon position - du oint d'origine et de la souris -*/ + * pour avoir un segment oriente a 0, 90 ou 45 degres, selon position + * du oint d'origine et de la souris + */ { -int deltax, deltay, angle; + int deltax, deltay, angle; - deltax = ActiveScreen->m_Curseur.x - ox ; - deltay = ActiveScreen->m_Curseur.y - oy ; - /* calcul de l'angle preferentiel : 0, 45 , 90 degre */ - deltax = abs(deltax) ; deltay = abs(deltay) ; angle = 45 ; - if( deltax >= deltay ) - { - if ( deltax == 0 ) angle = 0 ; - else if( ((deltay << 6 )/ deltax ) < 26 ) angle = 0 ; - } - else - { - angle = 45 ; - if (deltay == 0 ) angle = 90 ; - else if( ((deltax << 6 )/ deltay ) < 26 ) angle = 90 ; - } + deltax = ActiveScreen->m_Curseur.x - ox; + deltay = ActiveScreen->m_Curseur.y - oy; + /* calcul de l'angle preferentiel : 0, 45 , 90 degre */ + deltax = abs( deltax ); deltay = abs( deltay ); angle = 45; + if( deltax >= deltay ) + { + if( deltax == 0 ) + angle = 0; + else if( ( (deltay << 6 ) / deltax ) < 26 ) + angle = 0; + } + else + { + angle = 45; + if( deltay == 0 ) + angle = 90; + else if( ( (deltax << 6 ) / deltay ) < 26 ) + angle = 90; + } - switch ( angle ) - { - case 0 : - *fx = ActiveScreen->m_Curseur.x; - *fy = oy ; - break ; + switch( angle ) + { + case 0: + *fx = ActiveScreen->m_Curseur.x; + *fy = oy; + break; - case 45 : - deltax = min(deltax,deltay) ; deltay = deltax ; - /* recalcul des signes de deltax et deltay */ - if( (ActiveScreen->m_Curseur.x - ox) < 0 ) deltax = -deltax; - if( (ActiveScreen->m_Curseur.y - oy) < 0 ) deltay = -deltay; - *fx = ox + deltax ; - *fy = oy + deltay ; - break ; + case 45: + deltax = min( deltax, deltay ); deltay = deltax; + /* recalcul des signes de deltax et deltay */ + if( (ActiveScreen->m_Curseur.x - ox) < 0 ) + deltax = -deltax; + if( (ActiveScreen->m_Curseur.y - oy) < 0 ) + deltay = -deltay; + *fx = ox + deltax; + *fy = oy + deltay; + break; - case 90 : - *fx = ox ; - *fy = ActiveScreen->m_Curseur.y; - break ; - } + case 90: + *fx = ox; + *fy = ActiveScreen->m_Curseur.y; + break; + } } /********************************************************/ -void ComputeBreakPoint( TRACK * track, int SegmentCount ) +void ComputeBreakPoint( TRACK* track, int SegmentCount ) /********************************************************/ + /** * Compute new track angle based on previous track. */ { - int iDx = 0; - int iDy = 0; - int iAngle = 0; + int iDx = 0; + int iDy = 0; + int iAngle = 0; - if ( SegmentCount <= 0 ) return; - if ( track == NULL ) return; + if( SegmentCount <= 0 ) + return; + if( track == NULL ) + return; - TRACK * NewTrack = track; - track = (TRACK*)track->Pback; - SegmentCount--; - if ( track ) - { - iDx = ActiveScreen->m_Curseur.x - track->m_Start.x; - iDy = ActiveScreen->m_Curseur.y - track->m_Start.y; + TRACK* NewTrack = track; + track = (TRACK*) track->Pback; + SegmentCount--; + if( track ) + { + iDx = ActiveScreen->m_Curseur.x - track->m_Start.x; + iDy = ActiveScreen->m_Curseur.y - track->m_Start.y; - iDx = abs(iDx); - iDy = abs(iDy); - } + iDx = abs( iDx ); + iDy = abs( iDy ); + } - TRACK * LastTrack = track ? (TRACK*)track->Pback : NULL; - if ( LastTrack ) { - if ( (LastTrack->m_End.x == LastTrack->m_Start.x) || - (LastTrack->m_End.y == LastTrack->m_Start.y) ){ - iAngle = 45; - } - } + TRACK* LastTrack = track ? (TRACK*) track->Pback : NULL; + if( LastTrack ) + { + if( (LastTrack->m_End.x == LastTrack->m_Start.x) + || (LastTrack->m_End.y == LastTrack->m_Start.y) ) + { + iAngle = 45; + } + } - if (iAngle == 0){ - if (iDx >= iDy) iAngle = 0; - else iAngle = 90; + if( iAngle == 0 ) + { + if( iDx >= iDy ) + iAngle = 0; + else + iAngle = 90; + } - } + if( track == NULL ) + iAngle = -1; - if ( track == NULL ) iAngle = -1; - switch ( iAngle ) - { - case -1: - break; + switch( iAngle ) + { + case - 1: + break; - case 0 : - if ( (ActiveScreen->m_Curseur.x - track->m_Start.x) < 0 ) - track->m_End.x = ActiveScreen->m_Curseur.x + iDy; - else - track->m_End.x = ActiveScreen->m_Curseur.x - iDy; - track->m_End.y = track->m_Start.y; - break ; + case 0: + if( (ActiveScreen->m_Curseur.x - track->m_Start.x) < 0 ) + track->m_End.x = ActiveScreen->m_Curseur.x + iDy; + else + track->m_End.x = ActiveScreen->m_Curseur.x - iDy; + track->m_End.y = track->m_Start.y; + break; - case 45 : - iDx = min(iDx,iDy); - iDy = iDx ; - /* recalcul des signes de deltax et deltay */ - if( (ActiveScreen->m_Curseur.x - track->m_Start.x) < 0 ) - iDx = -iDx; - if( (ActiveScreen->m_Curseur.y - track->m_Start.y) < 0 ) - iDy = -iDy; - track->m_End.x = track->m_Start.x + iDx; - track->m_End.y = track->m_Start.y + iDy; - break ; + case 45: + iDx = min( iDx, iDy ); + iDy = iDx; + /* recalcul des signes de deltax et deltay */ + if( (ActiveScreen->m_Curseur.x - track->m_Start.x) < 0 ) + iDx = -iDx; + if( (ActiveScreen->m_Curseur.y - track->m_Start.y) < 0 ) + iDy = -iDy; + track->m_End.x = track->m_Start.x + iDx; + track->m_End.y = track->m_Start.y + iDy; + break; - case 90 : - if ( (ActiveScreen->m_Curseur.y - track->m_Start.y) < 0 ) - track->m_End.y = ActiveScreen->m_Curseur.y + iDx; - else - track->m_End.y = ActiveScreen->m_Curseur.y - iDx; - track->m_End.x = track->m_Start.x; - break ; - } + case 90: + if( (ActiveScreen->m_Curseur.y - track->m_Start.y) < 0 ) + track->m_End.y = ActiveScreen->m_Curseur.y + iDx; + else + track->m_End.y = ActiveScreen->m_Curseur.y - iDx; + track->m_End.x = track->m_Start.x; + break; + } - if ( track ) - { - if ( track->IsNull() ) track->m_End = ActiveScreen->m_Curseur; - NewTrack->m_Start = track->m_End; - } - NewTrack->m_End = ActiveScreen->m_Curseur; + if( track ) + { + if( track->IsNull() ) + track->m_End = ActiveScreen->m_Curseur; + NewTrack->m_Start = track->m_End; + } + NewTrack->m_End = ActiveScreen->m_Curseur; } /****************************************************************************/ -TRACK * DeleteNullTrackSegments(BOARD * pcb, TRACK * track, int * segmcount) +TRACK* DeleteNullTrackSegments( BOARD* pcb, TRACK* track, int* segmcount ) /****************************************************************************/ + /* Delete track segments which have len = 0; after creating a new track - return a pointer on the first segment (start of track list) -*/ + * return a pointer on the first segment (start of track list) + */ { -TRACK * firsttrack = track; -TRACK * oldtrack; -int nn = 0; -EDA_BaseStruct * LockPoint; - if(track == 0) return NULL; - LockPoint = track->start; - while ( track != NULL ) - { - oldtrack = track; - track = track->Next(); - if ( ! oldtrack->IsNull() ) - { - nn++; - continue; - } - // NULL segment, delete it - if ( firsttrack == oldtrack ) firsttrack = track; - oldtrack->UnLink(); - delete oldtrack; - } + TRACK* firsttrack = track; + TRACK* oldtrack; + int nn = 0; + EDA_BaseStruct* LockPoint; - if ( segmcount ) *segmcount = nn; - - if ( nn == 0 ) return NULL; // all the new track segments have been deleted + if( track == 0 ) + return NULL; + LockPoint = track->start; + while( track != NULL ) + { + oldtrack = track; + track = track->Next(); + if( !oldtrack->IsNull() ) + { + nn++; + continue; + } + + // NULL segment, delete it + if( firsttrack == oldtrack ) + firsttrack = track; + oldtrack->UnLink(); + delete oldtrack; + } + + if( segmcount ) + *segmcount = nn; + + if( nn == 0 ) + return NULL; // all the new track segments have been deleted - // we must set the pointers on connected items and the connection status - oldtrack = track = firsttrack; - firsttrack->start = NULL; - while ( track != NULL ) - { - oldtrack = track; - track = track->Next(); - oldtrack->end = track; - if ( track ) track->start = oldtrack; - oldtrack->SetStatus(0); - } + // we must set the pointers on connected items and the connection status + oldtrack = track = firsttrack; + firsttrack->start = NULL; + while( track != NULL ) + { + oldtrack = track; + track = track->Next(); + oldtrack->end = track; + if( track ) + track->start = oldtrack; + oldtrack->SetStatus( 0 ); + } - firsttrack->start = LockPoint; - if ( LockPoint && (LockPoint->m_StructType == TYPEPAD ) ) - firsttrack->SetState(BEGIN_ONPAD,ON); + firsttrack->start = LockPoint; + if( LockPoint && (LockPoint->m_StructType == TYPEPAD ) ) + firsttrack->SetState( BEGIN_ONPAD, ON ); - track = firsttrack; - while ( track != NULL ) - { - TRACK * next_track = track->Next(); - LockPoint = Locate_Pad_Connecte(pcb, track, END); - if ( LockPoint ) - { - track->end = LockPoint; - track->SetState(END_ONPAD,ON); - if ( next_track ) - { - next_track->start = LockPoint; - next_track->SetState(BEGIN_ONPAD,ON); - } - } - track = next_track; - } + track = firsttrack; + while( track != NULL ) + { + TRACK* next_track = track->Next(); + LockPoint = Locate_Pad_Connecte( pcb, track, END ); + if( LockPoint ) + { + track->end = LockPoint; + track->SetState( END_ONPAD, ON ); + if( next_track ) + { + next_track->start = LockPoint; + next_track->SetState( BEGIN_ONPAD, ON ); + } + } + track = next_track; + } - return firsttrack; + return firsttrack; } + /************************************/ -void EnsureEndTrackOnPad(D_PAD * Pad) +void EnsureEndTrackOnPad( D_PAD* Pad ) /************************************/ + /* Ensure the end point of g_CurrentTrackSegment is on the pas "Pad" - if no, create a new track segment if necessary - and move current (or new) end segment on pad -*/ + * if no, create a new track segment if necessary + * and move current (or new) end segment on pad + */ { - if( g_CurrentTrackSegment->m_End == Pad->m_Pos ) // Ok ! - { - g_CurrentTrackSegment->end = Pad; - g_CurrentTrackSegment->SetState(END_ONPAD, ON); - return; - } - - TRACK * lasttrack = g_CurrentTrackSegment; - if ( ! g_CurrentTrackSegment->IsNull() ) - { /* Must create a new segment, from track end to pad center */ - g_CurrentTrackSegment = new TRACK(*lasttrack); - g_TrackSegmentCount++; - lasttrack->Pnext = g_CurrentTrackSegment; - g_CurrentTrackSegment->Pback = lasttrack; - lasttrack->end = g_CurrentTrackSegment; - } - g_CurrentTrackSegment->m_End = Pad->m_Pos; - g_CurrentTrackSegment->SetState(END_ONPAD, OFF); + if( g_CurrentTrackSegment->m_End == Pad->m_Pos ) // Ok ! + { + g_CurrentTrackSegment->end = Pad; + g_CurrentTrackSegment->SetState( END_ONPAD, ON ); + return; + } - g_CurrentTrackSegment->end = Pad; - g_CurrentTrackSegment->SetState(END_ONPAD, ON); + TRACK* lasttrack = g_CurrentTrackSegment; + if( !g_CurrentTrackSegment->IsNull() ) + { /* Must create a new segment, from track end to pad center */ + g_CurrentTrackSegment = new TRACK( *lasttrack ); + g_TrackSegmentCount++; + lasttrack->Pnext = g_CurrentTrackSegment; + g_CurrentTrackSegment->Pback = lasttrack; + lasttrack->end = g_CurrentTrackSegment; + } + g_CurrentTrackSegment->m_End = Pad->m_Pos; + g_CurrentTrackSegment->SetState( END_ONPAD, OFF ); + + g_CurrentTrackSegment->end = Pad; + g_CurrentTrackSegment->SetState( END_ONPAD, ON ); } diff --git a/pcbnew/edtxtmod.cpp b/pcbnew/edtxtmod.cpp index b1b9fdcfb4..429391a086 100644 --- a/pcbnew/edtxtmod.cpp +++ b/pcbnew/edtxtmod.cpp @@ -1,9 +1,9 @@ - /*************************************************************/ - /* Edition des Modules: Routines de modification des textes */ - /* sur les MODULES */ - /*************************************************************/ +/*************************************************************/ +/* Edition des Modules: Routines de modification des textes */ +/* sur les MODULES */ +/*************************************************************/ - /* Fichier EDTXTMOD.CPP */ +/* Fichier EDTXTMOD.CPP */ #include "fctsys.h" #include "gr_basic.h" @@ -16,215 +16,226 @@ /* Routines Locales */ -static void Show_MoveTexte_Module(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); -static void ExitTextModule(WinEDA_DrawPanel * Panel, wxDC *DC); +static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); +static void ExitTextModule( WinEDA_DrawPanel* Panel, wxDC* DC ); /* local variables */ -wxPoint MoveVector; // Move vector for move edge, exported to dialog_edit mod_text.cpp -static wxPoint CursorInitialPosition; // Mouse cursor inital position for move command +wxPoint MoveVector; // Move vector for move edge, exported to dialog_edit mod_text.cpp +static wxPoint CursorInitialPosition; // Mouse cursor inital position for move command /******************************************************************************/ -TEXTE_MODULE * WinEDA_BasePcbFrame::CreateTextModule(MODULE * Module, wxDC * DC) +TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC ) /******************************************************************************/ + /* Add a new graphical text to the active module (footprint) - Note there always are 2 texts: reference and value. - New texts have the member TEXTE_MODULE.m_Type set to TEXT_is_DIVERS -*/ + * Note there always are 2 texts: reference and value. + * New texts have the member TEXTE_MODULE.m_Type set to TEXT_is_DIVERS + */ { -TEXTE_MODULE * Text; + TEXTE_MODULE* Text; - Text = new TEXTE_MODULE(Module); + Text = new TEXTE_MODULE( Module ); - /* Chainage de la nouvelle structure en tete de liste drawings */ - Text->Pnext = Module->m_Drawings; - Text->Pback = Module; + /* Chainage de la nouvelle structure en tete de liste drawings */ + Text->Pnext = Module->m_Drawings; + Text->Pback = Module; - if( Module->m_Drawings ) - Module->m_Drawings->Pback = Text; - Module->m_Drawings = Text; - Text->m_Flags = IS_NEW; + if( Module->m_Drawings ) + Module->m_Drawings->Pback = Text; + Module->m_Drawings = Text; + Text->m_Flags = IS_NEW; - Text->m_Text = wxT("text"); + Text->m_Text = wxT( "text" ); - Text->m_Size = ModuleTextSize; - Text->m_Width = ModuleTextWidth; - Text->m_Pos = GetScreen()->m_Curseur; - Text->SetLocalCoord(); + Text->m_Size = ModuleTextSize; + Text->m_Width = ModuleTextWidth; + Text->m_Pos = GetScreen()->m_Curseur; + Text->SetLocalCoord(); - InstallTextModOptionsFrame(Text, NULL, wxPoint(-1,-1) ); + InstallTextModOptionsFrame( Text, NULL, wxPoint( -1, -1 ) ); - Text->m_Flags = 0; - Text->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR ); + Text->m_Flags = 0; + Text->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); - Affiche_Infos_E_Texte(this, Module, Text); + Affiche_Infos_E_Texte( this, Module, Text ); - return Text; + return Text; } + /**************************************************************************/ -void WinEDA_BasePcbFrame::RotateTextModule(TEXTE_MODULE * Text, wxDC * DC) +void WinEDA_BasePcbFrame::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC ) /**************************************************************************/ /* Rotation de 90 du texte d'un module */ { -MODULE * Module; + MODULE* Module; - if ( Text == NULL ) return; + if( Text == NULL ) + return; - Module = (MODULE*)Text->m_Parent; + Module = (MODULE*) Text->m_Parent; - Text->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR ); + Text->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); - Text->m_Orient += 900 ; - while (Text->m_Orient >= 1800) Text->m_Orient -= 1800 ; + Text->m_Orient += 900; + while( Text->m_Orient >= 1800 ) + Text->m_Orient -= 1800; - /* Redessin du Texte */ - Text->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR ); + /* Redessin du Texte */ + Text->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); - Affiche_Infos_E_Texte(this, Module,Text); + Affiche_Infos_E_Texte( this, Module, Text ); - ((MODULE*)Text->m_Parent)->m_LastEdit_Time = time(NULL); - GetScreen()->SetModify(); + ( (MODULE*) Text->m_Parent )->m_LastEdit_Time = time( NULL ); + GetScreen()->SetModify(); } + /**************************************************************************/ -void WinEDA_BasePcbFrame::DeleteTextModule(TEXTE_MODULE * Text, wxDC * DC) +void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text, wxDC* DC ) /**************************************************************************/ + /* - Supprime 1 texte sur module (si ce n'est pas la r�f�rence ou la valeur) -*/ + * Supprime 1 texte sur module (si ce n'est pas la r�f�rence ou la valeur) + */ { -MODULE * Module; + MODULE* Module; - if (Text == NULL) return; + if( Text == NULL ) + return; - Module = (MODULE*)Text->m_Parent; + Module = (MODULE*) Text->m_Parent; - if(Text->m_Type == TEXT_is_DIVERS) - { - Text->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR ); + if( Text->m_Type == TEXT_is_DIVERS ) + { + Text->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); - /* liberation de la memoire : */ - DeleteStructure(Text); - GetScreen()->SetModify(); - Module->m_LastEdit_Time = time(NULL); - } + /* liberation de la memoire : */ + DeleteStructure( Text ); + GetScreen()->SetModify(); + Module->m_LastEdit_Time = time( NULL ); + } } - /*************************************************************/ -static void ExitTextModule(WinEDA_DrawPanel * Panel, wxDC *DC) +static void ExitTextModule( WinEDA_DrawPanel* Panel, wxDC* DC ) /*************************************************************/ + /* - Routine de sortie du menu edit texte module -Si un texte est selectionne, ses coord initiales sont regenerees -*/ + * Routine de sortie du menu edit texte module + * Si un texte est selectionne, ses coord initiales sont regenerees + */ { -BASE_SCREEN * screen = Panel->GetScreen(); -TEXTE_MODULE * Text = (TEXTE_MODULE *) screen->m_CurrentItem; -MODULE * Module; + BASE_SCREEN* screen = Panel->GetScreen(); + TEXTE_MODULE* Text = (TEXTE_MODULE*) screen->GetCurItem(); + MODULE* Module; - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; - if ( Text == NULL ) return; + if( Text == NULL ) + return; - Module = ( MODULE *) Text->m_Parent; - Text->Draw(Panel, DC, MoveVector, GR_XOR ); + Module = (MODULE*) Text->m_Parent; + Text->Draw( Panel, DC, MoveVector, GR_XOR ); - /* Redessin du Texte */ - Text->Draw(Panel, DC, wxPoint(0,0), GR_OR ); + /* Redessin du Texte */ + Text->Draw( Panel, DC, wxPoint( 0, 0 ), GR_OR ); - Text->m_Flags = 0; - Module->m_Flags = 0; + Text->m_Flags = 0; + Module->m_Flags = 0; - screen->m_CurrentItem = NULL; + screen->SetCurItem( NULL ); } + /****************************************************************************/ -void WinEDA_BasePcbFrame::StartMoveTexteModule(TEXTE_MODULE * Text, wxDC * DC) +void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC ) /****************************************************************************/ + /* Routine d'initialisation du deplacement d'un texte sur module -*/ + */ { -MODULE * Module; + MODULE* Module; - if( Text == NULL ) return; + if( Text == NULL ) + return; - Module = (MODULE*) Text->m_Parent; + Module = (MODULE*) Text->m_Parent; - Text->m_Flags |= IS_MOVED; - Module->m_Flags |= IN_EDIT; + Text->m_Flags |= IS_MOVED; + Module->m_Flags |= IN_EDIT; - MoveVector.x = MoveVector.y = 0; - CursorInitialPosition = Text->m_Pos; + MoveVector.x = MoveVector.y = 0; + CursorInitialPosition = Text->m_Pos; - Affiche_Infos_E_Texte(this, Module, Text); + Affiche_Infos_E_Texte( this, Module, Text ); - GetScreen()->m_CurrentItem = Text; - DrawPanel->ManageCurseur = Show_MoveTexte_Module; - DrawPanel->ForceCloseManageCurseur = ExitTextModule; - - DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); + GetScreen()->SetCurItem( Text ); + DrawPanel->ManageCurseur = Show_MoveTexte_Module; + DrawPanel->ForceCloseManageCurseur = ExitTextModule; + + DrawPanel->ManageCurseur( DrawPanel, DC, TRUE ); } /*************************************************************************/ -void WinEDA_BasePcbFrame::PlaceTexteModule(TEXTE_MODULE * Text, wxDC * DC) +void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) /*************************************************************************/ + /* Routine complementaire a StartMoveTexteModule(). - Place le texte en cours de deplacement ou nouvellement cree -*/ + * Place le texte en cours de deplacement ou nouvellement cree + */ { + if( Text != NULL ) + { + Text->m_Pos = GetScreen()->m_Curseur; + /* mise a jour des coordonn�es relatives a l'ancre */ + MODULE* Module = (MODULE*) Text->m_Parent; + if( Module ) + { + int px = Text->m_Pos.x - Module->m_Pos.x; + int py = Text->m_Pos.y - Module->m_Pos.y; + RotatePoint( &px, &py, -Module->m_Orient ); + Text->m_Pos0.x = px; + Text->m_Pos0.y = py; + Text->m_Flags = 0; + Module->m_Flags = 0; + Module->m_LastEdit_Time = time( NULL ); + GetScreen()->SetModify(); - if (Text != NULL ) - { - Text->m_Pos = GetScreen()->m_Curseur; - /* mise a jour des coordonn�es relatives a l'ancre */ - MODULE * Module = ( MODULE *) Text->m_Parent; - if (Module ) - { - int px = Text->m_Pos.x - Module->m_Pos.x; - int py = Text->m_Pos.y - Module->m_Pos.y; - RotatePoint( &px, &py, - Module->m_Orient); - Text->m_Pos0.x = px; - Text->m_Pos0.y = py; - Text->m_Flags = 0; - Module->m_Flags = 0; - Module->m_LastEdit_Time = time(NULL); - GetScreen()->SetModify(); + /* Redessin du Texte */ + Text->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + } + } - /* Redessin du Texte */ - Text->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR ); - } - } - - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; } /********************************************************************************/ -static void Show_MoveTexte_Module(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /********************************************************************************/ { -BASE_SCREEN * screen = panel->GetScreen(); -TEXTE_MODULE * Text = (TEXTE_MODULE *) screen->m_CurrentItem; -MODULE * Module; + BASE_SCREEN* screen = panel->GetScreen(); + TEXTE_MODULE* Text = (TEXTE_MODULE*) screen->GetCurItem(); + MODULE* Module; - if (Text == NULL ) return ; + if( Text == NULL ) + return; - Module = ( MODULE *) Text->m_Parent; - /* effacement du texte : */ + Module = (MODULE*) Text->m_Parent; + /* effacement du texte : */ - if ( erase ) - Text->Draw(panel, DC, MoveVector, GR_XOR ); + if( erase ) + Text->Draw( panel, DC, MoveVector, GR_XOR ); - MoveVector.x = -(screen->m_Curseur.x - CursorInitialPosition.x); - MoveVector.y = -(screen->m_Curseur.y - CursorInitialPosition.y); + MoveVector.x = -(screen->m_Curseur.x - CursorInitialPosition.x); + MoveVector.y = -(screen->m_Curseur.y - CursorInitialPosition.y); - /* Redessin du Texte */ - Text->Draw(panel, DC, MoveVector, GR_XOR ); + /* Redessin du Texte */ + Text->Draw( panel, DC, MoveVector, GR_XOR ); } - diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index 4204e2f261..1717ccce34 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -32,11 +32,11 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, * touche G: Start Drag module */ { - bool PopupOn = GetScreen()->m_CurrentItem - && GetScreen()->m_CurrentItem->m_Flags; + bool PopupOn = GetScreen()->GetCurItem() + && GetScreen()->GetCurItem()->m_Flags; - bool ItemFree = (GetScreen()->m_CurrentItem == 0 ) - || (GetScreen()->m_CurrentItem->m_Flags == 0); + bool ItemFree = (GetScreen()->GetCurItem() == 0 ) + || (GetScreen()->GetCurItem()->m_Flags == 0); if( hotkey == 0 ) return; @@ -60,8 +60,8 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, case WXK_BACK: if( m_ID_current_state == ID_TRACK_BUTT && GetScreen()->m_Active_Layer <= CMP_N ) { - bool ItemFree = (GetScreen()->m_CurrentItem == NULL ) - || (GetScreen()->m_CurrentItem->m_Flags == 0); + bool ItemFree = (GetScreen()->GetCurItem() == NULL ) + || (GetScreen()->GetCurItem()->m_Flags == 0); if( ItemFree ) { // no track is currently being edited - select a segment and remove it. @@ -73,11 +73,11 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, Delete_Segment( DC, (TRACK*) DrawStruct ); GetScreen()->SetModify(); } - else if( GetScreen()->m_CurrentItem->m_StructType == TYPETRACK ) + else if( GetScreen()->GetCurItem()->m_StructType == TYPETRACK ) { // then an element is being edited - remove the last segment. - GetScreen()->m_CurrentItem = - Delete_Segment( DC, (TRACK*) GetScreen()->m_CurrentItem ); + GetScreen()->SetCurItem( + Delete_Segment( DC, (TRACK*) GetScreen()->GetCurItem() ) ); GetScreen()->SetModify(); } } @@ -85,7 +85,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, case WXK_END: DrawPanel->MouseToCursorSchema(); - End_Route( (TRACK*) (GetScreen()->m_CurrentItem), DC ); + End_Route( (TRACK*) (GetScreen()->GetCurItem()), DC ); break; case 'F' + GR_KB_CTRL: @@ -122,11 +122,11 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, Other_Layer_Route( NULL, DC ); break; } - if( GetScreen()->m_CurrentItem->m_StructType != TYPETRACK ) + if( GetScreen()->GetCurItem()->m_StructType != TYPETRACK ) return; - if( (GetScreen()->m_CurrentItem->m_Flags & IS_NEW) == 0 ) + if( (GetScreen()->GetCurItem()->m_Flags & IS_NEW) == 0 ) return; - Other_Layer_Route( (TRACK*) GetScreen()->m_CurrentItem, DC ); + Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ); if( DisplayOpt.ContrastModeDisplay ) GetScreen()->SetRefreshReq(); break; @@ -136,11 +136,11 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, // get any module, locked or not locked and toggle its locked status if( ItemFree ) module = Locate_Prefered_Module( m_Pcb, CURSEUR_OFF_GRILLE | VISIBLE_ONLY ); - else if( GetScreen()->m_CurrentItem->m_StructType == TYPEMODULE ) - module = (MODULE*) GetScreen()->m_CurrentItem; + else if( GetScreen()->GetCurItem()->m_StructType == TYPEMODULE ) + module = (MODULE*) GetScreen()->GetCurItem(); if( module ) { - GetScreen()->m_CurrentItem = module; + GetScreen()->SetCurItem( module ); module->SetLocked( !module->IsLocked() ); module->Display_Infos( this ); } @@ -180,12 +180,12 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, } } } - else if( GetScreen()->m_CurrentItem->m_StructType == TYPEMODULE ) + else if( GetScreen()->GetCurItem()->m_StructType == TYPEMODULE ) { - module = (MODULE*) GetScreen()->m_CurrentItem; + module = (MODULE*) GetScreen()->GetCurItem(); // @todo: might need to add a layer check in if() below - if( (GetScreen()->m_CurrentItem->m_Flags == 0) + if( (GetScreen()->GetCurItem()->m_Flags == 0) && module->IsLocked() ) module = NULL; // do not move, rotate ... it. } @@ -197,13 +197,13 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, does not set m_CurrentItem at this time, nor does a mouse click when the local ratsnest icon is in play set m_CurrentItem, and these actions also call SendMessageToEESCHEMA(). - if( GetScreen()->m_CurrentItem != module ) + if( GetScreen()->GetCurItem() != module ) */ { // Send the module via socket to EESCHEMA's search facility. SendMessageToEESCHEMA( module ); - GetScreen()->m_CurrentItem = module; + GetScreen()->SetCurItem( module ); } switch( hotkey ) @@ -243,8 +243,8 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey, * Les majuscules/minuscules sont indifferenciees */ { - bool PopupOn = GetScreen()->m_CurrentItem - && GetScreen()->m_CurrentItem->m_Flags; + bool PopupOn = GetScreen()->GetCurItem() + && GetScreen()->GetCurItem()->m_Flags; if( hotkey == 0 ) return; @@ -294,8 +294,8 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct ) * Efface le module. */ { - bool ItemFree = (GetScreen()->m_CurrentItem == NULL ) - || (GetScreen()->m_CurrentItem->m_Flags == 0); + bool ItemFree = (GetScreen()->GetCurItem() == NULL ) + || (GetScreen()->GetCurItem()->m_Flags == 0); switch( m_ID_current_state ) { @@ -309,10 +309,10 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct ) return FALSE; Delete_Track( DC, (TRACK*) DrawStruct ); } - else if( GetScreen()->m_CurrentItem->m_StructType == TYPETRACK ) + else if( GetScreen()->GetCurItem()->m_StructType == TYPETRACK ) { - GetScreen()->m_CurrentItem = - Delete_Segment( DC, (TRACK*) GetScreen()->m_CurrentItem ); + GetScreen()->SetCurItem( + Delete_Segment( DC, (TRACK*) GetScreen()->GetCurItem() )); GetScreen()->SetModify(); return TRUE; } @@ -337,6 +337,6 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct ) } GetScreen()->SetModify(); - GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetCurItem( NULL ); return TRUE; } diff --git a/pcbnew/initpcb.cpp b/pcbnew/initpcb.cpp index 5c92b6a4c3..8aeede0771 100644 --- a/pcbnew/initpcb.cpp +++ b/pcbnew/initpcb.cpp @@ -1,7 +1,7 @@ - /**********************************************/ - /* PCBNEW : Routines d'initialisation globale */ - /******* Fichier INITPCB.C ********************/ - /**********************************************/ +/**********************************************/ +/* PCBNEW : Routines d'initialisation globale */ +/******* Fichier INITPCB.C ********************/ +/**********************************************/ #include "fctsys.h" @@ -19,335 +19,353 @@ /********************************************************************/ -void WinEDA_PcbFrame::InstallPcbGlobalDeleteFrame(const wxPoint & pos) +void WinEDA_PcbFrame::InstallPcbGlobalDeleteFrame( const wxPoint& pos ) /********************************************************************/ { -WinEDA_PcbGlobalDeleteFrame * frame = - new WinEDA_PcbGlobalDeleteFrame(this); - frame->ShowModal(); frame->Destroy(); + WinEDA_PcbGlobalDeleteFrame* frame = + new WinEDA_PcbGlobalDeleteFrame( this ); + + frame->ShowModal(); frame->Destroy(); } /***********************************************************************/ -void WinEDA_PcbGlobalDeleteFrame::AcceptPcbDelete(wxCommandEvent& event) +void WinEDA_PcbGlobalDeleteFrame::AcceptPcbDelete( wxCommandEvent& event ) /***********************************************************************/ { -int track_mask; -bool redraw = FALSE; -wxClientDC dc(m_Parent->DrawPanel); + int track_mask; + bool redraw = FALSE; + wxClientDC dc( m_Parent->DrawPanel ); - m_Parent->DrawPanel->PrepareGraphicContext(&dc); + m_Parent->DrawPanel->PrepareGraphicContext( &dc ); - if ( m_DelAlls->GetValue() ) - { - m_Parent->Clear_Pcb(&dc, TRUE); - redraw = TRUE; - } + if( m_DelAlls->GetValue() ) + { + m_Parent->Clear_Pcb( &dc, TRUE ); + redraw = TRUE; + } + else + { + if( m_DelZones->GetValue() ) + { + m_Parent->Erase_Zones( &dc, TRUE ); + redraw = TRUE; + } - else - { - if ( m_DelZones->GetValue() ) - { - m_Parent->Erase_Zones(&dc, TRUE); - redraw = TRUE; - } + if( m_DelTexts->GetValue() ) + { + m_Parent->Erase_Textes_Pcb( &dc, TRUE ); + redraw = TRUE; + } - if ( m_DelTexts->GetValue() ) - { - m_Parent->Erase_Textes_Pcb(&dc, TRUE); - redraw = TRUE; - } + if( m_DelEdges->GetValue() ) + { + m_Parent->Erase_Segments_Pcb( &dc, TRUE, TRUE ); + redraw = TRUE; + } - if ( m_DelEdges->GetValue() ) - { - m_Parent->Erase_Segments_Pcb(&dc, TRUE, TRUE); - redraw = TRUE; - } + if( m_DelDrawings->GetValue() ) + { + m_Parent->Erase_Segments_Pcb( &dc, FALSE, TRUE ); + redraw = TRUE; + } - if ( m_DelDrawings->GetValue() ) - { - m_Parent->Erase_Segments_Pcb(&dc, FALSE, TRUE); - redraw = TRUE; - } + if( m_DelModules->GetValue() ) + { + m_Parent->Erase_Modules( &dc, TRUE ); + redraw = TRUE; + } - if ( m_DelModules->GetValue() ) - { - m_Parent->Erase_Modules(&dc, TRUE); - redraw = TRUE; - } + if( m_DelTracks->GetValue() ) + { + { + track_mask = 0; + if( !m_TrackFilterLocked->GetValue() ) + track_mask |= SEGM_FIXE; + if( !m_TrackFilterAR->GetValue() ) + track_mask |= SEGM_AR; - if ( m_DelTracks->GetValue() ) - { - { - track_mask = 0; - if ( ! m_TrackFilterLocked->GetValue() ) track_mask |= SEGM_FIXE; - if ( ! m_TrackFilterAR->GetValue() ) track_mask |= SEGM_AR; + m_Parent->Erase_Pistes( &dc, track_mask, TRUE ); + redraw = TRUE; + } + } - m_Parent->Erase_Pistes(&dc, track_mask, TRUE); - redraw = TRUE; - } - } + if( m_DelMarkers->GetValue() ) + { + m_Parent->Erase_Marqueurs(); + redraw = TRUE; + } + } - if ( m_DelMarkers->GetValue() ) - { - m_Parent->Erase_Marqueurs(); - redraw = TRUE; - } + if( redraw ) + { + m_Parent->GetScreen()->SetCurItem( NULL ); + m_Parent->ReDrawPanel(); + } - } - - if ( redraw ) - { - m_Parent->GetScreen()->m_CurrentItem = NULL; - m_Parent->ReDrawPanel(); - } - - EndModal(1); + EndModal( 1 ); } - - /*********************************************************/ -bool WinEDA_BasePcbFrame::Clear_Pcb(wxDC * DC, bool query) +bool WinEDA_BasePcbFrame::Clear_Pcb( wxDC* DC, bool query ) /*********************************************************/ + /* Realise les init des pointeurs et variables - Si query == FALSE, il n'y aura pas de confirmation -*/ + * Si query == FALSE, il n'y aura pas de confirmation + */ { + if( m_Pcb == NULL ) + return FALSE; - if( m_Pcb == NULL ) return FALSE; + if( query && GetScreen()->IsModify() ) + { + if( m_Pcb->m_Drawings ||m_Pcb->m_Modules + || m_Pcb->m_Track || m_Pcb->m_Zone ) + { + if( !IsOK( this, _( "Current Board will be lost ?" ) ) ) + return FALSE; + } + } - if ( query && GetScreen()->IsModify() ) - { - if (m_Pcb->m_Drawings ||m_Pcb->m_Modules || - m_Pcb->m_Track || m_Pcb->m_Zone ) - { - if( ! IsOK(this, _("Current Board will be lost ?")) ) return FALSE; - } - } + /* Suppression des listes chainees */ + DeleteStructList( m_Pcb->m_Equipots ); + m_Pcb->m_Equipots = NULL; - /* Suppression des listes chainees */ - DeleteStructList(m_Pcb->m_Equipots); - m_Pcb->m_Equipots = NULL; + DeleteStructList( m_Pcb->m_Drawings ); + m_Pcb->m_Drawings = NULL; - DeleteStructList(m_Pcb->m_Drawings); - m_Pcb->m_Drawings = NULL; + DeleteStructList( m_Pcb->m_Modules ); + m_Pcb->m_Modules = NULL; - DeleteStructList(m_Pcb->m_Modules); - m_Pcb->m_Modules = NULL; + DeleteStructList( m_Pcb->m_Track ); + m_Pcb->m_Track = NULL; + m_Pcb->m_NbSegmTrack = 0; - DeleteStructList(m_Pcb->m_Track); - m_Pcb->m_Track = NULL; - m_Pcb->m_NbSegmTrack = 0; + DeleteStructList( m_Pcb->m_Zone ); + m_Pcb->m_Zone = NULL; + m_Pcb->m_NbSegmZone = 0; + DelLimitesZone( DC, FALSE ); - DeleteStructList(m_Pcb->m_Zone); - m_Pcb->m_Zone = NULL; - m_Pcb->m_NbSegmZone = 0; - DelLimitesZone(DC, FALSE); + for( ; g_UnDeleteStackPtr != 0; ) + { + g_UnDeleteStackPtr--; + DeleteStructList( g_UnDeleteStack[g_UnDeleteStackPtr] ); + } - for ( ; g_UnDeleteStackPtr != 0; ) - { - g_UnDeleteStackPtr--; - DeleteStructList(g_UnDeleteStack[g_UnDeleteStackPtr]); - } + /* init pointeurs et variables */ + GetScreen()->m_FileName.Empty(); + memset( buf_work, 0, BUFMEMSIZE ); + adr_lowmem = adr_max = buf_work; - /* init pointeurs et variables */ - GetScreen()->m_FileName.Empty(); - memset (buf_work, 0, BUFMEMSIZE); - adr_lowmem = adr_max = buf_work; + if( m_Pcb->m_Pads ) + { + MyFree( m_Pcb->m_Pads ); + m_Pcb->m_Pads = NULL; + } + if( m_Pcb->m_Ratsnest ) + MyFree( m_Pcb->m_Ratsnest ); + if( m_Pcb->m_LocalRatsnest ) + MyFree( m_Pcb->m_LocalRatsnest ); + m_Pcb->m_Ratsnest = NULL; + m_Pcb->m_LocalRatsnest = NULL; - if(m_Pcb->m_Pads) - { - MyFree(m_Pcb->m_Pads); - m_Pcb->m_Pads = NULL; - } - if( m_Pcb->m_Ratsnest ) MyFree(m_Pcb->m_Ratsnest); - if( m_Pcb->m_LocalRatsnest ) MyFree(m_Pcb->m_LocalRatsnest); - m_Pcb->m_Ratsnest = NULL; - m_Pcb->m_LocalRatsnest = NULL; + /* remise a 0 ou a une valeur initiale des variables de la structure */ + m_Pcb->m_BoundaryBox.SetOrigin( wxPoint( 0, 0 ) ); + m_Pcb->m_BoundaryBox.SetSize( wxSize( 0, 0 ) ); + m_Pcb->m_Status_Pcb = 0; + m_Pcb->m_NbLoclinks = 0; + m_Pcb->m_NbLinks = 0; + m_Pcb->m_NbPads = 0; + m_Pcb->m_NbNets = 0; + m_Pcb->m_NbNodes = 0; + m_Pcb->m_NbNoconnect = 0; + m_Pcb->m_NbSegmTrack = 0; + m_Pcb->m_NbSegmZone = 0; + GetScreen()->SetCurItem( NULL ); - /* remise a 0 ou a une valeur initiale des variables de la structure */ - m_Pcb->m_BoundaryBox.SetOrigin(wxPoint(0,0)); - m_Pcb->m_BoundaryBox.SetSize(wxSize(0,0)); - m_Pcb->m_Status_Pcb = 0; - m_Pcb->m_NbLoclinks = 0; - m_Pcb->m_NbLinks = 0; - m_Pcb->m_NbPads = 0; - m_Pcb->m_NbNets = 0; - m_Pcb->m_NbNodes = 0; - m_Pcb->m_NbNoconnect = 0; - m_Pcb->m_NbSegmTrack = 0; - m_Pcb->m_NbSegmZone = 0; - GetScreen()->m_CurrentItem = NULL; + /* Init parametres de gestion */ + GetScreen()->Init(); - /* Init parametres de gestion */ - GetScreen()->Init(); + g_HightLigt_Status = 0; - g_HightLigt_Status = 0 ; + for( int ii = 1; ii < HIST0RY_NUMBER; ii++ ) + { + g_DesignSettings.m_ViaSizeHistory[ii] = + g_DesignSettings.m_TrackWidhtHistory[ii] = 0; + } - for(int ii = 1; ii < HIST0RY_NUMBER; ii++) - { - g_DesignSettings.m_ViaSizeHistory[ii] = - g_DesignSettings.m_TrackWidhtHistory[ii] = 0; - } - g_DesignSettings.m_TrackWidhtHistory[0] = g_DesignSettings.m_CurrentTrackWidth; - g_DesignSettings.m_ViaSizeHistory[0] = g_DesignSettings.m_CurrentViaSize; + g_DesignSettings.m_TrackWidhtHistory[0] = g_DesignSettings.m_CurrentTrackWidth; + g_DesignSettings.m_ViaSizeHistory[0] = g_DesignSettings.m_CurrentViaSize; - Zoom_Automatique(TRUE); - DrawPanel->Refresh(TRUE); + Zoom_Automatique( TRUE ); + DrawPanel->Refresh( TRUE ); - return TRUE; + return TRUE; } + /************************************************************/ -void WinEDA_PcbFrame::Erase_Zones(wxDC * DC, bool query) +void WinEDA_PcbFrame::Erase_Zones( wxDC* DC, bool query ) /************************************************************/ { + if( query && !IsOK( this, _( "Delete Zones ?" ) ) ) + return; - if( query && !IsOK(this, _("Delete Zones ?") ) ) return ; + if( m_Pcb->m_Zone ) + { + while( m_Pcb->m_Zone ) + DeleteStructure( m_Pcb->m_Zone ); - if( m_Pcb->m_Zone ) - { - while(m_Pcb->m_Zone ) DeleteStructure(m_Pcb->m_Zone); - m_Pcb->m_NbSegmZone = 0; - } - DelLimitesZone(DC, FALSE); + m_Pcb->m_NbSegmZone = 0; + } + DelLimitesZone( DC, FALSE ); - GetScreen()->SetModify(); + GetScreen()->SetModify(); } /*****************************************************************************/ -void WinEDA_PcbFrame::Erase_Segments_Pcb(wxDC * DC, bool is_edges, bool query) +void WinEDA_PcbFrame::Erase_Segments_Pcb( wxDC* DC, bool is_edges, bool query ) /*****************************************************************************/ { -EDA_BaseStruct * PtStruct, *PtNext; -int masque_layer = (~EDGE_LAYER) & 0x1FFF0000; + EDA_BaseStruct* PtStruct, * PtNext; + int masque_layer = (~EDGE_LAYER) & 0x1FFF0000; - if( is_edges ) - { - masque_layer = EDGE_LAYER; - if ( query && ! IsOK(this, _("Delete Board edges ?") ) ) return; - } - else - { - if ( query && ! IsOK(this, _("Delete draw items?") ) ) return; - } + if( is_edges ) + { + masque_layer = EDGE_LAYER; + if( query && !IsOK( this, _( "Delete Board edges ?" ) ) ) + return; + } + else + { + if( query && !IsOK( this, _( "Delete draw items?" ) ) ) + return; + } - PtStruct = (EDA_BaseStruct *) m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtNext) - { - PtNext = PtStruct->Pnext; - switch( PtStruct->m_StructType ) - { - case TYPEDRAWSEGMENT: - if(g_TabOneLayerMask[((DRAWSEGMENT*)PtStruct)->m_Layer] & masque_layer) - DeleteStructure(PtStruct); - break; + PtStruct = (EDA_BaseStruct*) m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtNext ) + { + PtNext = PtStruct->Pnext; - case TYPETEXTE: - if(g_TabOneLayerMask[((TEXTE_PCB*)PtStruct)->m_Layer] & masque_layer) - DeleteStructure(PtStruct); - break; + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + if( g_TabOneLayerMask[( (DRAWSEGMENT*) PtStruct )->m_Layer] & masque_layer ) + DeleteStructure( PtStruct ); + break; - case TYPECOTATION: - if(g_TabOneLayerMask[((COTATION*)PtStruct)->m_Layer] & masque_layer) - DeleteStructure(PtStruct); - break; + case TYPETEXTE: + if( g_TabOneLayerMask[( (TEXTE_PCB*) PtStruct )->m_Layer] & masque_layer ) + DeleteStructure( PtStruct ); + break; - case TYPEMIRE: - if(g_TabOneLayerMask[((MIREPCB*)PtStruct)->m_Layer] & masque_layer) - DeleteStructure(PtStruct); - break; - default: - DisplayError(this, wxT("Unknown/unexpected Draw Type")); - break; - } - } + case TYPECOTATION: + if( g_TabOneLayerMask[( (COTATION*) PtStruct )->m_Layer] & masque_layer ) + DeleteStructure( PtStruct ); + break; - GetScreen()->SetModify(); + case TYPEMIRE: + if( g_TabOneLayerMask[( (MIREPCB*) PtStruct )->m_Layer] & masque_layer ) + DeleteStructure( PtStruct ); + break; + + default: + DisplayError( this, wxT( "Unknown/unexpected Draw Type" ) ); + break; + } + } + + GetScreen()->SetModify(); } /**************************************************************************/ -void WinEDA_PcbFrame::Erase_Pistes(wxDC * DC, int masque_type, bool query) +void WinEDA_PcbFrame::Erase_Pistes( wxDC* DC, int masque_type, bool query ) /**************************************************************************/ + /* Efface les segments de piste, selon les autorisations affichees -masque_type = masque des options de selection: -SEGM_FIXE, SEGM_AR - Si un des bits est a 1, il n'y a pas effacement du segment de meme bit a 1 -*/ + * masque_type = masque des options de selection: + * SEGM_FIXE, SEGM_AR + * Si un des bits est a 1, il n'y a pas effacement du segment de meme bit a 1 + */ { -TRACK * pt_segm; -EDA_BaseStruct * PtNext; + TRACK* pt_segm; + EDA_BaseStruct* PtNext; - if( query && ! IsOK(this, _("Delete Tracks?") ) ) return; + if( query && !IsOK( this, _( "Delete Tracks?" ) ) ) + return; - /* Marquage des pistes a effacer */ - for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext) - { - PtNext = pt_segm->Pnext; - if( pt_segm->GetState(SEGM_FIXE|SEGM_AR) & masque_type) continue; - DeleteStructure(pt_segm); - } + /* Marquage des pistes a effacer */ + for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext ) + { + PtNext = pt_segm->Pnext; + if( pt_segm->GetState( SEGM_FIXE | SEGM_AR ) & masque_type ) + continue; + DeleteStructure( pt_segm ); + } - GetScreen()->SetModify(); - Compile_Ratsnest(DC, TRUE); + GetScreen()->SetModify(); + Compile_Ratsnest( DC, TRUE ); } /**************************************************************/ -void WinEDA_PcbFrame::Erase_Modules(wxDC * DC, bool query) +void WinEDA_PcbFrame::Erase_Modules( wxDC* DC, bool query ) /**************************************************************/ { - if( query && ! IsOK(this, _("Delete Modules?") ) ) return; + if( query && !IsOK( this, _( "Delete Modules?" ) ) ) + return; - while ( m_Pcb->m_Modules ) DeleteStructure(m_Pcb->m_Modules); + while( m_Pcb->m_Modules ) + DeleteStructure( m_Pcb->m_Modules ); - m_Pcb->m_Status_Pcb = 0 ; - m_Pcb->m_NbNets = 0 ; - m_Pcb->m_NbPads = 0 ; - m_Pcb->m_NbNodes = 0 ; - m_Pcb->m_NbLinks = 0 ; - m_Pcb->m_NbNoconnect = 0 ; + m_Pcb->m_Status_Pcb = 0; + m_Pcb->m_NbNets = 0; + m_Pcb->m_NbPads = 0; + m_Pcb->m_NbNodes = 0; + m_Pcb->m_NbLinks = 0; + m_Pcb->m_NbNoconnect = 0; - GetScreen()->SetModify(); + GetScreen()->SetModify(); } /************************************************************/ -void WinEDA_PcbFrame::Erase_Textes_Pcb(wxDC * DC, bool query) +void WinEDA_PcbFrame::Erase_Textes_Pcb( wxDC* DC, bool query ) /************************************************************/ { -EDA_BaseStruct * PtStruct, *PtNext; + EDA_BaseStruct* PtStruct, * PtNext; - if( query && ! IsOK(this, _("Delete Pcb Texts") ) ) return; + if( query && !IsOK( this, _( "Delete Pcb Texts" ) ) ) + return; - PtStruct = (EDA_BaseStruct*) m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtNext) - { - PtNext = PtStruct->Pnext; - if(PtStruct->m_StructType == TYPETEXTE ) DeleteStructure(PtStruct); - } + PtStruct = (EDA_BaseStruct*) m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtNext ) + { + PtNext = PtStruct->Pnext; + if( PtStruct->m_StructType == TYPETEXTE ) + DeleteStructure( PtStruct ); + } - GetScreen()->SetModify(); + GetScreen()->SetModify(); } /*******************************************/ -void WinEDA_PcbFrame::Erase_Marqueurs(void) +void WinEDA_PcbFrame::Erase_Marqueurs( void ) /*******************************************/ { -EDA_BaseStruct * PtStruct, *PtNext; + EDA_BaseStruct* PtStruct, * PtNext; - PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtNext) - { - PtNext = PtStruct->Pnext; - if(PtStruct->m_StructType == TYPEMARQUEUR ) DeleteStructure(PtStruct); - } + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtNext ) + { + PtNext = PtStruct->Pnext; + if( PtStruct->m_StructType == TYPEMARQUEUR ) + DeleteStructure( PtStruct ); + } - GetScreen()->SetModify(); + GetScreen()->SetModify(); } - diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index 426ed4b63d..cce0d1f4b0 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -1,6 +1,6 @@ - /**********************************************/ - /* Footprints selection and loading functions */ - /**********************************************/ +/**********************************************/ +/* Footprints selection and loading functions */ +/**********************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -13,547 +13,599 @@ class ModList { public: - ModList * Next; - wxString m_Name, m_Doc, m_KeyWord; + ModList* Next; + wxString m_Name, m_Doc, m_KeyWord; public: - ModList(void) - { - Next = NULL; - } - ~ModList(void) - { - } + ModList( void ) + { + Next = NULL; + } + + + ~ModList( void ) + { + } }; /* Fonctions locales */ -static void DisplayCmpDoc(wxString & Name); -static void ReadDocLib(const wxString & ModLibName ); +static void DisplayCmpDoc( wxString& Name ); +static void ReadDocLib( const wxString& ModLibName ); + /*****/ /* variables locales */ -static ModList * MList; +static ModList* MList; /***************************************************************************/ -void WinEDA_ModuleEditFrame::Load_Module_Module_From_BOARD( MODULE * Module ) +void WinEDA_ModuleEditFrame::Load_Module_Module_From_BOARD( MODULE* Module ) /***************************************************************************/ { -MODULE * NewModule; + MODULE* NewModule; - if ( Module == NULL ) - { - if (m_Parent->m_PcbFrame == NULL) return; - if (m_Parent->m_PcbFrame->m_Pcb == NULL) return; - if (m_Parent->m_PcbFrame->m_Pcb->m_Modules == NULL) return; + if( Module == NULL ) + { + if( m_Parent->m_PcbFrame == NULL ) + return; + if( m_Parent->m_PcbFrame->m_Pcb == NULL ) + return; + if( m_Parent->m_PcbFrame->m_Pcb->m_Modules == NULL ) + return; - Module = Select_1_Module_From_BOARD(m_Parent->m_PcbFrame->m_Pcb); - } + Module = Select_1_Module_From_BOARD( m_Parent->m_PcbFrame->m_Pcb ); + } - if ( Module == NULL ) return; + if( Module == NULL ) + return; - m_CurrentScreen->m_CurrentItem = NULL; + m_CurrentScreen->SetCurItem( NULL ); - Clear_Pcb(NULL, TRUE); + Clear_Pcb( NULL, TRUE ); - m_Pcb->m_Status_Pcb = 0; - NewModule = new MODULE(m_Pcb); - NewModule->Copy(Module); - NewModule->m_Link = Module->m_TimeStamp; + m_Pcb->m_Status_Pcb = 0; + NewModule = new MODULE( m_Pcb ); + NewModule->Copy( Module ); + NewModule->m_Link = Module->m_TimeStamp; - Module = NewModule; - Module->m_Parent = m_Pcb; - Module->Pback = m_Pcb->m_Modules; Module->Pnext = NULL; - m_Pcb->m_Modules = Module; + Module = NewModule; + Module->m_Parent = m_Pcb; + Module->Pback = m_Pcb->m_Modules; Module->Pnext = NULL; + m_Pcb->m_Modules = Module; - Module->m_Flags = 0; + Module->m_Flags = 0; - build_liste_pads(); + build_liste_pads(); - m_CurrentScreen->m_Curseur.x = m_CurrentScreen->m_Curseur.y = 0; - Place_Module(Module, NULL); - if( Module->m_Layer != CMP_N) Change_Side_Module(Module, NULL); - Rotate_Module(NULL, Module, 0, FALSE); - m_CurrentScreen->ClrModify(); - Zoom_Automatique(TRUE); + m_CurrentScreen->m_Curseur.x = m_CurrentScreen->m_Curseur.y = 0; + Place_Module( Module, NULL ); + if( Module->m_Layer != CMP_N ) + Change_Side_Module( Module, NULL ); + Rotate_Module( NULL, Module, 0, FALSE ); + m_CurrentScreen->ClrModify(); + Zoom_Automatique( TRUE ); } + /****************************************************************************/ -MODULE * WinEDA_BasePcbFrame::Load_Module_From_Library(const wxString & library, - wxDC * DC) +MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library, + wxDC* DC ) /****************************************************************************/ /* Permet de charger un module directement a partir de la librairie */ { -MODULE * module; -wxPoint curspos = m_CurrentScreen->m_Curseur; -wxString ModuleName, keys; -static wxArrayString HistoryList; -bool AllowWildSeach = TRUE; + MODULE* module; + wxPoint curspos = m_CurrentScreen->m_Curseur; + wxString ModuleName, keys; + static wxArrayString HistoryList; + bool AllowWildSeach = TRUE; - /* Ask for a component name or key words */ - ModuleName = GetComponentName(this, HistoryList, _("Module name:"), NULL); - ModuleName.MakeUpper(); - if( ModuleName.IsEmpty() ) /* Cancel command */ - { - DrawPanel->MouseToCursorSchema(); - return NULL; - } + /* Ask for a component name or key words */ + ModuleName = GetComponentName( this, HistoryList, _( "Module name:" ), NULL ); + ModuleName.MakeUpper(); + if( ModuleName.IsEmpty() ) /* Cancel command */ + { + DrawPanel->MouseToCursorSchema(); + return NULL; + } - if( ModuleName[0] == '=' ) // Selection by keywords - { - AllowWildSeach = FALSE; - keys = ModuleName.AfterFirst('='); - ModuleName = Select_1_Module_From_List(this, library, wxEmptyString, keys); - if( ModuleName.IsEmpty() ) /* Cancel command */ - { - DrawPanel->MouseToCursorSchema(); - return NULL; - } - } + if( ModuleName[0] == '=' ) // Selection by keywords + { + AllowWildSeach = FALSE; + keys = ModuleName.AfterFirst( '=' ); + ModuleName = Select_1_Module_From_List( this, library, wxEmptyString, keys ); + if( ModuleName.IsEmpty() ) /* Cancel command */ + { + DrawPanel->MouseToCursorSchema(); + return NULL; + } + } + else if( ( ModuleName.Contains( wxT( "?" ) ) ) || ( ModuleName.Contains( wxT( "*" ) ) ) ) // Selection wild card + { + AllowWildSeach = FALSE; + ModuleName = Select_1_Module_From_List( this, library, ModuleName, wxEmptyString ); + if( ModuleName.IsEmpty() ) + { + DrawPanel->MouseToCursorSchema(); + return NULL; /* annulation de commande */ + } + } - else if( (ModuleName.Contains(wxT("?"))) || (ModuleName.Contains(wxT("*"))) ) // Selection wild card - { - AllowWildSeach = FALSE; - ModuleName = Select_1_Module_From_List(this, library, ModuleName, wxEmptyString); - if( ModuleName.IsEmpty() ) - { - DrawPanel->MouseToCursorSchema(); - return NULL; /* annulation de commande */ - } - } + module = Get_Librairie_Module( this, library, ModuleName, FALSE ); - module = Get_Librairie_Module(this, library, ModuleName, FALSE); + if( (module == NULL) && AllowWildSeach ) /* Attemp to search with wildcard */ + { + AllowWildSeach = FALSE; + wxString wildname = wxChar( '*' ) + ModuleName + wxChar( '*' ); + ModuleName = wildname; + ModuleName = Select_1_Module_From_List( this, library, ModuleName, wxEmptyString ); + if( ModuleName.IsEmpty() ) + { + DrawPanel->MouseToCursorSchema(); + return NULL; /* annulation de commande */ + } + else + module = Get_Librairie_Module( this, library, ModuleName, TRUE ); + } - if( (module == NULL) && AllowWildSeach ) /* Attemp to search with wildcard */ - { - AllowWildSeach = FALSE; - wxString wildname = wxChar('*') + ModuleName + wxChar('*'); - ModuleName = wildname; - ModuleName = Select_1_Module_From_List(this, library, ModuleName, wxEmptyString); - if( ModuleName.IsEmpty() ) - { - DrawPanel->MouseToCursorSchema(); - return NULL; /* annulation de commande */ - } - else module = Get_Librairie_Module(this, library, ModuleName, TRUE); - } + m_CurrentScreen->m_Curseur = curspos; + DrawPanel->MouseToCursorSchema(); - m_CurrentScreen->m_Curseur = curspos; - DrawPanel->MouseToCursorSchema(); + if( module ) + { + AddHistoryComponentName( HistoryList, ModuleName ); - if( module ) - { - AddHistoryComponentName(HistoryList, ModuleName); + module->m_Flags = IS_NEW; + module->m_Link = 0; + module->m_TimeStamp = GetTimeStamp(); + m_Pcb->m_Status_Pcb = 0; + module->SetPosition( curspos ); + build_liste_pads(); - module->m_Flags = IS_NEW; - module->m_Link = 0; - module->m_TimeStamp = GetTimeStamp(); - m_Pcb->m_Status_Pcb = 0 ; - module->SetPosition(curspos); - build_liste_pads(); + module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + } - module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); - } - - return module; + return module; } + /*******************************************************************************/ -MODULE * WinEDA_BasePcbFrame::Get_Librairie_Module(wxWindow * winaff, - const wxString & library, const wxString & ModuleName, bool show_msg_err) +MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff, + const wxString& library, + const wxString& ModuleName, bool show_msg_err ) /*******************************************************************************/ + /* - Analyse les LIBRAIRIES pour trouver le module demande - Si ce module est trouve, le copie en memoire, et le - chaine en fin de liste des modules - - Entree: - name_cmp = nom du module - - Retour: - Pointeur sur le nouveau module. -*/ + * Analyse les LIBRAIRIES pour trouver le module demande + * Si ce module est trouve, le copie en memoire, et le + * chaine en fin de liste des modules + * - Entree: + * name_cmp = nom du module + * - Retour: + * Pointeur sur le nouveau module. + */ { -int LineNum, Found= 0; -wxString fulllibname; -char Line[512]; -wxString Name; -wxString ComponentName, msg; -MODULE * Module; -MODULE * NewModule; -FILE * lib_module = NULL; -unsigned ii; + int LineNum, Found = 0; + wxString fulllibname; + char Line[512]; + wxString Name; + wxString ComponentName, msg; + MODULE* Module; + MODULE* NewModule; + FILE* lib_module = NULL; + unsigned ii; - ComponentName = ModuleName; + ComponentName = ModuleName; - /* Calcul de l'adresse du dernier module: */ - Module = m_Pcb->m_Modules; - if( Module ) while( Module->Pnext ) Module = (MODULE*) Module->Pnext; + /* Calcul de l'adresse du dernier module: */ + Module = m_Pcb->m_Modules; + if( Module ) + while( Module->Pnext ) + Module = (MODULE*) Module->Pnext; - for( ii = 0; ii < g_LibName_List.GetCount(); ii++) - { - fulllibname = g_LibName_List[ii]; + for( ii = 0; ii < g_LibName_List.GetCount(); ii++ ) + { + fulllibname = g_LibName_List[ii]; - /* Calcul du nom complet de la librairie */ - fulllibname = MakeFileName(g_RealLibDirBuffer,fulllibname,LibExtBuffer); + /* Calcul du nom complet de la librairie */ + fulllibname = MakeFileName( g_RealLibDirBuffer, fulllibname, LibExtBuffer ); - if ((lib_module = wxFopen(fulllibname, wxT("rt"))) == NULL ) - { - msg.Printf(_("Library <%s> not found"),fulllibname.GetData()); - Affiche_Message(msg); - continue ; - } + if( ( lib_module = wxFopen( fulllibname, wxT( "rt" ) ) ) == NULL ) + { + msg.Printf( _( "Library <%s> not found" ), fulllibname.GetData() ); + Affiche_Message( msg ); + continue; + } - msg.Printf(_("Scan Lib: %s"),fulllibname.GetData()); - Affiche_Message(msg); + msg.Printf( _( "Scan Lib: %s" ), fulllibname.GetData() ); + Affiche_Message( msg ); - /* lecture entete chaine definie par ENTETE_LIBRAIRIE */ - LineNum = 0; - GetLine(lib_module, Line, &LineNum) ; - StrPurge(Line); - if(strnicmp( Line,ENTETE_LIBRAIRIE, L_ENTETE_LIB) != 0) - { - DisplayError(winaff, _("File is Not a library") ); - return(NULL); - } + /* lecture entete chaine definie par ENTETE_LIBRAIRIE */ + LineNum = 0; + GetLine( lib_module, Line, &LineNum ); + StrPurge( Line ); + if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) + { + DisplayError( winaff, _( "File is Not a library" ) ); + return NULL; + } - /* Lecture de la liste des composants de la librairie */ - Found = 0; - while( !Found && GetLine(lib_module,Line, &LineNum) ) - { - if( strnicmp( Line, "$MODULE",6) == 0 ) break; - if( strnicmp( Line,"$INDEX",6) == 0 ) - { - while( GetLine(lib_module,Line, &LineNum) ) - { - if( strnicmp( Line,"$EndINDEX",9) == 0 ) break; - StrPurge(Line); - msg = CONV_FROM_UTF8(Line); - if( msg.CmpNoCase(ComponentName) == 0 ) - { - Found = 1; break; /* Trouve! */ - } - } - } - } + /* Lecture de la liste des composants de la librairie */ + Found = 0; + while( !Found && GetLine( lib_module, Line, &LineNum ) ) + { + if( strnicmp( Line, "$MODULE", 6 ) == 0 ) + break; + if( strnicmp( Line, "$INDEX", 6 ) == 0 ) + { + while( GetLine( lib_module, Line, &LineNum ) ) + { + if( strnicmp( Line, "$EndINDEX", 9 ) == 0 ) + break; + StrPurge( Line ); + msg = CONV_FROM_UTF8( Line ); + if( msg.CmpNoCase( ComponentName ) == 0 ) + { + Found = 1; break; /* Trouve! */ + } + } + } + } - /* Lecture de la librairie */ - while( Found && GetLine(lib_module,Line, &LineNum) ) - { - if( Line[0] != '$' ) continue; - if( Line[1] != 'M' ) continue; - if( strnicmp( Line, "$MODULE",7) != 0 ) continue; - /* Lecture du nom du composant */ - Name = CONV_FROM_UTF8(Line+8); - if( Name.CmpNoCase(ComponentName) == 0 ) /* composant localise */ - { - NewModule = new MODULE(m_Pcb); - // Switch the locale to standard C (needed to print floating point numbers like 1.3) - setlocale(LC_NUMERIC, "C"); - NewModule->ReadDescr(lib_module, &LineNum); - setlocale(LC_NUMERIC, ""); // revert to the current locale - if( Module == NULL ) /* 1er Module */ - { - m_Pcb->m_Modules = NewModule; - NewModule->Pback = m_Pcb; - } + /* Lecture de la librairie */ + while( Found && GetLine( lib_module, Line, &LineNum ) ) + { + if( Line[0] != '$' ) + continue; + if( Line[1] != 'M' ) + continue; + if( strnicmp( Line, "$MODULE", 7 ) != 0 ) + continue; + /* Lecture du nom du composant */ + Name = CONV_FROM_UTF8( Line + 8 ); + if( Name.CmpNoCase( ComponentName ) == 0 ) /* composant localise */ + { + NewModule = new MODULE( m_Pcb ); - else - { - Module->Pnext = NewModule; - NewModule->Pback = Module; - } - fclose(lib_module) ; - Affiche_Message(wxEmptyString) ; - return(NewModule) ; - } - } - fclose(lib_module) ; lib_module = 0; - } + // Switch the locale to standard C (needed to print floating point numbers like 1.3) + setlocale( LC_NUMERIC, "C" ); + NewModule->ReadDescr( lib_module, &LineNum ); + setlocale( LC_NUMERIC, "" ); // revert to the current locale + if( Module == NULL ) /* 1er Module */ + { + m_Pcb->m_Modules = NewModule; + NewModule->Pback = m_Pcb; + } + else + { + Module->Pnext = NewModule; + NewModule->Pback = Module; + } + fclose( lib_module ); + Affiche_Message( wxEmptyString ); + return NewModule; + } + } - if( lib_module ) fclose(lib_module) ; + fclose( lib_module ); lib_module = 0; + } - if ( show_msg_err ) - { - msg.Printf(_("Module <%s> not found"),ComponentName.GetData()); - DisplayError(winaff, msg); - } - return(NULL) ; + if( lib_module ) + fclose( lib_module ); + + if( show_msg_err ) + { + msg.Printf( _( "Module <%s> not found" ), ComponentName.GetData() ); + DisplayError( winaff, msg ); + } + return NULL; } + /***************************************************************/ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( - WinEDA_DrawFrame * active_window, - const wxString & Library, - const wxString & Mask, const wxString & KeyWord) + WinEDA_DrawFrame* active_window, + const wxString& Library, + const wxString& Mask, const wxString& KeyWord ) /***************************************************************/ + /* - Affiche la liste des modules des librairies - Recherche dans la librairie Library ou generale si Library == NULL - Mask = Filtre d'affichage( Mask = wxEmptyString pour listage non filtr� ) - KeyWord = Liste de mots cles, Recherche limitee aux composants - ayant ces mots cles ( KeyWord = wxEmptyString pour listage de tous les modules ) - - retourne wxEmptyString si abort ou probleme - ou le nom du module -*/ + * Affiche la liste des modules des librairies + * Recherche dans la librairie Library ou generale si Library == NULL + * Mask = Filtre d'affichage( Mask = wxEmptyString pour listage non filtr� ) + * KeyWord = Liste de mots cles, Recherche limitee aux composants + * ayant ces mots cles ( KeyWord = wxEmptyString pour listage de tous les modules ) + * + * retourne wxEmptyString si abort ou probleme + * ou le nom du module + */ { -int LineNum; -unsigned ii, NbModules; -char Line[1024]; -wxString FullLibName; -static wxString OldName; /* Memorise le nom du dernier composant charge */ -wxString CmpName; -FILE * lib_module; -wxString msg; - -WinEDAListBox * ListBox = new WinEDAListBox(active_window, wxEmptyString, - NULL, OldName, DisplayCmpDoc, wxColour(200, 200, 255) ); + int LineNum; + unsigned ii, NbModules; + char Line[1024]; + wxString FullLibName; + static wxString OldName;/* Memorise le nom du dernier composant charge */ + wxString CmpName; + FILE* lib_module; + wxString msg; - wxBeginBusyCursor(); + WinEDAListBox* ListBox = new WinEDAListBox( active_window, wxEmptyString, + NULL, OldName, DisplayCmpDoc, + wxColour( 200, 200, 255 ) ); - /* Recherche des composants en librairies */ - NbModules = 0; - for( ii = 0; ii < g_LibName_List.GetCount(); ii++) - { - /* Calcul du nom complet de la librairie */ - if( Library.IsEmpty() ) - { - FullLibName = MakeFileName(g_RealLibDirBuffer, - g_LibName_List[ii], LibExtBuffer); - } - else - FullLibName = MakeFileName(g_RealLibDirBuffer,Library,LibExtBuffer); + wxBeginBusyCursor(); - ReadDocLib(FullLibName ); + /* Recherche des composants en librairies */ + NbModules = 0; + for( ii = 0; ii < g_LibName_List.GetCount(); ii++ ) + { + /* Calcul du nom complet de la librairie */ + if( Library.IsEmpty() ) + { + FullLibName = MakeFileName( g_RealLibDirBuffer, + g_LibName_List[ii], LibExtBuffer ); + } + else + FullLibName = MakeFileName( g_RealLibDirBuffer, Library, LibExtBuffer ); - if( ! KeyWord.IsEmpty()) /* Inutile de lire la librairie si selection - par mots cles, deja lus */ - { - if( ! Library.IsEmpty() ) break; - continue ; - } + ReadDocLib( FullLibName ); - if ((lib_module = wxFopen(FullLibName, wxT("rt"))) == NULL ) - { - if( ! Library.IsEmpty() ) break; - continue ; - } + if( !KeyWord.IsEmpty() ) /* Inutile de lire la librairie si selection + * par mots cles, deja lus */ + { + if( !Library.IsEmpty() ) + break; + continue; + } - msg = _("Library: "); msg << FullLibName; - Affiche_Message(msg); + if( ( lib_module = wxFopen( FullLibName, wxT( "rt" ) ) ) == NULL ) + { + if( !Library.IsEmpty() ) + break; + continue; + } - /* lecture entete */ - LineNum = 0; - GetLine(lib_module, Line, &LineNum, sizeof(Line) -1); + msg = _( "Library: " ); msg << FullLibName; + Affiche_Message( msg ); - if(strnicmp( Line,ENTETE_LIBRAIRIE, L_ENTETE_LIB) != 0) - { - DisplayError(this, wxT("This file is not an Eeschema libray file"), 20); continue; - } + /* lecture entete */ + LineNum = 0; + GetLine( lib_module, Line, &LineNum, sizeof(Line) - 1 ); - /* Lecture de la librairie */ - while( GetLine(lib_module,Line, &LineNum, sizeof(Line) -1) ) - { - if( Line[0] != '$' ) continue; - if( strnicmp( Line, "$MODULE",6) == 0 ) break; - if( strnicmp( Line,"$INDEX",6) == 0 ) - { - while( GetLine(lib_module,Line, &LineNum) ) - { - if( strnicmp( Line,"$EndINDEX",9) == 0 ) break; - strupper(Line); - msg = CONV_FROM_UTF8(StrPurge(Line)); - if ( Mask.IsEmpty() ) - { - ListBox->Append( msg ); - NbModules++; - } - else if ( WildCompareString(Mask, msg, FALSE) ) - { - ListBox->Append( msg ); - NbModules++; - } - } - } /* Fin Lecture INDEX */ - } /* Fin lecture 1 Librairie */ + if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) + { + DisplayError( this, wxT( "This file is not an Eeschema libray file" ), 20 ); continue; + } - fclose(lib_module) ; lib_module = NULL; - if( ! Library.IsEmpty() ) break; - } + /* Lecture de la librairie */ + while( GetLine( lib_module, Line, &LineNum, sizeof(Line) - 1 ) ) + { + if( Line[0] != '$' ) + continue; + if( strnicmp( Line, "$MODULE", 6 ) == 0 ) + break; + if( strnicmp( Line, "$INDEX", 6 ) == 0 ) + { + while( GetLine( lib_module, Line, &LineNum ) ) + { + if( strnicmp( Line, "$EndINDEX", 9 ) == 0 ) + break; + strupper( Line ); + msg = CONV_FROM_UTF8( StrPurge( Line ) ); + if( Mask.IsEmpty() ) + { + ListBox->Append( msg ); + NbModules++; + } + else if( WildCompareString( Mask, msg, FALSE ) ) + { + ListBox->Append( msg ); + NbModules++; + } + } + } /* Fin Lecture INDEX */ + } - /* creation de la liste des modules si recherche par mots-cles */ - if( ! KeyWord.IsEmpty() ) - { - ModList * ItemMod = MList; - while( ItemMod != NULL ) - { - if( KeyWordOk(KeyWord, ItemMod->m_KeyWord) ) - { - NbModules++; - ListBox->Append( ItemMod->m_Name ); - } - ItemMod = ItemMod->Next; - } - } + /* Fin lecture 1 Librairie */ - wxEndBusyCursor(); + fclose( lib_module ); lib_module = NULL; + if( !Library.IsEmpty() ) + break; + } - msg.Printf( _("Modules (%d items)"), NbModules); - ListBox->SetTitle(msg); - ListBox->SortList(); - - ii = ListBox->ShowModal(); - if ( ii >= 0 ) CmpName = ListBox->GetTextSelection(); - else CmpName.Empty(); + /* creation de la liste des modules si recherche par mots-cles */ + if( !KeyWord.IsEmpty() ) + { + ModList* ItemMod = MList; + while( ItemMod != NULL ) + { + if( KeyWordOk( KeyWord, ItemMod->m_KeyWord ) ) + { + NbModules++; + ListBox->Append( ItemMod->m_Name ); + } + ItemMod = ItemMod->Next; + } + } - ListBox->Destroy(); + wxEndBusyCursor(); - /* liberation mem de la liste des textes doc module */ - while( MList != NULL ) - { - ModList * NewMod = MList->Next; - delete MList; - MList = NewMod; - } + msg.Printf( _( "Modules (%d items)" ), NbModules ); + ListBox->SetTitle( msg ); + ListBox->SortList(); - if( CmpName != wxEmptyString ) OldName = CmpName; + ii = ListBox->ShowModal(); + if( ii >= 0 ) + CmpName = ListBox->GetTextSelection(); + else + CmpName.Empty(); - return(CmpName); + ListBox->Destroy(); + + /* liberation mem de la liste des textes doc module */ + while( MList != NULL ) + { + ModList* NewMod = MList->Next; + delete MList; + MList = NewMod; + } + + if( CmpName != wxEmptyString ) + OldName = CmpName; + + return CmpName; } + /******************************************/ -static void DisplayCmpDoc(wxString & Name) +static void DisplayCmpDoc( wxString& Name ) /*******************************************/ + /* Routine de recherche et d'affichage de la doc du composant Name - La liste des doc est pointee par MList -*/ + * La liste des doc est pointee par MList + */ { -ModList * Mod = MList; + ModList* Mod = MList; - if ( ! Mod ) - { - Name.Empty(); return; - } + if( !Mod ) + { + Name.Empty(); return; + } - /* Recherche de la description */ - while ( Mod ) - { - if( ! Mod->m_Name.IsEmpty() && (Mod->m_Name.CmpNoCase(Name) == 0) ) break; - Mod = Mod->Next; - } + /* Recherche de la description */ + while( Mod ) + { + if( !Mod->m_Name.IsEmpty() && (Mod->m_Name.CmpNoCase( Name ) == 0) ) + break; + Mod = Mod->Next; + } - if ( Mod ) - { - Name = ! Mod->m_Doc.IsEmpty() ? Mod->m_Doc : wxT("No Doc"); - Name += wxT("\nKeyW: "); - Name += ! Mod->m_KeyWord.IsEmpty() ? Mod->m_KeyWord : wxT("No Keyword"); - } - - else Name = wxEmptyString; + if( Mod ) + { + Name = !Mod->m_Doc.IsEmpty() ? Mod->m_Doc : wxT( "No Doc" ); + Name += wxT( "\nKeyW: " ); + Name += !Mod->m_KeyWord.IsEmpty() ? Mod->m_KeyWord : wxT( "No Keyword" ); + } + else + Name = wxEmptyString; } + /***************************************************/ -static void ReadDocLib(const wxString & ModLibName ) +static void ReadDocLib( const wxString& ModLibName ) /***************************************************/ + /* Routine de lecture du fichier Doc associe a la librairie ModLibName. - Cree en memoire la chaine liste des docs pointee par MList - ModLibName = full file Name de la librairie Modules -*/ + * Cree en memoire la chaine liste des docs pointee par MList + * ModLibName = full file Name de la librairie Modules + */ { -ModList * NewMod; -char Line[1024]; -FILE * LibDoc; -wxString FullModLibName = ModLibName; + ModList* NewMod; + char Line[1024]; + FILE* LibDoc; + wxString FullModLibName = ModLibName; - ChangeFileNameExt(FullModLibName, EXT_DOC); + ChangeFileNameExt( FullModLibName, EXT_DOC ); - if( (LibDoc = wxFopen(FullModLibName, wxT("rt"))) == NULL ) return; + if( ( LibDoc = wxFopen( FullModLibName, wxT( "rt" ) ) ) == NULL ) + return; - GetLine(LibDoc, Line, NULL, sizeof(Line) -1); - if(strnicmp( Line,ENTETE_LIBDOC, L_ENTETE_LIB) != 0) return; + GetLine( LibDoc, Line, NULL, sizeof(Line) - 1 ); + if( strnicmp( Line, ENTETE_LIBDOC, L_ENTETE_LIB ) != 0 ) + return; - /* Lecture de la librairie */ - while( GetLine(LibDoc,Line, NULL, sizeof(Line) -1) ) - { - if( Line[0] != '$' ) continue; - if( Line[1] == 'E' ) break;; - if( Line[1] == 'M' ) /* Debut decription 1 module */ - { - NewMod = new ModList(); - NewMod->Next = MList; - MList = NewMod; - while( GetLine(LibDoc,Line, NULL, sizeof(Line) -1) ) - { - if( Line[0] == '$' ) /* $EndMODULE */ - break; - switch( Line[0] ) - { - case 'L': /* LibName */ - NewMod->m_Name = CONV_FROM_UTF8(StrPurge(Line+3) ); - break; + /* Lecture de la librairie */ + while( GetLine( LibDoc, Line, NULL, sizeof(Line) - 1 ) ) + { + if( Line[0] != '$' ) + continue; + if( Line[1] == 'E' ) + break;; + if( Line[1] == 'M' ) /* Debut decription 1 module */ + { + NewMod = new ModList(); + NewMod->Next = MList; + MList = NewMod; + while( GetLine( LibDoc, Line, NULL, sizeof(Line) - 1 ) ) + { + if( Line[0] == '$' ) /* $EndMODULE */ + break; - case 'K': /* KeyWords */ - NewMod->m_KeyWord = CONV_FROM_UTF8(StrPurge(Line+3) ); - break; + switch( Line[0] ) + { + case 'L': /* LibName */ + NewMod->m_Name = CONV_FROM_UTF8( StrPurge( Line + 3 ) ); + break; - case 'C': /* Doc */ - NewMod->m_Doc = CONV_FROM_UTF8(StrPurge(Line+3) ); - break; - } - } - } /* lecture 1 descr module */ - } /* Fin lecture librairie */ - fclose(LibDoc); + case 'K': /* KeyWords */ + NewMod->m_KeyWord = CONV_FROM_UTF8( StrPurge( Line + 3 ) ); + break; + + case 'C': /* Doc */ + NewMod->m_Doc = CONV_FROM_UTF8( StrPurge( Line + 3 ) ); + break; + } + } + } /* lecture 1 descr module */ + } + + /* Fin lecture librairie */ + fclose( LibDoc ); } + /********************************************************************/ -MODULE * WinEDA_BasePcbFrame::Select_1_Module_From_BOARD(BOARD * Pcb) +MODULE* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb ) /********************************************************************/ + /* Affiche la liste des modules du PCB en cours - Retourne un pointeur si module selectionne - retourne NULL sinon -*/ + * Retourne un pointeur si module selectionne + * retourne NULL sinon + */ { -int ii; -MODULE * Module; -static wxString OldName; /* Memorise le nom du dernier composant charge */ -wxString CmpName, msg; + int ii; + MODULE* Module; + static wxString OldName;/* Memorise le nom du dernier composant charge */ + wxString CmpName, msg; -WinEDAListBox * ListBox = new WinEDAListBox(this, wxEmptyString, - NULL, wxEmptyString, NULL, wxColour(200, 200, 255) ); + WinEDAListBox* ListBox = new WinEDAListBox( this, wxEmptyString, + NULL, wxEmptyString, NULL, + wxColour( 200, 200, 255 ) ); - /* Recherche des composants en BOARD */ - ii = 0; - Module = Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) - { - ii++; - ListBox->Append( Module->m_Reference->m_Text ); - } + /* Recherche des composants en BOARD */ + ii = 0; + Module = Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + ii++; + ListBox->Append( Module->m_Reference->m_Text ); + } - msg.Printf( _("Modules (%d items)"), ii); - ListBox->SetTitle(msg); + msg.Printf( _( "Modules (%d items)" ), ii ); + ListBox->SetTitle( msg ); - ListBox->SortList(); + ListBox->SortList(); - ii = ListBox->ShowModal(); - if ( ii >= 0 ) CmpName = ListBox->GetTextSelection(); - else CmpName.Empty(); + ii = ListBox->ShowModal(); + if( ii >= 0 ) + CmpName = ListBox->GetTextSelection(); + else + CmpName.Empty(); - ListBox->Destroy(); + ListBox->Destroy(); - if( CmpName == wxEmptyString ) return NULL; + if( CmpName == wxEmptyString ) + return NULL; - OldName = CmpName; + OldName = CmpName; - // Recherche du pointeur sur le module - Module = Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) - { - if ( CmpName.CmpNoCase(Module->m_Reference->m_Text) == 0 ) - break; - } - return Module; + // Recherche du pointeur sur le module + Module = Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + if( CmpName.CmpNoCase( Module->m_Reference->m_Text ) == 0 ) + break; + } + + return Module; } - - diff --git a/pcbnew/mirepcb.cpp b/pcbnew/mirepcb.cpp index 28a4c00542..177dd35688 100644 --- a/pcbnew/mirepcb.cpp +++ b/pcbnew/mirepcb.cpp @@ -1,6 +1,6 @@ - /*********************************************/ - /* Routines de gestion des mires de centrage */ - /*********************************************/ +/*********************************************/ +/* Routines de gestion des mires de centrage */ +/*********************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -12,267 +12,275 @@ /* Routines Locales */ -static void Exit_EditMire(WinEDA_DrawPanel * Panel, wxDC *DC); -static void Montre_Position_Mire(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void Exit_EditMire( WinEDA_DrawPanel* Panel, wxDC* DC ); +static void Montre_Position_Mire( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); /* Variables locales : */ static wxPoint OldPos; -static int MireDefaultSize = 5000; +static int MireDefaultSize = 5000; -enum id_mire_properties -{ - ID_ACCEPT_MIRE_PROPERTIES = 1900, - ID_CANCEL_MIRE_PROPERTIES, - ID_SIZE_MIRE, - ID_LISTBOX_SHAPE_MIRE +enum id_mire_properties { + ID_ACCEPT_MIRE_PROPERTIES = 1900, + ID_CANCEL_MIRE_PROPERTIES, + ID_SIZE_MIRE, + ID_LISTBOX_SHAPE_MIRE }; - /************************************/ - /* class WinEDA_MirePropertiesFrame */ - /************************************/ +/************************************/ +/* class WinEDA_MirePropertiesFrame */ +/************************************/ -class WinEDA_MirePropertiesFrame: public wxDialog +class WinEDA_MirePropertiesFrame : public wxDialog { private: - WinEDA_PcbFrame * m_Parent; - wxDC * m_DC; - MIREPCB * m_MirePcb; - WinEDA_ValueCtrl * m_MireWidthCtrl; - WinEDA_ValueCtrl * m_MireSizeCtrl; - wxRadioBox * m_MireShape; + WinEDA_PcbFrame* m_Parent; + wxDC* m_DC; + MIREPCB* m_MirePcb; + WinEDA_ValueCtrl* m_MireWidthCtrl; + WinEDA_ValueCtrl* m_MireSizeCtrl; + wxRadioBox* m_MireShape; public: - // Constructor and destructor - WinEDA_MirePropertiesFrame(WinEDA_PcbFrame *parent, - MIREPCB * Mire, wxDC * DC, const wxPoint & pos); - ~WinEDA_MirePropertiesFrame(void) - { - } + + // Constructor and destructor + WinEDA_MirePropertiesFrame( WinEDA_PcbFrame* parent, + MIREPCB* Mire, wxDC* DC, const wxPoint& pos ); + ~WinEDA_MirePropertiesFrame( void ) + { + } + private: - void MirePropertiesAccept(wxCommandEvent& event); - void OnQuit(wxCommandEvent& event); + void MirePropertiesAccept( wxCommandEvent& event ); + void OnQuit( wxCommandEvent& event ); - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() }; -BEGIN_EVENT_TABLE(WinEDA_MirePropertiesFrame, wxDialog) - EVT_BUTTON(ID_ACCEPT_MIRE_PROPERTIES, WinEDA_MirePropertiesFrame::MirePropertiesAccept) - EVT_BUTTON(ID_CANCEL_MIRE_PROPERTIES, WinEDA_MirePropertiesFrame::OnQuit) +BEGIN_EVENT_TABLE( WinEDA_MirePropertiesFrame, wxDialog ) +EVT_BUTTON( ID_ACCEPT_MIRE_PROPERTIES, WinEDA_MirePropertiesFrame::MirePropertiesAccept ) +EVT_BUTTON( ID_CANCEL_MIRE_PROPERTIES, WinEDA_MirePropertiesFrame::OnQuit ) END_EVENT_TABLE() - /***************************************************************/ -void WinEDA_PcbFrame::InstallMireOptionsFrame(MIREPCB * MirePcb, - wxDC * DC, const wxPoint & pos) +void WinEDA_PcbFrame::InstallMireOptionsFrame( MIREPCB* MirePcb, + wxDC* DC, const wxPoint& pos ) /***************************************************************/ { - WinEDA_MirePropertiesFrame * frame = new WinEDA_MirePropertiesFrame(this, - MirePcb, DC, pos); - frame->ShowModal(); frame->Destroy(); + WinEDA_MirePropertiesFrame* frame = new WinEDA_MirePropertiesFrame( this, + MirePcb, DC, pos ); + + frame->ShowModal(); frame->Destroy(); } -WinEDA_MirePropertiesFrame::WinEDA_MirePropertiesFrame(WinEDA_PcbFrame *parent, - MIREPCB * Mire,wxDC * DC, - const wxPoint & framepos): - wxDialog(parent, -1, _("Mire properties"), framepos, wxSize(270, 210), - DIALOG_STYLE) +WinEDA_MirePropertiesFrame::WinEDA_MirePropertiesFrame( WinEDA_PcbFrame* parent, + MIREPCB* Mire, wxDC* DC, + const wxPoint& framepos ) : + wxDialog( parent, -1, _( "Mire properties" ), framepos, wxSize( 270, 210 ), + DIALOG_STYLE ) { -wxString number; -wxButton * Button; + wxString number; + wxButton* Button; - m_Parent = parent; - SetFont(*g_DialogFont); - m_DC = DC; - Centre(); + m_Parent = parent; + SetFont( *g_DialogFont ); + m_DC = DC; + Centre(); - m_MirePcb = Mire; + m_MirePcb = Mire; - wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); - SetSizer(MainBoxSizer); - wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); - wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); - MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); - MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); + SetSizer( MainBoxSizer ); + wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL ); + MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 ); + MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - /* Creation des boutons de commande */ - Button = new wxButton(this, ID_ACCEPT_MIRE_PROPERTIES, _("Ok")); - Button->SetForegroundColour(*wxRED); - RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + /* Creation des boutons de commande */ + Button = new wxButton( this, ID_ACCEPT_MIRE_PROPERTIES, _( "Ok" ) ); + Button->SetForegroundColour( *wxRED ); + RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - Button = new wxButton(this, ID_CANCEL_MIRE_PROPERTIES, _("Cancel")); - Button->SetForegroundColour(*wxBLUE); - RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + Button = new wxButton( this, ID_CANCEL_MIRE_PROPERTIES, _( "Cancel" ) ); + Button->SetForegroundColour( *wxBLUE ); + RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - // Size: - m_MireSizeCtrl = new WinEDA_ValueCtrl(this, _("Size"), - m_MirePcb->m_Size, - g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits ); + // Size: + m_MireSizeCtrl = new WinEDA_ValueCtrl( this, _( "Size" ), + m_MirePcb->m_Size, + g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits ); - // Width: - m_MireWidthCtrl = new WinEDA_ValueCtrl(this, _("Width"), - m_MirePcb->m_Width, - g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits ); + // Width: + m_MireWidthCtrl = new WinEDA_ValueCtrl( this, _( "Width" ), + m_MirePcb->m_Width, + g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits ); - // Shape -wxString shape_list[2] = { _("shape +"), _("shape X") }; - m_MireShape = new wxRadioBox(this, ID_LISTBOX_SHAPE_MIRE, - _("Mire Shape:"), - wxDefaultPosition, wxSize(-1,-1), - 2, shape_list, 1); - m_MireShape->SetSelection(m_MirePcb->m_Shape ? 1 : 0); - LeftBoxSizer->Add(m_MireShape, 0, wxGROW|wxALL, 5); + // Shape + wxString shape_list[2] = { _( "shape +" ), _( "shape X" ) }; + m_MireShape = new wxRadioBox( this, ID_LISTBOX_SHAPE_MIRE, + _( "Mire Shape:" ), + wxDefaultPosition, wxSize( -1, -1 ), + 2, shape_list, 1 ); + m_MireShape->SetSelection( m_MirePcb->m_Shape ? 1 : 0 ); + LeftBoxSizer->Add( m_MireShape, 0, wxGROW | wxALL, 5 ); - GetSizer()->Fit(this); - GetSizer()->SetSizeHints(this); + GetSizer()->Fit( this ); + GetSizer()->SetSizeHints( this ); } /**********************************************************************/ -void WinEDA_MirePropertiesFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +void WinEDA_MirePropertiesFrame::OnQuit( wxCommandEvent& WXUNUSED (event) ) /**********************************************************************/ { - Close(true); // true is to force the frame to close + Close( true ); // true is to force the frame to close } +/**************************************************************************/ +void WinEDA_MirePropertiesFrame::MirePropertiesAccept( wxCommandEvent& event ) +/**************************************************************************/ -/**************************************************************************/ -void WinEDA_MirePropertiesFrame::MirePropertiesAccept(wxCommandEvent& event) -/**************************************************************************/ /* Met a jour les differents parametres pour le composant en cours d'�dition -*/ + */ { - m_MirePcb->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0), GR_XOR); + m_MirePcb->Draw( m_Parent->DrawPanel, m_DC, wxPoint( 0, 0 ), GR_XOR ); - m_MirePcb->m_Width = m_MireWidthCtrl->GetValue(); - MireDefaultSize = m_MirePcb->m_Size = m_MireSizeCtrl->GetValue(); - m_MirePcb->m_Shape = m_MireShape->GetSelection() ? 1 : 0; + m_MirePcb->m_Width = m_MireWidthCtrl->GetValue(); + MireDefaultSize = m_MirePcb->m_Size = m_MireSizeCtrl->GetValue(); + m_MirePcb->m_Shape = m_MireShape->GetSelection() ? 1 : 0; - m_MirePcb->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0), GR_OR); + m_MirePcb->Draw( m_Parent->DrawPanel, m_DC, wxPoint( 0, 0 ), GR_OR ); - m_Parent->GetScreen()->SetModify(); - Close(TRUE); + m_Parent->GetScreen()->SetModify(); + Close( TRUE ); } + /**************************************************************/ -void WinEDA_PcbFrame::Delete_Mire(MIREPCB * MirePcb, wxDC * DC) +void WinEDA_PcbFrame::Delete_Mire( MIREPCB* MirePcb, wxDC* DC ) /**************************************************************/ { + if( MirePcb == NULL ) + return; - if( MirePcb == NULL ) return; - - MirePcb->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); - DeleteStructure(MirePcb); + MirePcb->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + DeleteStructure( MirePcb ); } /**********************************************************/ -static void Exit_EditMire(WinEDA_DrawPanel * Panel, wxDC *DC) +static void Exit_EditMire( WinEDA_DrawPanel* Panel, wxDC* DC ) /**********************************************************/ { -BASE_SCREEN * screen = Panel->GetScreen(); -MIREPCB * MirePcb = (MIREPCB *) screen->m_CurrentItem; + BASE_SCREEN* screen = Panel->GetScreen(); + MIREPCB* MirePcb = (MIREPCB*) screen->GetCurItem(); - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; - if( MirePcb ) - { - /* Effacement de la mire */ - MirePcb->Draw(Panel, DC, wxPoint(0,0), GR_XOR); + if( MirePcb ) + { + /* Effacement de la mire */ + MirePcb->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR ); - if( MirePcb->m_Flags & IS_NEW ) - { - MirePcb->Draw(Panel, DC, wxPoint(0,0), GR_XOR); - DeleteStructure(MirePcb); - MirePcb = NULL ; - } - else /* Ancienne mire en deplacement: Remise en ancienne position */ - { - MirePcb->m_Pos = OldPos; - MirePcb->m_Flags = 0; - MirePcb->Draw(Panel, DC, wxPoint(0,0),GR_OR); - } - } + if( MirePcb->m_Flags & IS_NEW ) + { + MirePcb->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR ); + DeleteStructure( MirePcb ); + MirePcb = NULL; + } + else /* Ancienne mire en deplacement: Remise en ancienne position */ + { + MirePcb->m_Pos = OldPos; + MirePcb->m_Flags = 0; + MirePcb->Draw( Panel, DC, wxPoint( 0, 0 ), GR_OR ); + } + } } + /*****************************************************/ -MIREPCB * WinEDA_PcbFrame::Create_Mire( wxDC *DC) +MIREPCB* WinEDA_PcbFrame::Create_Mire( wxDC* DC ) /*****************************************************/ + /* Routine de creation d'un Draw Symbole Pcb type MIRE -*/ + */ { -MIREPCB * MirePcb = new MIREPCB(m_Pcb); + MIREPCB* MirePcb = new MIREPCB( m_Pcb ); - MirePcb->Pnext = m_Pcb->m_Drawings; - MirePcb->Pback = m_Pcb; - if( m_Pcb->m_Drawings ) - m_Pcb->m_Drawings->Pback = MirePcb; - m_Pcb->m_Drawings = MirePcb; + MirePcb->Pnext = m_Pcb->m_Drawings; + MirePcb->Pback = m_Pcb; + if( m_Pcb->m_Drawings ) + m_Pcb->m_Drawings->Pback = MirePcb; + m_Pcb->m_Drawings = MirePcb; - MirePcb->m_Layer = EDGE_N; - MirePcb->m_Width = g_DesignSettings.m_EdgeSegmentWidth; - MirePcb->m_Size = MireDefaultSize; - MirePcb->m_Pos = GetScreen()->m_Curseur ; + MirePcb->m_Layer = EDGE_N; + MirePcb->m_Width = g_DesignSettings.m_EdgeSegmentWidth; + MirePcb->m_Size = MireDefaultSize; + MirePcb->m_Pos = GetScreen()->m_Curseur; - Place_Mire(MirePcb, DC); + Place_Mire( MirePcb, DC ); - return MirePcb; + return MirePcb; } /**********************************************************************/ -void WinEDA_PcbFrame::StartMove_Mire(MIREPCB * MirePcb, wxDC * DC) +void WinEDA_PcbFrame::StartMove_Mire( MIREPCB* MirePcb, wxDC* DC ) /**********************************************************************/ + /* Routine d'initialisation du deplacement d'une mire -*/ + */ { - if(MirePcb == NULL ) return; + if( MirePcb == NULL ) + return; - OldPos = MirePcb->m_Pos; - MirePcb->m_Flags |= IS_MOVED; - DrawPanel->ManageCurseur = Montre_Position_Mire; - DrawPanel->ForceCloseManageCurseur = Exit_EditMire; - GetScreen()->m_CurrentItem = MirePcb; + OldPos = MirePcb->m_Pos; + MirePcb->m_Flags |= IS_MOVED; + DrawPanel->ManageCurseur = Montre_Position_Mire; + DrawPanel->ForceCloseManageCurseur = Exit_EditMire; + GetScreen()->SetCurItem( MirePcb ); } /**************************************************************/ -void WinEDA_PcbFrame::Place_Mire(MIREPCB * MirePcb, wxDC * DC) +void WinEDA_PcbFrame::Place_Mire( MIREPCB* MirePcb, wxDC* DC ) /**************************************************************/ { - if( MirePcb == NULL ) return ; + if( MirePcb == NULL ) + return; - MirePcb->Draw(DrawPanel, DC, wxPoint(0,0),GR_OR); + MirePcb->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); - MirePcb->m_Flags = 0; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->m_CurrentItem = NULL; - GetScreen()->SetModify(); + MirePcb->m_Flags = 0; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->SetCurItem( NULL ); + GetScreen()->SetModify(); } /******************************************************************************/ -static void Montre_Position_Mire(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +static void Montre_Position_Mire( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /*********************************************************************************/ /* redessin du contour de la piste lors des deplacements de la souris */ { -BASE_SCREEN * screen = panel->GetScreen(); -MIREPCB * MirePcb = (MIREPCB *) screen->m_CurrentItem; + BASE_SCREEN* screen = panel->GetScreen(); + MIREPCB* MirePcb = (MIREPCB*) screen->GetCurItem(); - if(MirePcb == NULL ) return ; + if( MirePcb == NULL ) + return; - /* efface ancienne position */ - if ( erase ) MirePcb->Draw(panel, DC, wxPoint(0,0),GR_XOR); + /* efface ancienne position */ + if( erase ) + MirePcb->Draw( panel, DC, wxPoint( 0, 0 ), GR_XOR ); - MirePcb->m_Pos = screen->m_Curseur; + MirePcb->m_Pos = screen->m_Curseur; - // Reaffichage - MirePcb->Draw(panel, DC, wxPoint(0,0),GR_XOR); + // Reaffichage + MirePcb->Draw( panel, DC, wxPoint( 0, 0 ), GR_XOR ); } - diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 5f97d8da67..cc86bd68db 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -1,6 +1,6 @@ - /****************/ - /* modedit.cpp */ - /****************/ +/****************/ +/* modedit.cpp */ +/****************/ #ifdef __GNUG__ #pragma implementation @@ -19,645 +19,670 @@ /*********************************************************************/ -EDA_BaseStruct * WinEDA_ModuleEditFrame::ModeditLocateAndDisplay(void) +EDA_BaseStruct* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( void ) /*********************************************************************/ { -EDA_BaseStruct * DrawStruct = GetScreen()->m_CurrentItem; -MODULE * Module = m_Pcb->m_Modules; + EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem(); + MODULE* Module = m_Pcb->m_Modules; - if ( Module == NULL ) return NULL; + if( Module == NULL ) + return NULL; - DrawStruct = Locate_Edge_Module(Module, CURSEUR_OFF_GRILLE); - if ( DrawStruct ) - { - Affiche_Infos_Segment_Module(this, Module,(EDGE_MODULE*) DrawStruct); - } - else DrawStruct = Locate( CURSEUR_OFF_GRILLE, -1); + DrawStruct = Locate_Edge_Module( Module, CURSEUR_OFF_GRILLE ); + if( DrawStruct ) + { + Affiche_Infos_Segment_Module( this, Module, (EDGE_MODULE*) DrawStruct ); + } + else + DrawStruct = Locate( CURSEUR_OFF_GRILLE, -1 ); - return DrawStruct; + return DrawStruct; } /****************************************************************************/ -void WinEDA_ModuleEditFrame::Process_Special_Functions(wxCommandEvent& event) +void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) /****************************************************************************/ + /* Traite les selections d'outils et les commandes appelees du menu POPUP -*/ + */ { -int id = event.GetId(); -wxPoint pos; -wxClientDC dc(DrawPanel); + int id = event.GetId(); + wxPoint pos; + wxClientDC dc( DrawPanel ); - DrawPanel->CursorOff(&dc); - DrawPanel->PrepareGraphicContext(&dc); + DrawPanel->CursorOff( &dc ); + DrawPanel->PrepareGraphicContext( &dc ); - wxGetMousePosition(&pos.x, &pos.y); + wxGetMousePosition( &pos.x, &pos.y ); - pos.y += 20; + pos.y += 20; - switch ( id ) // Arret eventuel de la commande de d�placement en cours - { - case wxID_CUT: - case wxID_COPY: - case ID_TOOLBARH_PCB_SELECT_LAYER: - case ID_MODEDIT_PAD_SETTINGS: - case ID_PCB_USER_GRID_SETUP: - case ID_POPUP_PCB_ROTATE_TEXTEPCB: - case ID_POPUP_PCB_EDIT_TEXTEPCB: - case ID_POPUP_PCB_ROTATE_TEXTMODULE: - case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE: - case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE: - case ID_POPUP_PCB_EDIT_TEXTMODULE: - case ID_POPUP_PCB_IMPORT_PAD_SETTINGS: - case ID_POPUP_PCB_EXPORT_PAD_SETTINGS: - case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS: - case ID_POPUP_PCB_STOP_CURRENT_DRAWING: - case ID_POPUP_PCB_EDIT_EDGE: - case ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE: - case ID_POPUP_PCB_EDIT_WIDTH_ALL_EDGE: - case ID_POPUP_PCB_EDIT_LAYER_CURRENT_EDGE: - case ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE: - case ID_POPUP_PCB_ENTER_EDGE_WIDTH: - case ID_POPUP_DELETE_BLOCK: - case ID_POPUP_PLACE_BLOCK: - case ID_POPUP_ZOOM_BLOCK: - case ID_POPUP_MIRROR_Y_BLOCK: - case ID_POPUP_MIRROR_X_BLOCK: - case ID_POPUP_ROTATE_BLOCK: - case ID_POPUP_COPY_BLOCK: - break; + switch( id ) // Arret eventuel de la commande de d�placement en cours + { + case wxID_CUT: + case wxID_COPY: + case ID_TOOLBARH_PCB_SELECT_LAYER: + case ID_MODEDIT_PAD_SETTINGS: + case ID_PCB_USER_GRID_SETUP: + case ID_POPUP_PCB_ROTATE_TEXTEPCB: + case ID_POPUP_PCB_EDIT_TEXTEPCB: + case ID_POPUP_PCB_ROTATE_TEXTMODULE: + case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE: + case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE: + case ID_POPUP_PCB_EDIT_TEXTMODULE: + case ID_POPUP_PCB_IMPORT_PAD_SETTINGS: + case ID_POPUP_PCB_EXPORT_PAD_SETTINGS: + case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS: + case ID_POPUP_PCB_STOP_CURRENT_DRAWING: + case ID_POPUP_PCB_EDIT_EDGE: + case ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE: + case ID_POPUP_PCB_EDIT_WIDTH_ALL_EDGE: + case ID_POPUP_PCB_EDIT_LAYER_CURRENT_EDGE: + case ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE: + case ID_POPUP_PCB_ENTER_EDGE_WIDTH: + case ID_POPUP_DELETE_BLOCK: + case ID_POPUP_PLACE_BLOCK: + case ID_POPUP_ZOOM_BLOCK: + case ID_POPUP_MIRROR_Y_BLOCK: + case ID_POPUP_MIRROR_X_BLOCK: + case ID_POPUP_ROTATE_BLOCK: + case ID_POPUP_COPY_BLOCK: + break; - case ID_POPUP_CANCEL_CURRENT_COMMAND: - if( DrawPanel->ManageCurseur && - DrawPanel->ForceCloseManageCurseur ) - { - DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); - } - break; + case ID_POPUP_CANCEL_CURRENT_COMMAND: + if( DrawPanel->ManageCurseur + && DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); + } + break; - default: // Arret dea commande de d�placement en cours - if( DrawPanel->ManageCurseur && - DrawPanel->ForceCloseManageCurseur ) - { - DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); - } - SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); - break; - } + default: // Arret dea commande de d�placement en cours + if( DrawPanel->ManageCurseur + && DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); + } + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); + break; + } - switch ( id ) // Traitement des commandes - { - case ID_EXIT : - Close(TRUE); - break; + switch( id ) // Traitement des commandes + { + case ID_EXIT: + Close( TRUE ); + break; - case ID_LIBEDIT_SELECT_CURRENT_LIB: - Select_Active_Library(); - break; + case ID_LIBEDIT_SELECT_CURRENT_LIB: + Select_Active_Library(); + break; - case ID_LIBEDIT_DELETE_PART: - { - wxString Line; - Line = MakeFileName(g_RealLibDirBuffer, m_CurrentLib, LibExtBuffer); - Delete_Module_In_Library(Line); - } - break; + case ID_LIBEDIT_DELETE_PART: + { + wxString Line; + Line = MakeFileName( g_RealLibDirBuffer, m_CurrentLib, LibExtBuffer ); + Delete_Module_In_Library( Line ); + } + break; - case ID_MODEDIT_NEW_MODULE: - Clear_Pcb(&dc, TRUE); - GetScreen()->ClearUndoRedoList(); - GetScreen()->m_CurrentItem = NULL; - GetScreen()->m_Curseur = wxPoint(0,0); - Create_1_Module(& dc, wxEmptyString); - if ( m_Pcb->m_Modules ) m_Pcb->m_Modules->m_Flags = 0; - Zoom_Automatique(TRUE); - break; + case ID_MODEDIT_NEW_MODULE: + Clear_Pcb( &dc, TRUE ); + GetScreen()->ClearUndoRedoList(); + GetScreen()->SetCurItem( NULL ); + GetScreen()->m_Curseur = wxPoint( 0, 0 ); + Create_1_Module( &dc, wxEmptyString ); + if( m_Pcb->m_Modules ) + m_Pcb->m_Modules->m_Flags = 0; + Zoom_Automatique( TRUE ); + break; - case ID_MODEDIT_SAVE_LIBMODULE: - { - wxString Line; - Line = MakeFileName(g_RealLibDirBuffer, m_CurrentLib.GetData(), LibExtBuffer); - Save_1_Module(Line, m_Pcb->m_Modules, TRUE, TRUE); - GetScreen()->ClrModify(); - } - break; + case ID_MODEDIT_SAVE_LIBMODULE: + { + wxString Line; + Line = MakeFileName( g_RealLibDirBuffer, m_CurrentLib.GetData(), LibExtBuffer ); + Save_1_Module( Line, m_Pcb->m_Modules, TRUE, TRUE ); + GetScreen()->ClrModify(); + } + break; - case ID_MODEDIT_LOAD_MODULE_FROM_BOARD: - GetScreen()->ClearUndoRedoList(); - Load_Module_Module_From_BOARD(NULL); - GetScreen()->ClrModify(); - if ( m_Draw3DFrame ) - m_Draw3DFrame->NewDisplay(); - break; + case ID_MODEDIT_LOAD_MODULE_FROM_BOARD: + GetScreen()->ClearUndoRedoList(); + Load_Module_Module_From_BOARD( NULL ); + GetScreen()->ClrModify(); + if( m_Draw3DFrame ) + m_Draw3DFrame->NewDisplay(); + break; - case ID_MODEDIT_INSERT_MODULE_IN_BOARD: - case ID_MODEDIT_UPDATE_MODULE_IN_BOARD:{ - // update module in the current board, - // not just add it to the board with total disregard for the netlist... - WinEDA_PcbFrame * pcbframe = m_Parent->m_PcbFrame; - BOARD * mainpcb = pcbframe->m_Pcb; - MODULE * source_module = NULL; - MODULE * module_in_edit = m_Pcb->m_Modules; - // Search the old module (source) if exists - // Because this source could be deleted when editing the main board... - if ( module_in_edit->m_Link ) // this is not a new module ... - { - source_module = mainpcb->m_Modules; - for( ; source_module != NULL ; source_module = (MODULE *) source_module->Pnext ) - { - if( module_in_edit->m_Link == source_module->m_TimeStamp ) - break; - } - } - if ( (source_module == NULL) && id == (ID_MODEDIT_UPDATE_MODULE_IN_BOARD) ) // source not found - { - wxString msg; - msg.Printf( _("Unable to find the footprint source on the main board") ); - msg << _("\nCannot update the footprint"); - DisplayError(this, msg); - break; - } + case ID_MODEDIT_INSERT_MODULE_IN_BOARD: + case ID_MODEDIT_UPDATE_MODULE_IN_BOARD: + { + // update module in the current board, + // not just add it to the board with total disregard for the netlist... + WinEDA_PcbFrame* pcbframe = m_Parent->m_PcbFrame; + BOARD* mainpcb = pcbframe->m_Pcb; + MODULE* source_module = NULL; + MODULE* module_in_edit = m_Pcb->m_Modules; - if ( (source_module != NULL) && id == (ID_MODEDIT_INSERT_MODULE_IN_BOARD) ) // source not found - { - wxString msg; - msg.Printf( _("A footprint source was found on the main board") ); - msg << _("\nCannot insert this footprint"); - DisplayError(this, msg); - break; - } - // Create the "new" module - MODULE * newmodule = new MODULE(mainpcb); - newmodule->Copy(module_in_edit); - newmodule->m_Parent = mainpcb; // modifie par la copie - newmodule->m_Link = 0; - // Put the footprint in the main pcb linked list. - newmodule->Pnext = mainpcb->m_Modules; - mainpcb->m_Modules = newmodule; - newmodule->Pback = mainpcb; - if ( newmodule->Pnext ) newmodule->Pnext->Pback = newmodule; + // Search the old module (source) if exists + // Because this source could be deleted when editing the main board... + if( module_in_edit->m_Link ) // this is not a new module ... + { + source_module = mainpcb->m_Modules; + for( ; source_module != NULL; source_module = (MODULE*) source_module->Pnext ) + { + if( module_in_edit->m_Link == source_module->m_TimeStamp ) + break; + } + } + if( (source_module == NULL) && id == (ID_MODEDIT_UPDATE_MODULE_IN_BOARD) ) // source not found + { + wxString msg; + msg.Printf( _( "Unable to find the footprint source on the main board" ) ); + msg << _( "\nCannot update the footprint" ); + DisplayError( this, msg ); + break; + } - if ( source_module ) // this is an update command - { - // The new module replace the old module (pos, orient, ref, value and connexions are kept) - // and the source_module (old module) is deleted - newmodule = pcbframe->Exchange_Module(this, source_module, newmodule); - newmodule->m_TimeStamp = module_in_edit->m_Link; - } - else // This is an insert command - { - wxPoint cursor_pos = pcbframe->GetScreen()->m_Curseur; - pcbframe->GetScreen()->m_Curseur = wxPoint(0,0); - pcbframe->Place_Module(newmodule, NULL); - pcbframe->GetScreen()->m_Curseur = cursor_pos; - newmodule->m_TimeStamp = GetTimeStamp(); - } + if( (source_module != NULL) && id == (ID_MODEDIT_INSERT_MODULE_IN_BOARD) ) // source not found + { + wxString msg; + msg.Printf( _( "A footprint source was found on the main board" ) ); + msg << _( "\nCannot insert this footprint" ); + DisplayError( this, msg ); + break; + } - newmodule->m_Flags = 0; - GetScreen()->ClrModify(); - pcbframe->GetScreen()->m_CurrentItem = NULL; - mainpcb->m_Status_Pcb = 0; - } - break; - - case ID_LIBEDIT_IMPORT_PART: - GetScreen()->ClearUndoRedoList(); - GetScreen()->m_CurrentItem = NULL; - Clear_Pcb(&dc, TRUE); - GetScreen()->m_Curseur = wxPoint(0,0); - Import_Module(&dc); - if ( m_Pcb->m_Modules ) m_Pcb->m_Modules->m_Flags = 0; - GetScreen()->ClrModify(); - Zoom_Automatique(TRUE); - if ( m_Draw3DFrame ) - m_Draw3DFrame->NewDisplay(); - break; + // Create the "new" module + MODULE* newmodule = new MODULE( mainpcb ); + newmodule->Copy( module_in_edit ); + newmodule->m_Parent = mainpcb; // modifie par la copie + newmodule->m_Link = 0; - case ID_LIBEDIT_EXPORT_PART: - if ( m_Pcb->m_Modules ) - Export_Module(m_Pcb->m_Modules, FALSE); - break; + // Put the footprint in the main pcb linked list. + newmodule->Pnext = mainpcb->m_Modules; + mainpcb->m_Modules = newmodule; + newmodule->Pback = mainpcb; + if( newmodule->Pnext ) + newmodule->Pnext->Pback = newmodule; - case ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART: - if ( m_Pcb->m_Modules ) - Export_Module(m_Pcb->m_Modules, TRUE); - break; + if( source_module ) // this is an update command + { + // The new module replace the old module (pos, orient, ref, value and connexions are kept) + // and the source_module (old module) is deleted + newmodule = pcbframe->Exchange_Module( this, source_module, newmodule ); + newmodule->m_TimeStamp = module_in_edit->m_Link; + } + else // This is an insert command + { + wxPoint cursor_pos = pcbframe->GetScreen()->m_Curseur; + pcbframe->GetScreen()->m_Curseur = wxPoint( 0, 0 ); + pcbframe->Place_Module( newmodule, NULL ); + pcbframe->GetScreen()->m_Curseur = cursor_pos; + newmodule->m_TimeStamp = GetTimeStamp(); + } - case ID_MODEDIT_SHEET_SET: - break; + newmodule->m_Flags = 0; + GetScreen()->ClrModify(); + pcbframe->GetScreen()->SetCurItem( NULL ); + mainpcb->m_Status_Pcb = 0; + } + break; - case ID_MODEDIT_LOAD_MODULE:{ - GetScreen()->ClearUndoRedoList(); - GetScreen()->m_CurrentItem = NULL; - Clear_Pcb(&dc, TRUE); - GetScreen()->m_Curseur = wxPoint(0,0); - Load_Module_From_Library(m_CurrentLib, &dc); - if ( m_Pcb->m_Modules ) m_Pcb->m_Modules->m_Flags = 0; - //if either m_Reference or m_Value are gone, reinstate them - - //otherwise it becomes hard to see what you are working with in the layout! - if(m_Pcb && m_Pcb->m_Modules){ - TEXTE_MODULE* ref = m_Pcb->m_Modules->m_Reference; - TEXTE_MODULE* val = m_Pcb->m_Modules->m_Value; - if(val && ref){ - ref->m_NoShow = 0; - val->m_NoShow = 0; - ref->m_Type = 0; - val->m_Type = 1; - if(ref->m_Text.Length() == 0) ref->m_Text = L"Ref**"; - if(val->m_Text.Length() == 0) val->m_Text = L"Val**"; - } - } - GetScreen()->ClrModify(); - Zoom_Automatique(TRUE); - if ( m_Draw3DFrame ) - m_Draw3DFrame->NewDisplay(); - break; - } + case ID_LIBEDIT_IMPORT_PART: + GetScreen()->ClearUndoRedoList(); + GetScreen()->SetCurItem( NULL ); + Clear_Pcb( &dc, TRUE ); + GetScreen()->m_Curseur = wxPoint( 0, 0 ); + Import_Module( &dc ); + if( m_Pcb->m_Modules ) + m_Pcb->m_Modules->m_Flags = 0; + GetScreen()->ClrModify(); + Zoom_Automatique( TRUE ); + if( m_Draw3DFrame ) + m_Draw3DFrame->NewDisplay(); + break; - case ID_MODEDIT_PAD_SETTINGS: - InstallPadOptionsFrame(NULL, NULL, wxPoint(-1, -1) ); - break; + case ID_LIBEDIT_EXPORT_PART: + if( m_Pcb->m_Modules ) + Export_Module( m_Pcb->m_Modules, FALSE ); + break; - case ID_MODEDIT_CHECK: - break; + case ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART: + if( m_Pcb->m_Modules ) + Export_Module( m_Pcb->m_Modules, TRUE ); + break; - case ID_MODEDIT_EDIT_MODULE_PROPERTIES: - if ( m_Pcb->m_Modules ) - { - GetScreen()->m_CurrentItem = m_Pcb->m_Modules; - InstallModuleOptionsFrame((MODULE *)GetScreen()->m_CurrentItem, - &dc, pos); - GetScreen()->m_CurrentItem->m_Flags = 0; - } - break; + case ID_MODEDIT_SHEET_SET: + break; - case ID_MODEDIT_ADD_PAD: - if ( m_Pcb->m_Modules ) - SetToolID( id, wxCURSOR_PENCIL, _("Add Pad")); - else - { - SetToolID( id, wxCURSOR_ARROW, _("Pad Settings")); - InstallPadOptionsFrame(NULL, NULL, wxPoint(-1, -1) ); - SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); - } - break; + case ID_MODEDIT_LOAD_MODULE: + { + GetScreen()->ClearUndoRedoList(); + GetScreen()->SetCurItem( NULL ); + Clear_Pcb( &dc, TRUE ); + GetScreen()->m_Curseur = wxPoint( 0, 0 ); + Load_Module_From_Library( m_CurrentLib, &dc ); + if( m_Pcb->m_Modules ) + m_Pcb->m_Modules->m_Flags = 0; - case ID_LINE_COMMENT_BUTT: - case ID_PCB_ARC_BUTT: - case ID_PCB_CIRCLE_BUTT: - case ID_TEXT_COMMENT_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _("Add Drawing")); - break; + //if either m_Reference or m_Value are gone, reinstate them - + //otherwise it becomes hard to see what you are working with in the layout! + if( m_Pcb && m_Pcb->m_Modules ) + { + TEXTE_MODULE* ref = m_Pcb->m_Modules->m_Reference; + TEXTE_MODULE* val = m_Pcb->m_Modules->m_Value; + if( val && ref ) + { + ref->m_NoShow = 0; + val->m_NoShow = 0; + ref->m_Type = 0; + val->m_Type = 1; + if( ref->m_Text.Length() == 0 ) + ref->m_Text = L"Ref**"; + if( val->m_Text.Length() == 0 ) + val->m_Text = L"Val**"; + } + } + GetScreen()->ClrModify(); + Zoom_Automatique( TRUE ); + if( m_Draw3DFrame ) + m_Draw3DFrame->NewDisplay(); + break; + } - case ID_MODEDIT_PLACE_ANCHOR: - SetToolID( id, wxCURSOR_PENCIL, _("Place anchor")); - break; + case ID_MODEDIT_PAD_SETTINGS: + InstallPadOptionsFrame( NULL, NULL, wxPoint( -1, -1 ) ); + break; - case ID_NO_SELECT_BUTT: - SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); - break; + case ID_MODEDIT_CHECK: + break; - case ID_POPUP_CLOSE_CURRENT_TOOL: - break; + case ID_MODEDIT_EDIT_MODULE_PROPERTIES: + if( m_Pcb->m_Modules ) + { + GetScreen()->SetCurItem( m_Pcb->m_Modules ); + InstallModuleOptionsFrame( (MODULE*) GetScreen()->GetCurItem(), + &dc, pos ); + GetScreen()->GetCurItem()->m_Flags = 0; + } + break; - case ID_POPUP_CANCEL_CURRENT_COMMAND: - break; + case ID_MODEDIT_ADD_PAD: + if( m_Pcb->m_Modules ) + SetToolID( id, wxCURSOR_PENCIL, _( "Add Pad" ) ); + else + { + SetToolID( id, wxCURSOR_ARROW, _( "Pad Settings" ) ); + InstallPadOptionsFrame( NULL, NULL, wxPoint( -1, -1 ) ); + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); + } + break; - case ID_MODEDIT_DELETE_ITEM_BUTT: - SetToolID( id, wxCURSOR_BULLSEYE, _("Delete item")); - break; + case ID_LINE_COMMENT_BUTT: + case ID_PCB_ARC_BUTT: + case ID_PCB_CIRCLE_BUTT: + case ID_TEXT_COMMENT_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Add Drawing" ) ); + break; - case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE: - DrawPanel->MouseToCursorSchema(); - Rotate_Module(&dc, (MODULE*)GetScreen()->m_CurrentItem, 900, TRUE); - break; + case ID_MODEDIT_PLACE_ANCHOR: + SetToolID( id, wxCURSOR_PENCIL, _( "Place anchor" ) ); + break; - case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE: - DrawPanel->MouseToCursorSchema(); - Rotate_Module(&dc, (MODULE*)GetScreen()->m_CurrentItem, -900, TRUE); - break; + case ID_NO_SELECT_BUTT: + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); + break; - case ID_POPUP_PCB_EDIT_MODULE: - InstallModuleOptionsFrame((MODULE *)GetScreen()->m_CurrentItem, - &dc, pos); - GetScreen()->m_CurrentItem->m_Flags = 0; - DrawPanel->MouseToCursorSchema(); - break; + case ID_POPUP_CLOSE_CURRENT_TOOL: + break; - case ID_POPUP_PCB_MOVE_PAD_REQUEST: - DrawPanel->MouseToCursorSchema(); - StartMovePad((D_PAD *)GetScreen()->m_CurrentItem, &dc); - break; + case ID_POPUP_CANCEL_CURRENT_COMMAND: + break; - case ID_POPUP_PCB_EDIT_PAD: - InstallPadOptionsFrame((D_PAD *)GetScreen()->m_CurrentItem, - &dc, pos); - DrawPanel->MouseToCursorSchema(); - break; + case ID_MODEDIT_DELETE_ITEM_BUTT: + SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) ); + break; - case ID_POPUP_PCB_DELETE_PAD: - SaveCopyInUndoList(m_Pcb->m_Modules); - DeletePad((D_PAD *)GetScreen()->m_CurrentItem, &dc); - GetScreen()->m_CurrentItem = NULL; - DrawPanel->MouseToCursorSchema(); - break; + case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE: + DrawPanel->MouseToCursorSchema(); + Rotate_Module( &dc, (MODULE*) GetScreen()->GetCurItem(), 900, TRUE ); + break; - case ID_POPUP_PCB_IMPORT_PAD_SETTINGS: - SaveCopyInUndoList(m_Pcb->m_Modules); - DrawPanel->MouseToCursorSchema(); - Import_Pad_Settings((D_PAD *)GetScreen()->m_CurrentItem, &dc); - break; + case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE: + DrawPanel->MouseToCursorSchema(); + Rotate_Module( &dc, (MODULE*) GetScreen()->GetCurItem(), -900, TRUE ); + break; - case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS: - SaveCopyInUndoList(m_Pcb->m_Modules); - Global_Import_Pad_Settings((D_PAD *)GetScreen()->m_CurrentItem, &dc); - DrawPanel->MouseToCursorSchema(); - break; + case ID_POPUP_PCB_EDIT_MODULE: + InstallModuleOptionsFrame( (MODULE*) GetScreen()->GetCurItem(), + &dc, pos ); + GetScreen()->GetCurItem()->m_Flags = 0; + DrawPanel->MouseToCursorSchema(); + break; - case ID_POPUP_PCB_EXPORT_PAD_SETTINGS: - DrawPanel->MouseToCursorSchema(); - Export_Pad_Settings((D_PAD *)GetScreen()->m_CurrentItem); - break; + case ID_POPUP_PCB_MOVE_PAD_REQUEST: + DrawPanel->MouseToCursorSchema(); + StartMovePad( (D_PAD*) GetScreen()->GetCurItem(), &dc ); + break; - case ID_POPUP_PCB_EDIT_TEXTMODULE: - InstallTextModOptionsFrame((TEXTE_MODULE *)GetScreen()->m_CurrentItem, - &dc, pos); - DrawPanel->MouseToCursorSchema(); - break; + case ID_POPUP_PCB_EDIT_PAD: + InstallPadOptionsFrame( (D_PAD*) GetScreen()->GetCurItem(), + &dc, pos ); + DrawPanel->MouseToCursorSchema(); + break; - case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST: - DrawPanel->MouseToCursorSchema(); - StartMoveTexteModule( (TEXTE_MODULE *) GetScreen()->m_CurrentItem, - &dc); - break; + case ID_POPUP_PCB_DELETE_PAD: + SaveCopyInUndoList( m_Pcb->m_Modules ); + DeletePad( (D_PAD*) GetScreen()->GetCurItem(), &dc ); + GetScreen()->SetCurItem( NULL ); + DrawPanel->MouseToCursorSchema(); + break; - case ID_POPUP_PCB_ROTATE_TEXTMODULE: - RotateTextModule((TEXTE_MODULE *)GetScreen()->m_CurrentItem, - &dc); - DrawPanel->MouseToCursorSchema(); - break; + case ID_POPUP_PCB_IMPORT_PAD_SETTINGS: + SaveCopyInUndoList( m_Pcb->m_Modules ); + DrawPanel->MouseToCursorSchema(); + Import_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem(), &dc ); + break; - case ID_POPUP_PCB_DELETE_TEXTMODULE: - SaveCopyInUndoList(m_Pcb->m_Modules); - DeleteTextModule((TEXTE_MODULE *)GetScreen()->m_CurrentItem, - &dc); - GetScreen()->m_CurrentItem = NULL; - DrawPanel->MouseToCursorSchema(); - break; + case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS: + SaveCopyInUndoList( m_Pcb->m_Modules ); + Global_Import_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem(), &dc ); + DrawPanel->MouseToCursorSchema(); + break; - case ID_POPUP_PCB_MOVE_EDGE: - Start_Move_EdgeMod((EDGE_MODULE *)GetScreen()->m_CurrentItem, &dc); - DrawPanel->MouseToCursorSchema(); - break; + case ID_POPUP_PCB_EXPORT_PAD_SETTINGS: + DrawPanel->MouseToCursorSchema(); + Export_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem() ); + break; - case ID_POPUP_PCB_STOP_CURRENT_DRAWING: - DrawPanel->MouseToCursorSchema(); - if ( (GetScreen()->m_CurrentItem->m_Flags & IS_NEW) ) - { - End_Edge_Module((EDGE_MODULE *) GetScreen()->m_CurrentItem, &dc); - GetScreen()->m_CurrentItem = NULL; - } - break; + case ID_POPUP_PCB_EDIT_TEXTMODULE: + InstallTextModOptionsFrame( (TEXTE_MODULE*) GetScreen()->GetCurItem(), + &dc, pos ); + DrawPanel->MouseToCursorSchema(); + break; - case ID_POPUP_PCB_ENTER_EDGE_WIDTH: - { - EDGE_MODULE * edge = NULL; - if ( GetScreen()->m_CurrentItem && - ( GetScreen()->m_CurrentItem->m_Flags & IS_NEW) && - (GetScreen()->m_CurrentItem->m_StructType == TYPEEDGEMODULE) ) - { - edge = (EDGE_MODULE *) GetScreen()->m_CurrentItem; - } - Enter_Edge_Width(edge, &dc); - DrawPanel->MouseToCursorSchema(); - } - break; + case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST: + DrawPanel->MouseToCursorSchema(); + StartMoveTexteModule( (TEXTE_MODULE*) GetScreen()->GetCurItem(), + &dc ); + break; - case ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE: - DrawPanel->MouseToCursorSchema(); - Edit_Edge_Width((EDGE_MODULE *) GetScreen()->m_CurrentItem, &dc); - break; + case ID_POPUP_PCB_ROTATE_TEXTMODULE: + RotateTextModule( (TEXTE_MODULE*) GetScreen()->GetCurItem(), + &dc ); + DrawPanel->MouseToCursorSchema(); + break; - case ID_POPUP_PCB_EDIT_WIDTH_ALL_EDGE: - DrawPanel->MouseToCursorSchema(); - Edit_Edge_Width(NULL, &dc); - break; + case ID_POPUP_PCB_DELETE_TEXTMODULE: + SaveCopyInUndoList( m_Pcb->m_Modules ); + DeleteTextModule( (TEXTE_MODULE*) GetScreen()->GetCurItem(), + &dc ); + GetScreen()->SetCurItem( NULL ); + DrawPanel->MouseToCursorSchema(); + break; - case ID_POPUP_PCB_EDIT_LAYER_CURRENT_EDGE: - DrawPanel->MouseToCursorSchema(); - Edit_Edge_Layer((EDGE_MODULE *) GetScreen()->m_CurrentItem, &dc); - break; + case ID_POPUP_PCB_MOVE_EDGE: + Start_Move_EdgeMod( (EDGE_MODULE*) GetScreen()->GetCurItem(), &dc ); + DrawPanel->MouseToCursorSchema(); + break; - case ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE: - DrawPanel->MouseToCursorSchema(); - Edit_Edge_Layer(NULL, &dc); - break; + case ID_POPUP_PCB_STOP_CURRENT_DRAWING: + DrawPanel->MouseToCursorSchema(); + if( (GetScreen()->GetCurItem()->m_Flags & IS_NEW) ) + { + End_Edge_Module( (EDGE_MODULE*) GetScreen()->GetCurItem(), &dc ); + GetScreen()->SetCurItem( NULL ); + } + break; - case ID_POPUP_PCB_DELETE_EDGE: - SaveCopyInUndoList(m_Pcb->m_Modules); - DrawPanel->MouseToCursorSchema(); - RemoveStruct(GetScreen()->m_CurrentItem, &dc); - GetScreen()->m_CurrentItem = NULL; - break; + case ID_POPUP_PCB_ENTER_EDGE_WIDTH: + { + EDGE_MODULE* edge = NULL; + if( GetScreen()->GetCurItem() + && ( GetScreen()->GetCurItem()->m_Flags & IS_NEW) + && (GetScreen()->GetCurItem()->m_StructType == TYPEEDGEMODULE) ) + { + edge = (EDGE_MODULE*) GetScreen()->GetCurItem(); + } + Enter_Edge_Width( edge, &dc ); + DrawPanel->MouseToCursorSchema(); + } + break; - case ID_MODEDIT_MODULE_ROTATE: - case ID_MODEDIT_MODULE_MIRROR: - case ID_MODEDIT_MODULE_SCALE: - case ID_MODEDIT_MODULE_SCALEX: - case ID_MODEDIT_MODULE_SCALEY: - SaveCopyInUndoList(m_Pcb->m_Modules); - Transform( (MODULE*) GetScreen()->m_CurrentItem, &dc, id); - break; + case ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE: + DrawPanel->MouseToCursorSchema(); + Edit_Edge_Width( (EDGE_MODULE*) GetScreen()->GetCurItem(), &dc ); + break; - case ID_PCB_DRAWINGS_WIDTHS_SETUP: - InstallOptionsFrame(pos); - break; + case ID_POPUP_PCB_EDIT_WIDTH_ALL_EDGE: + DrawPanel->MouseToCursorSchema(); + Edit_Edge_Width( NULL, &dc ); + break; - case ID_PCB_PAD_SETUP: - InstallPadOptionsFrame((D_PAD *)GetScreen()->m_CurrentItem, - &dc, pos); - break; + case ID_POPUP_PCB_EDIT_LAYER_CURRENT_EDGE: + DrawPanel->MouseToCursorSchema(); + Edit_Edge_Layer( (EDGE_MODULE*) GetScreen()->GetCurItem(), &dc ); + break; - case ID_PCB_USER_GRID_SETUP: - InstallGridFrame(pos); - break; - - case ID_MODEDIT_UNDO: - GetComponentFromUndoList(); - DrawPanel->Refresh(TRUE); - break; + case ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE: + DrawPanel->MouseToCursorSchema(); + Edit_Edge_Layer( NULL, &dc ); + break; - case ID_MODEDIT_REDO: - GetComponentFromRedoList(); - DrawPanel->Refresh(TRUE); - break; + case ID_POPUP_PCB_DELETE_EDGE: + SaveCopyInUndoList( m_Pcb->m_Modules ); + DrawPanel->MouseToCursorSchema(); + RemoveStruct( GetScreen()->GetCurItem(), &dc ); + GetScreen()->SetCurItem( NULL ); + break; - case ID_POPUP_PLACE_BLOCK: - GetScreen()->BlockLocate.m_Command = BLOCK_MOVE; - DrawPanel->m_AutoPAN_Request = FALSE; - HandleBlockPlace(&dc); - break; + case ID_MODEDIT_MODULE_ROTATE: + case ID_MODEDIT_MODULE_MIRROR: + case ID_MODEDIT_MODULE_SCALE: + case ID_MODEDIT_MODULE_SCALEX: + case ID_MODEDIT_MODULE_SCALEY: + SaveCopyInUndoList( m_Pcb->m_Modules ); + Transform( (MODULE*) GetScreen()->GetCurItem(), &dc, id ); + break; - case ID_POPUP_COPY_BLOCK: - GetScreen()->BlockLocate.m_Command = BLOCK_COPY; - m_CurrentScreen->BlockLocate.SetMessageBlock(this); - DrawPanel->m_AutoPAN_Request = FALSE; - HandleBlockPlace(&dc); - break; + case ID_PCB_DRAWINGS_WIDTHS_SETUP: + InstallOptionsFrame( pos ); + break; - case ID_POPUP_ZOOM_BLOCK: - GetScreen()->BlockLocate.m_Command = BLOCK_ZOOM; - m_CurrentScreen->BlockLocate.SetMessageBlock(this); - m_CurrentScreen->BlockLocate.SetMessageBlock(this); - HandleBlockEnd(&dc); - break; + case ID_PCB_PAD_SETUP: + InstallPadOptionsFrame( (D_PAD*) GetScreen()->GetCurItem(), + &dc, pos ); + break; - case ID_POPUP_DELETE_BLOCK: - GetScreen()->BlockLocate.m_Command = BLOCK_DELETE; - m_CurrentScreen->BlockLocate.SetMessageBlock(this); - HandleBlockEnd(&dc); - break; + case ID_PCB_USER_GRID_SETUP: + InstallGridFrame( pos ); + break; - case ID_POPUP_ROTATE_BLOCK: - GetScreen()->BlockLocate.m_Command = BLOCK_ROTATE; - m_CurrentScreen->BlockLocate.SetMessageBlock(this); - HandleBlockEnd(&dc); - break; + case ID_MODEDIT_UNDO: + GetComponentFromUndoList(); + DrawPanel->Refresh( TRUE ); + break; - case ID_POPUP_MIRROR_X_BLOCK: - case ID_POPUP_MIRROR_Y_BLOCK: - case ID_POPUP_INVERT_BLOCK: - GetScreen()->BlockLocate.m_Command = BLOCK_INVERT; - m_CurrentScreen->BlockLocate.SetMessageBlock(this); - HandleBlockEnd(&dc); - break; - default: - DisplayError(this, - wxT("WinEDA_ModuleEditFrame::Process_Special_Functions error")); - break; - } + case ID_MODEDIT_REDO: + GetComponentFromRedoList(); + DrawPanel->Refresh( TRUE ); + break; - SetToolbars(); - DrawPanel->CursorOn(&dc); + case ID_POPUP_PLACE_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_MOVE; + DrawPanel->m_AutoPAN_Request = FALSE; + HandleBlockPlace( &dc ); + break; + + case ID_POPUP_COPY_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_COPY; + m_CurrentScreen->BlockLocate.SetMessageBlock( this ); + DrawPanel->m_AutoPAN_Request = FALSE; + HandleBlockPlace( &dc ); + break; + + case ID_POPUP_ZOOM_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_ZOOM; + m_CurrentScreen->BlockLocate.SetMessageBlock( this ); + m_CurrentScreen->BlockLocate.SetMessageBlock( this ); + HandleBlockEnd( &dc ); + break; + + case ID_POPUP_DELETE_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_DELETE; + m_CurrentScreen->BlockLocate.SetMessageBlock( this ); + HandleBlockEnd( &dc ); + break; + + case ID_POPUP_ROTATE_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_ROTATE; + m_CurrentScreen->BlockLocate.SetMessageBlock( this ); + HandleBlockEnd( &dc ); + break; + + case ID_POPUP_MIRROR_X_BLOCK: + case ID_POPUP_MIRROR_Y_BLOCK: + case ID_POPUP_INVERT_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_INVERT; + m_CurrentScreen->BlockLocate.SetMessageBlock( this ); + HandleBlockEnd( &dc ); + break; + + default: + DisplayError( this, + wxT( "WinEDA_ModuleEditFrame::Process_Special_Functions error" ) ); + break; + } + + SetToolbars(); + DrawPanel->CursorOn( &dc ); } /******************************************************************************/ -void WinEDA_ModuleEditFrame::Transform(MODULE* module, wxDC * DC, int transform) +void WinEDA_ModuleEditFrame::Transform( MODULE* module, wxDC* DC, int transform ) /******************************************************************************/ + /* Execute les transformations de la repr�sentation des modules. - le module, apres transformation est toujours en position de reference: - position 0,0 - orientation 0, cot� composant. -*/ + * le module, apres transformation est toujours en position de reference: + * position 0,0 + * orientation 0, cot� composant. + */ { -D_PAD * pad = module->m_Pads; -EDA_BaseStruct * PtStruct = module->m_Drawings; -TEXTE_MODULE * textmod; -EDGE_MODULE* edgemod; -int angle = 900; // NECESSAIREMENT +- 900 (+- 90 degres) ) + D_PAD* pad = module->m_Pads; + EDA_BaseStruct* PtStruct = module->m_Drawings; + TEXTE_MODULE* textmod; + EDGE_MODULE* edgemod; + int angle = 900; // NECESSAIREMENT +- 900 (+- 90 degres) ) - switch ( transform ) - { - case ID_MODEDIT_MODULE_ROTATE: - module->SetOrientation(angle); + switch( transform ) + { + case ID_MODEDIT_MODULE_ROTATE: + module->SetOrientation( angle ); - for (; pad != NULL; pad = (D_PAD*) pad->Pnext ) - { - pad->m_Pos0 = pad->m_Pos; - pad->m_Orient -= angle; - RotatePoint(&pad->m_Offset.x, &pad->m_Offset.y, angle); - EXCHG(pad->m_Size.x, pad->m_Size.y); - RotatePoint(&pad->m_DeltaSize.x, &pad->m_DeltaSize.y, - angle); - } + for( ; pad != NULL; pad = (D_PAD*) pad->Pnext ) + { + pad->m_Pos0 = pad->m_Pos; + pad->m_Orient -= angle; + RotatePoint( &pad->m_Offset.x, &pad->m_Offset.y, angle ); + EXCHG( pad->m_Size.x, pad->m_Size.y ); + RotatePoint( &pad->m_DeltaSize.x, &pad->m_DeltaSize.y, -angle ); + } - module->m_Reference->m_Pos0 = module->m_Reference->m_Pos; - module->m_Reference->m_Orient += angle; - if ( module->m_Reference->m_Orient >= 1800 ) - module->m_Reference->m_Orient -= 1800; - module->m_Value->m_Pos0 = module->m_Value->m_Pos; - module->m_Value->m_Orient += angle; - if ( module->m_Value->m_Orient >= 1800 ) - module->m_Value->m_Orient -= 1800; + module->m_Reference->m_Pos0 = module->m_Reference->m_Pos; + module->m_Reference->m_Orient += angle; + if( module->m_Reference->m_Orient >= 1800 ) + module->m_Reference->m_Orient -= 1800; + module->m_Value->m_Pos0 = module->m_Value->m_Pos; + module->m_Value->m_Orient += angle; + if( module->m_Value->m_Orient >= 1800 ) + module->m_Value->m_Orient -= 1800; - /* Rectification des contours et textes de l'empreinte : */ - for(; PtStruct != NULL; PtStruct = PtStruct->Pnext ) - { - if( PtStruct->m_StructType == TYPEEDGEMODULE ) - { - edgemod = (EDGE_MODULE*) PtStruct ; - edgemod->m_Start0 = edgemod->m_Start; - edgemod->m_End0 = edgemod->m_End; - } - if( PtStruct->m_StructType == TYPETEXTEMODULE ) - { - /* deplacement des inscriptions : */ - textmod = (TEXTE_MODULE*) PtStruct; - textmod->m_Pos0 = textmod->m_Pos; - } - } + /* Rectification des contours et textes de l'empreinte : */ + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if( PtStruct->m_StructType == TYPEEDGEMODULE ) + { + edgemod = (EDGE_MODULE*) PtStruct; + edgemod->m_Start0 = edgemod->m_Start; + edgemod->m_End0 = edgemod->m_End; + } + if( PtStruct->m_StructType == TYPETEXTEMODULE ) + { + /* deplacement des inscriptions : */ + textmod = (TEXTE_MODULE*) PtStruct; + textmod->m_Pos0 = textmod->m_Pos; + } + } - module->m_Orient = 0; - break; + module->m_Orient = 0; + break; - case ID_MODEDIT_MODULE_MIRROR: - for ( ; pad != NULL; pad = (D_PAD*) pad->Pnext ) - { - pad->m_Pos.y = -pad->m_Pos.y; - pad->m_Pos0.y = -pad->m_Pos0.y; - pad->m_Offset.y = -pad->m_Offset.y; - pad->m_DeltaSize.y = -pad->m_DeltaSize.y; - if(pad->m_Orient) pad->m_Orient = 3600 - pad->m_Orient; - } + case ID_MODEDIT_MODULE_MIRROR: + for( ; pad != NULL; pad = (D_PAD*) pad->Pnext ) + { + pad->m_Pos.y = -pad->m_Pos.y; + pad->m_Pos0.y = -pad->m_Pos0.y; + pad->m_Offset.y = -pad->m_Offset.y; + pad->m_DeltaSize.y = -pad->m_DeltaSize.y; + if( pad->m_Orient ) + pad->m_Orient = 3600 - pad->m_Orient; + } - /* Inversion miroir de la Reference */ - textmod = module->m_Reference; - textmod->m_Pos.y = -textmod->m_Pos.y; - textmod->m_Pos0.y = textmod->m_Pos0.y; - if(textmod->m_Orient) textmod->m_Orient = 3600 - textmod->m_Orient; + /* Inversion miroir de la Reference */ + textmod = module->m_Reference; + textmod->m_Pos.y = -textmod->m_Pos.y; + textmod->m_Pos0.y = textmod->m_Pos0.y; + if( textmod->m_Orient ) + textmod->m_Orient = 3600 - textmod->m_Orient; - /* Inversion miroir de la Valeur */ - textmod = module->m_Value; - textmod->m_Pos.y = -textmod->m_Pos.y; - textmod->m_Pos0.y = textmod->m_Pos0.y; - if(textmod->m_Orient) textmod->m_Orient = 3600 - textmod->m_Orient; + /* Inversion miroir de la Valeur */ + textmod = module->m_Value; + textmod->m_Pos.y = -textmod->m_Pos.y; + textmod->m_Pos0.y = textmod->m_Pos0.y; + if( textmod->m_Orient ) + textmod->m_Orient = 3600 - textmod->m_Orient; - /* Inversion miroir des dessins de l'empreinte : */ - PtStruct = module->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext) - { - switch( PtStruct->m_StructType) - { - case TYPEEDGEMODULE: - edgemod = (EDGE_MODULE *) PtStruct; - edgemod->m_Start.y = -edgemod->m_Start.y ; - edgemod->m_End.y = -edgemod->m_End.y; - /* inversion des coords locales */ - edgemod->m_Start0.y = -edgemod->m_Start0.y; - edgemod->m_End0.y = -edgemod->m_End0.y; - break; + /* Inversion miroir des dessins de l'empreinte : */ + PtStruct = module->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEEDGEMODULE: + edgemod = (EDGE_MODULE*) PtStruct; + edgemod->m_Start.y = -edgemod->m_Start.y; + edgemod->m_End.y = -edgemod->m_End.y; + /* inversion des coords locales */ + edgemod->m_Start0.y = -edgemod->m_Start0.y; + edgemod->m_End0.y = -edgemod->m_End0.y; + break; - case TYPETEXTEMODULE: - /* Inversion miroir de la position et mise en miroir : */ - textmod = (TEXTE_MODULE*)PtStruct; - textmod->m_Pos.y = -textmod->m_Pos.y; - textmod->m_Pos0.y = textmod->m_Pos0.y; - if(textmod->m_Orient) - textmod->m_Orient = 3600 - textmod->m_Orient; - break; + case TYPETEXTEMODULE: + /* Inversion miroir de la position et mise en miroir : */ + textmod = (TEXTE_MODULE*) PtStruct; + textmod->m_Pos.y = -textmod->m_Pos.y; + textmod->m_Pos0.y = textmod->m_Pos0.y; + if( textmod->m_Orient ) + textmod->m_Orient = 3600 - textmod->m_Orient; + break; - default: DisplayError(this, wxT("Type Draw Indefini")); - break; - } - } - break; + default: + DisplayError( this, wxT( "Type Draw Indefini" ) ); + break; + } + } - case ID_MODEDIT_MODULE_SCALE: - case ID_MODEDIT_MODULE_SCALEX: - case ID_MODEDIT_MODULE_SCALEY: - DisplayInfo(this, wxT("Not availlable")); - break; - } - module->Set_Rectangle_Encadrement(); - DrawPanel->ReDraw(DC); + break; + + case ID_MODEDIT_MODULE_SCALE: + case ID_MODEDIT_MODULE_SCALEX: + case ID_MODEDIT_MODULE_SCALEY: + DisplayInfo( this, wxT( "Not availlable" ) ); + break; + } + + module->Set_Rectangle_Encadrement(); + DrawPanel->ReDraw( DC ); } diff --git a/pcbnew/modedit_onclick.cpp b/pcbnew/modedit_onclick.cpp index ba6f746b99..38c0d06ac9 100644 --- a/pcbnew/modedit_onclick.cpp +++ b/pcbnew/modedit_onclick.cpp @@ -1,6 +1,6 @@ - /************************/ - /* modedit_onclick.cpp */ - /************************/ +/************************/ +/* modedit_onclick.cpp */ +/************************/ #ifdef __GNUG__ #pragma implementation @@ -27,406 +27,414 @@ #include "Select_Layer_Pair.xpm" /*************************************************************************/ -void WinEDA_ModuleEditFrame::OnLeftClick(wxDC * DC, const wxPoint& MousePos) +void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) /*************************************************************************/ + /* Traite les commandes declench�e par le bouton gauche de la souris, - quand un outil est deja selectionn� -*/ + * quand un outil est deja selectionn� + */ { -EDA_BaseStruct * DrawStruct = m_CurrentScreen->m_CurrentItem; + EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem(); - DrawPanel->CursorOff(DC); - if ( m_ID_current_state == 0 ) - { - if ( DrawStruct && DrawStruct->m_Flags ) // Commande "POPUP" en cours - { - switch (DrawStruct->m_StructType ) - { - case TYPETEXTEMODULE: - SaveCopyInUndoList(m_Pcb->m_Modules); - PlaceTexteModule( (TEXTE_MODULE *) DrawStruct, DC); - break; + DrawPanel->CursorOff( DC ); + if( m_ID_current_state == 0 ) + { + if( DrawStruct && DrawStruct->m_Flags ) // Commande "POPUP" en cours + { + switch( DrawStruct->m_StructType ) + { + case TYPETEXTEMODULE: + SaveCopyInUndoList( m_Pcb->m_Modules ); + PlaceTexteModule( (TEXTE_MODULE*) DrawStruct, DC ); + break; - case TYPEEDGEMODULE: - SaveCopyInUndoList(m_Pcb->m_Modules); - Place_EdgeMod( (EDGE_MODULE *) DrawStruct, DC); - break; + case TYPEEDGEMODULE: + SaveCopyInUndoList( m_Pcb->m_Modules ); + Place_EdgeMod( (EDGE_MODULE*) DrawStruct, DC ); + break; - case TYPEPAD: - PlacePad((D_PAD *)DrawStruct, DC); - break; + case TYPEPAD: + PlacePad( (D_PAD*) DrawStruct, DC ); + break; - default: - { - wxString msg; - msg.Printf( -wxT("WinEDA_ModEditFrame::ProcessCommand err: m_Flags != 0\nStruct @%p, type %d m_Flag %X") -, DrawStruct, DrawStruct->m_StructType, DrawStruct->m_Flags); - DisplayError(this, msg); - DrawStruct->m_Flags = 0; - break; - } - } - } - } + default: + { + wxString msg; + msg.Printf( + wxT( + "WinEDA_ModEditFrame::ProcessCommand err: m_Flags != 0\nStruct @%p, type %d m_Flag %X" ), + DrawStruct, DrawStruct->m_StructType, DrawStruct->m_Flags ); + DisplayError( this, msg ); + DrawStruct->m_Flags = 0; + break; + } + } + } + } - DrawStruct = m_CurrentScreen->m_CurrentItem; - if ( ! DrawStruct || (DrawStruct->m_Flags == 0) ) - { - m_CurrentScreen->m_CurrentItem = DrawStruct = ModeditLocateAndDisplay(); - } + DrawStruct = m_CurrentScreen->GetCurItem(); + if( !DrawStruct || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->SetCurItem( DrawStruct = ModeditLocateAndDisplay() ); + } - switch ( m_ID_current_state ) - { - case 0: - break; + switch( m_ID_current_state ) + { + case 0: + break; - case ID_NO_SELECT_BUTT: - break; + case ID_NO_SELECT_BUTT: + break; - case ID_PCB_CIRCLE_BUTT: - case ID_PCB_ARC_BUTT: - case ID_LINE_COMMENT_BUTT: - if ( ! DrawStruct || DrawStruct->m_Flags == 0) - { - int shape = S_SEGMENT; - if ( m_ID_current_state == ID_PCB_CIRCLE_BUTT) shape = S_CIRCLE; - if ( m_ID_current_state == ID_PCB_ARC_BUTT) shape = S_ARC; + case ID_PCB_CIRCLE_BUTT: + case ID_PCB_ARC_BUTT: + case ID_LINE_COMMENT_BUTT: + if( !DrawStruct || DrawStruct->m_Flags == 0 ) + { + int shape = S_SEGMENT; + if( m_ID_current_state == ID_PCB_CIRCLE_BUTT ) + shape = S_CIRCLE; + if( m_ID_current_state == ID_PCB_ARC_BUTT ) + shape = S_ARC; - m_CurrentScreen->m_CurrentItem = - Begin_Edge_Module((EDGE_MODULE *) NULL, DC, shape); - } + m_CurrentScreen->SetCurItem( + Begin_Edge_Module( (EDGE_MODULE*) NULL, DC, shape ) ); + } + else if( (DrawStruct->m_Flags & IS_NEW) ) + { + if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_CIRCLE ) + { + End_Edge_Module( (EDGE_MODULE*) DrawStruct, DC ); + m_CurrentScreen->SetCurItem( NULL ); + } + else if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_ARC ) + { + End_Edge_Module( (EDGE_MODULE*) DrawStruct, DC ); + m_CurrentScreen->SetCurItem( NULL ); + } + else if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_SEGMENT ) + { + m_CurrentScreen->SetCurItem( + Begin_Edge_Module( (EDGE_MODULE*) DrawStruct, DC, 0 ) ); + } + else + DisplayError( this, wxT( "ProcessCommand error: DrawStruct/ flags error" ) ); + } + break; - else if ( (DrawStruct->m_Flags & IS_NEW) ) - { - if ( ((EDGE_MODULE*)DrawStruct)->m_Shape == S_CIRCLE ) - { - End_Edge_Module((EDGE_MODULE *) DrawStruct, DC); - m_CurrentScreen->m_CurrentItem = NULL; - } - else if ( ((EDGE_MODULE*)DrawStruct)->m_Shape == S_ARC ) - { - End_Edge_Module((EDGE_MODULE *) DrawStruct, DC); - m_CurrentScreen->m_CurrentItem = NULL; - } - else if ( ((EDGE_MODULE*)DrawStruct)->m_Shape == S_SEGMENT ) - { - m_CurrentScreen->m_CurrentItem = - Begin_Edge_Module((EDGE_MODULE *) DrawStruct, DC, 0); - } - else DisplayError(this, wxT("ProcessCommand error: DrawStruct/ flags error")); - } - break; + case ID_MODEDIT_DELETE_ITEM_BUTT: + if( !DrawStruct || (DrawStruct->m_Flags == 0) ) + { + DrawStruct = ModeditLocateAndDisplay(); + if( DrawStruct && (DrawStruct->m_Flags == 0) ) + { + SaveCopyInUndoList( m_Pcb->m_Modules ); + RemoveStruct( DrawStruct, DC ); + m_CurrentScreen->SetCurItem( DrawStruct = NULL ); + } + } + break; - case ID_MODEDIT_DELETE_ITEM_BUTT: - if ( !DrawStruct || (DrawStruct->m_Flags == 0) ) - { - DrawStruct = ModeditLocateAndDisplay(); - if ( DrawStruct && (DrawStruct->m_Flags == 0) ) - { - SaveCopyInUndoList(m_Pcb->m_Modules); - RemoveStruct(DrawStruct, DC); - m_CurrentScreen->m_CurrentItem = DrawStruct = NULL; - } - } - break; + case ID_MODEDIT_PLACE_ANCHOR: + SaveCopyInUndoList( m_Pcb->m_Modules ); + Place_Ancre( m_Pcb->m_Modules, DC ); + m_Pcb->m_Modules->m_Flags = 0; + m_CurrentScreen->m_Curseur = wxPoint( 0, 0 ); + Recadre_Trace( TRUE ); + Place_Module( m_Pcb->m_Modules, DC ); + RedrawActiveWindow( DC, TRUE ); + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); + m_CurrentScreen->SetCurItem( NULL ); + break; - case ID_MODEDIT_PLACE_ANCHOR: - SaveCopyInUndoList(m_Pcb->m_Modules); - Place_Ancre(m_Pcb->m_Modules, DC); - m_Pcb->m_Modules->m_Flags = 0; - m_CurrentScreen->m_Curseur = wxPoint(0,0); - Recadre_Trace(TRUE); - Place_Module(m_Pcb->m_Modules, DC); - RedrawActiveWindow(DC, TRUE); - SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); - m_CurrentScreen->m_CurrentItem = NULL; - break; + case ID_TEXT_COMMENT_BUTT: + SaveCopyInUndoList( m_Pcb->m_Modules ); + CreateTextModule( m_Pcb->m_Modules, DC ); + break; - case ID_TEXT_COMMENT_BUTT: - SaveCopyInUndoList(m_Pcb->m_Modules); - CreateTextModule(m_Pcb->m_Modules, DC); - break; + case ID_MODEDIT_ADD_PAD: + if( m_Pcb->m_Modules ) + { + SaveCopyInUndoList( m_Pcb->m_Modules ); + AddPad( m_Pcb->m_Modules, DC ); + } + break; - case ID_MODEDIT_ADD_PAD: - if ( m_Pcb->m_Modules ) - { - SaveCopyInUndoList(m_Pcb->m_Modules); - AddPad(m_Pcb->m_Modules, DC); - } - break; + default: + DrawPanel->SetCursor( wxCURSOR_ARROW ); + DisplayError( this, wxT( "WinEDA_ModuleEditFrame::ProcessCommand error" ) ); + m_ID_current_state = 0; + break; + } - default : - DrawPanel->SetCursor(wxCURSOR_ARROW); - DisplayError(this, wxT("WinEDA_ModuleEditFrame::ProcessCommand error")); - m_ID_current_state = 0; - break; - } - DrawPanel->CursorOn(DC); + DrawPanel->CursorOn( DC ); } /*********************************************************************/ -void WinEDA_ModuleEditFrame::OnRightClick(const wxPoint& MousePos, - wxMenu * PopMenu) +void WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, + wxMenu* PopMenu ) /*********************************************************************/ + /* Prepare le menu PullUp affich� par un click sur le bouton droit -de la souris. - Ce menu est ensuite compl�t� par la liste des commandes de ZOOM -*/ + * de la souris. + * Ce menu est ensuite compl�t� par la liste des commandes de ZOOM + */ { -EDA_BaseStruct *DrawStruct = m_CurrentScreen->m_CurrentItem; -wxString msg; -bool append_set_width = FALSE; -bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE); + EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem(); + wxString msg; + bool append_set_width = FALSE; + bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE); - // Simple localisation des elements si possible - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - m_CurrentScreen->m_CurrentItem = DrawStruct = ModeditLocateAndDisplay(); - } + // Simple localisation des elements si possible + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->SetCurItem( DrawStruct = ModeditLocateAndDisplay() ); + } - // Si commande en cours: affichage fin de commande - if ( m_ID_current_state ) - { - if ( DrawStruct && DrawStruct->m_Flags ) - { - ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, - _("Cancel"), cancel_xpm); - } - else - ADD_MENUITEM(PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL, - _("End Tool"), cancel_tool_xpm ); - PopMenu->AppendSeparator(); - } + // Si commande en cours: affichage fin de commande + if( m_ID_current_state ) + { + if( DrawStruct && DrawStruct->m_Flags ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, + _( "Cancel" ), cancel_xpm ); + } + else + ADD_MENUITEM( PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL, + _( "End Tool" ), cancel_tool_xpm ); + PopMenu->AppendSeparator(); + } + else + { + if( (DrawStruct && DrawStruct->m_Flags) || BlockActive ) + { + if( BlockActive ) // Put block commnands in list + { + ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, + _( "Cancel Block" ), cancel_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_ZOOM_BLOCK, + _( "Zoom Block (Midd butt drag)" ), zoom_selected_xpm ); + PopMenu->AppendSeparator(); + ADD_MENUITEM( PopMenu, ID_POPUP_PLACE_BLOCK, + _( "Place Block" ), apply_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_COPY_BLOCK, + _( "Copy Block (shift + drag mouse)" ), copyblock_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_MIRROR_X_BLOCK, + _( "Mirror Block (alt + drag mouse)" ), mirror_H_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_ROTATE_BLOCK, + _( "Rotate Block (ctrl + drag mouse)" ), rotate_pos_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_DELETE_BLOCK, + _( "Delete Block (shift+ctrl + drag mouse)" ), delete_xpm ); + } + else + { + ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, + _( "Cancel" ), cancel_xpm ); + } + PopMenu->AppendSeparator(); + } + } - else - { - if ( (DrawStruct && DrawStruct->m_Flags) || BlockActive ) - { - if ( BlockActive ) // Put block commnands in list - { - ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, - _("Cancel Block"), cancel_xpm ); - ADD_MENUITEM(PopMenu, ID_POPUP_ZOOM_BLOCK, - _("Zoom Block (Midd butt drag)"), zoom_selected_xpm ); - PopMenu->AppendSeparator(); - ADD_MENUITEM(PopMenu, ID_POPUP_PLACE_BLOCK, - _("Place Block"), apply_xpm ); - ADD_MENUITEM(PopMenu, ID_POPUP_COPY_BLOCK, - _("Copy Block (shift + drag mouse)"), copyblock_xpm ); - ADD_MENUITEM(PopMenu, ID_POPUP_MIRROR_X_BLOCK, - _("Mirror Block (alt + drag mouse)"), mirror_H_xpm ); - ADD_MENUITEM(PopMenu, ID_POPUP_ROTATE_BLOCK, - _("Rotate Block (ctrl + drag mouse)"), rotate_pos_xpm ); - ADD_MENUITEM(PopMenu, ID_POPUP_DELETE_BLOCK, - _("Delete Block (shift+ctrl + drag mouse)"), delete_xpm ); - } - else - { - ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, - _("Cancel"), cancel_xpm); - } - PopMenu->AppendSeparator(); - } - } + if( DrawStruct == NULL ) + return; - if ( DrawStruct == NULL ) return; + int flags = DrawStruct->m_Flags; -int flags = DrawStruct->m_Flags; - - switch ( DrawStruct->m_StructType ) - { - case TYPEMODULE: - { - wxMenu * transform_choice = new wxMenu; - ADD_MENUITEM(transform_choice, ID_MODEDIT_MODULE_ROTATE, - _("Rotate"), rotate_module_pos_xpm); - ADD_MENUITEM(transform_choice, ID_MODEDIT_MODULE_MIRROR, - _("Mirror"), mirror_H_xpm); + switch( DrawStruct->m_StructType ) + { + case TYPEMODULE: + { + wxMenu* transform_choice = new wxMenu; + ADD_MENUITEM( transform_choice, ID_MODEDIT_MODULE_ROTATE, + _( "Rotate" ), rotate_module_pos_xpm ); + ADD_MENUITEM( transform_choice, ID_MODEDIT_MODULE_MIRROR, + _( "Mirror" ), mirror_H_xpm ); #if 0 - transform_choice->Append(ID_MODEDIT_MODULE_SCALE, _("Scale")); - transform_choice->Append(ID_MODEDIT_MODULE_SCALE, _("Scale X")); - transform_choice->Append(ID_MODEDIT_MODULE_SCALE, _("Scale Y")); + transform_choice->Append( ID_MODEDIT_MODULE_SCALE, _( "Scale" ) ); + transform_choice->Append( ID_MODEDIT_MODULE_SCALE, _( "Scale X" ) ); + transform_choice->Append( ID_MODEDIT_MODULE_SCALE, _( "Scale Y" ) ); #endif - ADD_MENUITEM(PopMenu,ID_POPUP_PCB_EDIT_MODULE, - _("Edit Module"), Edit_Module_xpm); - ADD_MENUITEM_WITH_SUBMENU(PopMenu, transform_choice, - ID_MODEDIT_TRANSFORM_MODULE, - _("Transform Module"), edit_xpm); - break; - } + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_MODULE, + _( "Edit Module" ), Edit_Module_xpm ); + ADD_MENUITEM_WITH_SUBMENU( PopMenu, transform_choice, + ID_MODEDIT_TRANSFORM_MODULE, + _( "Transform Module" ), edit_xpm ); + break; + } - case TYPEPAD: - if( !flags ) - { - ADD_MENUITEM(PopMenu,ID_POPUP_PCB_MOVE_PAD_REQUEST, - _("Move Pad"), move_pad_xpm); - } - ADD_MENUITEM(PopMenu,ID_POPUP_PCB_EDIT_PAD, _("Edit Pad"), options_pad_xpm); - ADD_MENUITEM(PopMenu,ID_POPUP_PCB_IMPORT_PAD_SETTINGS, - _("New Pad Settings"), options_new_pad_xpm); - ADD_MENUITEM(PopMenu,ID_POPUP_PCB_EXPORT_PAD_SETTINGS, - _("Export Pad Settings"), Export_Options_Pad_xpm); - ADD_MENUITEM(PopMenu,ID_POPUP_PCB_DELETE_PAD, - _("delete Pad"), Delete_Pad_xpm); - if( !flags ) - { - PopMenu->AppendSeparator(); - ADD_MENUITEM(PopMenu,ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS, - _("Global Pad Settings"), global_options_pad_xpm); - } - break; + case TYPEPAD: + if( !flags ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_PAD_REQUEST, + _( "Move Pad" ), move_pad_xpm ); + } + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_PAD, _( "Edit Pad" ), options_pad_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_IMPORT_PAD_SETTINGS, + _( "New Pad Settings" ), options_new_pad_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EXPORT_PAD_SETTINGS, + _( "Export Pad Settings" ), Export_Options_Pad_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_PAD, + _( "delete Pad" ), Delete_Pad_xpm ); + if( !flags ) + { + PopMenu->AppendSeparator(); + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS, + _( "Global Pad Settings" ), global_options_pad_xpm ); + } + break; - case TYPETEXTEMODULE: - if( !flags ) - { - ADD_MENUITEM(PopMenu,ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST, - _("Move Text Mod."), Move_Field_xpm ); - } - ADD_MENUITEM(PopMenu,ID_POPUP_PCB_ROTATE_TEXTMODULE, - _("Rotate Text Mod."), Rotate_Field_xpm); - ADD_MENUITEM(PopMenu,ID_POPUP_PCB_EDIT_TEXTMODULE, - _("Edit Text Mod."), edit_text_xpm); - if ( ((TEXTE_MODULE*)DrawStruct)->m_Type == TEXT_is_DIVERS) - ADD_MENUITEM(PopMenu,ID_POPUP_PCB_DELETE_TEXTMODULE, - _("Delete Text Mod."), delete_text_xpm); - break; + case TYPETEXTEMODULE: + if( !flags ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST, + _( "Move Text Mod." ), Move_Field_xpm ); + } + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_ROTATE_TEXTMODULE, + _( "Rotate Text Mod." ), Rotate_Field_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_TEXTMODULE, + _( "Edit Text Mod." ), edit_text_xpm ); + if( ( (TEXTE_MODULE*) DrawStruct )->m_Type == TEXT_is_DIVERS ) + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_TEXTMODULE, + _( "Delete Text Mod." ), delete_text_xpm ); + break; - case TYPEEDGEMODULE: - { - if( (flags & IS_NEW) ) - ADD_MENUITEM(PopMenu,ID_POPUP_PCB_STOP_CURRENT_DRAWING, - _("End edge"), apply_xpm); - if( !flags ) - ADD_MENUITEM(PopMenu,ID_POPUP_PCB_MOVE_EDGE, - _("Move edge"), move_line_xpm); - if( (flags & (IS_NEW|IS_MOVED)) == IS_MOVED) - ADD_MENUITEM(PopMenu,ID_POPUP_PCB_PLACE_EDGE, - _("Place edge"), apply_xpm); - wxMenu * edit_mnu = new wxMenu; - ADD_MENUITEM_WITH_SUBMENU(PopMenu, edit_mnu, - ID_POPUP_PCB_EDIT_EDGE, _("Edit"), edit_xpm); - ADD_MENUITEM(edit_mnu, ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE, - _("Edit Width (Current)"), width_segment_xpm); - ADD_MENUITEM(edit_mnu, ID_POPUP_PCB_EDIT_WIDTH_ALL_EDGE, - _("Edit Width (All)"), width_segment_xpm); - ADD_MENUITEM(edit_mnu, ID_POPUP_PCB_EDIT_LAYER_CURRENT_EDGE, - _("Edit Layer (Current)"), select_layer_pair_xpm); - ADD_MENUITEM(edit_mnu, ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE, - _("Edit Layer (All)"), select_layer_pair_xpm); - ADD_MENUITEM(PopMenu,ID_POPUP_PCB_DELETE_EDGE, - _("Delete edge"), delete_xpm); - append_set_width = TRUE; - } - break; + case TYPEEDGEMODULE: + { + if( (flags & IS_NEW) ) + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_STOP_CURRENT_DRAWING, + _( "End edge" ), apply_xpm ); + if( !flags ) + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_EDGE, + _( "Move edge" ), move_line_xpm ); + if( ( flags & (IS_NEW | IS_MOVED) ) == IS_MOVED ) + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_PLACE_EDGE, + _( "Place edge" ), apply_xpm ); + wxMenu* edit_mnu = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU( PopMenu, edit_mnu, + ID_POPUP_PCB_EDIT_EDGE, _( "Edit" ), edit_xpm ); + ADD_MENUITEM( edit_mnu, ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE, + _( "Edit Width (Current)" ), width_segment_xpm ); + ADD_MENUITEM( edit_mnu, ID_POPUP_PCB_EDIT_WIDTH_ALL_EDGE, + _( "Edit Width (All)" ), width_segment_xpm ); + ADD_MENUITEM( edit_mnu, ID_POPUP_PCB_EDIT_LAYER_CURRENT_EDGE, + _( "Edit Layer (Current)" ), select_layer_pair_xpm ); + ADD_MENUITEM( edit_mnu, ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE, + _( "Edit Layer (All)" ), select_layer_pair_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_EDGE, + _( "Delete edge" ), delete_xpm ); + append_set_width = TRUE; + } + break; - case TYPEDRAWSEGMENT: - case TYPETEXTE: - case TYPEVIA: - case TYPETRACK: - case TYPEZONE: - case TYPEMARQUEUR: - case TYPECOTATION: - case TYPEMIRE: - break; + case TYPEDRAWSEGMENT: + case TYPETEXTE: + case TYPEVIA: + case TYPETRACK: + case TYPEZONE: + case TYPEMARQUEUR: + case TYPECOTATION: + case TYPEMIRE: + break; - case TYPESCREEN: - case TYPE_NOT_INIT: - case TYPEPCB: - case PCB_EQUIPOT_STRUCT_TYPE: - msg.Printf( - wxT("WinEDA_ModuleEditFrame::OnRightClick Error: illegal DrawType %d"), - DrawStruct->m_StructType); - DisplayError(this, msg ); - break; + case TYPESCREEN: + case TYPE_NOT_INIT: + case TYPEPCB: + case PCB_EQUIPOT_STRUCT_TYPE: + msg.Printf( + wxT( "WinEDA_ModuleEditFrame::OnRightClick Error: illegal DrawType %d" ), + DrawStruct->m_StructType ); + DisplayError( this, msg ); + break; - default: - msg.Printf( - wxT("WinEDA_ModuleEditFrame::OnRightClick Error: unknown DrawType %d"), - DrawStruct->m_StructType); - DisplayError(this, msg ); - break; - } - PopMenu->AppendSeparator(); + default: + msg.Printf( + wxT( "WinEDA_ModuleEditFrame::OnRightClick Error: unknown DrawType %d" ), + DrawStruct->m_StructType ); + DisplayError( this, msg ); + break; + } - if ( append_set_width || - ( m_ID_current_state && ((m_ID_current_state == ID_LINE_COMMENT_BUTT) || - (m_ID_current_state == ID_PCB_CIRCLE_BUTT) || - (m_ID_current_state == ID_PCB_ARC_BUTT)) ) ) - { - ADD_MENUITEM(PopMenu,ID_POPUP_PCB_ENTER_EDGE_WIDTH, - _("Set Width"), width_segment_xpm); - PopMenu->AppendSeparator(); - } + PopMenu->AppendSeparator(); + if( append_set_width + || ( m_ID_current_state && ( (m_ID_current_state == ID_LINE_COMMENT_BUTT) + || (m_ID_current_state == ID_PCB_CIRCLE_BUTT) + || (m_ID_current_state == ID_PCB_ARC_BUTT) ) ) ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_ENTER_EDGE_WIDTH, + _( "Set Width" ), width_segment_xpm ); + PopMenu->AppendSeparator(); + } } /****************************************************************************/ -void WinEDA_ModuleEditFrame::OnLeftDClick(wxDC * DC, const wxPoint& MousePos) +void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) /****************************************************************************/ + /* Appel� sur un double click: - pour un �l�ment editable (textes, composant): - appel de l'editeur correspondant. -*/ + * pour un �l�ment editable (textes, composant): + * appel de l'editeur correspondant. + */ { -EDA_BaseStruct * DrawStruct = m_CurrentScreen->m_CurrentItem; -wxPoint pos = GetPosition(); -wxClientDC dc(DrawPanel); + EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem(); + wxPoint pos = GetPosition(); + wxClientDC dc( DrawPanel ); - DrawPanel->PrepareGraphicContext(&dc); + DrawPanel->PrepareGraphicContext( &dc ); - switch ( m_ID_current_state ) - { - case 0: - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - DrawStruct = PcbGeneralLocateAndDisplay(); - } + switch( m_ID_current_state ) + { + case 0: + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + DrawStruct = PcbGeneralLocateAndDisplay(); + } - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) ) - break; + if( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) ) + break; - // Element localis� - m_CurrentScreen->m_CurrentItem = DrawStruct; - switch ( DrawStruct->m_StructType ) - { - case TYPEPAD: - InstallPadOptionsFrame( - (D_PAD *)DrawStruct, &dc, pos); - DrawPanel->MouseToCursorSchema(); - break; + // Element localis� + m_CurrentScreen->SetCurItem( DrawStruct ); - case TYPEMODULE: - InstallModuleOptionsFrame((MODULE *)DrawStruct, - &dc, pos); - DrawPanel->MouseToCursorSchema(); - break; + switch( DrawStruct->m_StructType ) + { + case TYPEPAD: + InstallPadOptionsFrame( + (D_PAD*) DrawStruct, &dc, pos ); + DrawPanel->MouseToCursorSchema(); + break; - case TYPETEXTEMODULE: - InstallTextModOptionsFrame((TEXTE_MODULE *)DrawStruct, - &dc, pos); - DrawPanel->MouseToCursorSchema(); - break; + case TYPEMODULE: + InstallModuleOptionsFrame( (MODULE*) DrawStruct, + &dc, pos ); + DrawPanel->MouseToCursorSchema(); + break; - default: - break; - } - break; // end case 0 + case TYPETEXTEMODULE: + InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, + &dc, pos ); + DrawPanel->MouseToCursorSchema(); + break; - case ID_LINE_COMMENT_BUTT: - { - if ( DrawStruct && (DrawStruct->m_Flags & IS_NEW) ) - { - End_Edge_Module((EDGE_MODULE *) DrawStruct, DC); - m_CurrentScreen->m_CurrentItem = NULL; - } - break; - } + default: + break; + } - default: - break; - } + break; // end case 0 + + case ID_LINE_COMMENT_BUTT: + { + if( DrawStruct && (DrawStruct->m_Flags & IS_NEW) ) + { + End_Edge_Module( (EDGE_MODULE*) DrawStruct, DC ); + m_CurrentScreen->SetCurItem( NULL ); + } + break; + } + + default: + break; + } } - diff --git a/pcbnew/modedit_undo_redo.cpp b/pcbnew/modedit_undo_redo.cpp index 9ccd826737..eb3ac61e45 100644 --- a/pcbnew/modedit_undo_redo.cpp +++ b/pcbnew/modedit_undo_redo.cpp @@ -1,6 +1,6 @@ - /********************************************/ - /* library editor: undo and redo functions */ - /********************************************/ +/********************************************/ +/* library editor: undo and redo functions */ +/********************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -13,69 +13,76 @@ /**************************************************************************/ -void WinEDA_ModuleEditFrame::SaveCopyInUndoList(EDA_BaseStruct * ItemToCopy, - int unused_flag) +void WinEDA_ModuleEditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy, + int unused_flag ) /************************************************************************/ { -EDA_BaseStruct * item; -MODULE * CopyItem; + EDA_BaseStruct* item; + MODULE* CopyItem; - CopyItem = new MODULE(m_Pcb); - CopyItem->Copy((MODULE*)ItemToCopy); - CopyItem->m_Parent = m_Pcb; + CopyItem = new MODULE( m_Pcb ); + CopyItem->Copy( (MODULE*) ItemToCopy ); + CopyItem->m_Parent = m_Pcb; - GetScreen()->AddItemToUndoList((EDA_BaseStruct *)CopyItem); - /* Clear current flags (which can be temporary set by a current edit command) */ - for ( item = CopyItem->m_Drawings; item != NULL; item = item->Pnext ) - item->m_Flags = 0; - + GetScreen()->AddItemToUndoList( (EDA_BaseStruct*) CopyItem ); + /* Clear current flags (which can be temporary set by a current edit command) */ + for( item = CopyItem->m_Drawings; item != NULL; item = item->Pnext ) + item->m_Flags = 0; - /* Clear redo list, because after new save there is no redo to do */ - while ( GetScreen()->m_RedoList ) - { - item = GetScreen()->m_RedoList->Pnext; - delete GetScreen()->m_RedoList; - GetScreen()->m_RedoList = item; - } + /* Clear redo list, because after new save there is no redo to do */ + while( GetScreen()->m_RedoList ) + { + item = GetScreen()->m_RedoList->Pnext; + delete GetScreen()->m_RedoList; + GetScreen()->m_RedoList = item; + } } + /*********************************************************/ -void WinEDA_ModuleEditFrame::GetComponentFromRedoList(void) +void WinEDA_ModuleEditFrame::GetComponentFromRedoList( void ) /*********************************************************/ + /* Redo the last edition: - - Place the current edited library component in undo list - - Get old version of the current edited library component -*/ + * - Place the current edited library component in undo list + * - Get old version of the current edited library component + */ { - if ( GetScreen()->m_RedoList == NULL ) return; - - GetScreen()->AddItemToUndoList(m_Pcb->m_Modules); - m_Pcb->m_Modules = - (MODULE *) GetScreen()->GetItemFromRedoList(); - if ( m_Pcb->m_Modules ) m_Pcb->m_Modules->Pnext = NULL; - GetScreen()->m_CurrentItem = NULL;; - GetScreen()->SetModify(); - ReCreateHToolbar(); - SetToolbars(); + if( GetScreen()->m_RedoList == NULL ) + return; + + GetScreen()->AddItemToUndoList( m_Pcb->m_Modules ); + m_Pcb->m_Modules = + (MODULE*) GetScreen()->GetItemFromRedoList(); + if( m_Pcb->m_Modules ) + m_Pcb->m_Modules->Pnext = NULL; + GetScreen()->SetCurItem( NULL );; + GetScreen()->SetModify(); + ReCreateHToolbar(); + SetToolbars(); } + /*********************************************************/ -void WinEDA_ModuleEditFrame::GetComponentFromUndoList(void) +void WinEDA_ModuleEditFrame::GetComponentFromUndoList( void ) /*********************************************************/ + /* Undo the last edition: - - Place the current edited library component in Redo list - - Get old version of the current edited library component -*/ + * - Place the current edited library component in Redo list + * - Get old version of the current edited library component + */ { - if ( GetScreen()->m_UndoList == NULL ) return; - - GetScreen()->AddItemToRedoList(m_Pcb->m_Modules); - m_Pcb->m_Modules = - (MODULE *) GetScreen()->GetItemFromUndoList(); + if( GetScreen()->m_UndoList == NULL ) + return; - if ( m_Pcb->m_Modules ) m_Pcb->m_Modules->Pnext = NULL; - GetScreen()->SetModify(); - GetScreen()->m_CurrentItem = NULL;; - ReCreateHToolbar(); - SetToolbars(); + GetScreen()->AddItemToRedoList( m_Pcb->m_Modules ); + m_Pcb->m_Modules = + (MODULE*) GetScreen()->GetItemFromUndoList(); + + if( m_Pcb->m_Modules ) + m_Pcb->m_Modules->Pnext = NULL; + GetScreen()->SetModify(); + GetScreen()->SetCurItem( NULL );; + ReCreateHToolbar(); + SetToolbars(); } diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 22a3fbc35d..104b9e8ccc 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -15,313 +15,322 @@ #include "protos.h" #include "id.h" - /********************************/ - /* class WinEDA_ModuleEditFrame */ - /********************************/ -BEGIN_EVENT_TABLE(WinEDA_ModuleEditFrame, wxFrame) - COMMON_EVENTS_DRAWFRAME +/********************************/ +/* class WinEDA_ModuleEditFrame */ +/********************************/ +BEGIN_EVENT_TABLE( WinEDA_ModuleEditFrame, wxFrame ) +COMMON_EVENTS_DRAWFRAME EVT_CLOSE( WinEDA_ModuleEditFrame::OnCloseWindow ) +EVT_SIZE( WinEDA_ModuleEditFrame::OnSize ) - EVT_CLOSE(WinEDA_ModuleEditFrame::OnCloseWindow) - EVT_SIZE(WinEDA_ModuleEditFrame::OnSize) +EVT_KICAD_CHOICEBOX( ID_ON_ZOOM_SELECT, WinEDA_PcbFrame::OnSelectZoom ) +EVT_KICAD_CHOICEBOX( ID_ON_GRID_SELECT, WinEDA_PcbFrame::OnSelectGrid ) - EVT_KICAD_CHOICEBOX(ID_ON_ZOOM_SELECT,WinEDA_PcbFrame::OnSelectZoom) - EVT_KICAD_CHOICEBOX(ID_ON_GRID_SELECT,WinEDA_PcbFrame::OnSelectGrid) +EVT_TOOL_RANGE( ID_ZOOM_PLUS_BUTT, ID_ZOOM_PAGE_BUTT, + WinEDA_ModuleEditFrame::Process_Zoom ) - EVT_TOOL_RANGE(ID_ZOOM_PLUS_BUTT, ID_ZOOM_PAGE_BUTT, - WinEDA_ModuleEditFrame::Process_Zoom) +EVT_TOOL( ID_LIBEDIT_SELECT_CURRENT_LIB, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_MODEDIT_SAVE_LIBMODULE, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_LIBEDIT_DELETE_PART, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_MODEDIT_NEW_MODULE, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_MODEDIT_LOAD_MODULE, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_LIBEDIT_IMPORT_PART, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_LIBEDIT_EXPORT_PART, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, + WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_MODEDIT_SHEET_SET, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_GEN_PRINT, WinEDA_DrawFrame::ToPrinter ) +EVT_TOOL( ID_MODEDIT_LOAD_MODULE, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_MODEDIT_CHECK, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_MODEDIT_PAD_SETTINGS, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_MODEDIT_INSERT_MODULE_IN_BOARD, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_MODEDIT_UPDATE_MODULE_IN_BOARD, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_MODEDIT_EDIT_MODULE_PROPERTIES, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_MODEDIT_UNDO, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_MODEDIT_REDO, WinEDA_ModuleEditFrame::Process_Special_Functions ) - EVT_TOOL(ID_LIBEDIT_SELECT_CURRENT_LIB, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_MODEDIT_SAVE_LIBMODULE, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_LIBEDIT_DELETE_PART, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_MODEDIT_NEW_MODULE, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_MODEDIT_LOAD_MODULE, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_LIBEDIT_IMPORT_PART, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_LIBEDIT_EXPORT_PART, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_MODEDIT_SHEET_SET, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_GEN_PRINT, WinEDA_DrawFrame::ToPrinter) - EVT_TOOL(ID_MODEDIT_LOAD_MODULE, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_MODEDIT_CHECK, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_MODEDIT_PAD_SETTINGS, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_MODEDIT_LOAD_MODULE_FROM_BOARD, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_MODEDIT_INSERT_MODULE_IN_BOARD, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_MODEDIT_UPDATE_MODULE_IN_BOARD, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_MODEDIT_EDIT_MODULE_PROPERTIES, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_MODEDIT_UNDO, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_MODEDIT_REDO, WinEDA_ModuleEditFrame::Process_Special_Functions) +// Vertical toolbar (left click): +EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_MODEDIT_ADD_PAD, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_PCB_ARC_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_PCB_CIRCLE_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_TEXT_COMMENT_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_LINE_COMMENT_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_MODEDIT_DELETE_ITEM_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_TOOL( ID_MODEDIT_PLACE_ANCHOR, WinEDA_ModuleEditFrame::Process_Special_Functions ) - // Vertical toolbar (left click): - EVT_TOOL(ID_NO_SELECT_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_MODEDIT_ADD_PAD, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_PCB_ARC_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_PCB_CIRCLE_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_TEXT_COMMENT_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_LINE_COMMENT_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_MODEDIT_DELETE_ITEM_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_TOOL(ID_MODEDIT_PLACE_ANCHOR, WinEDA_ModuleEditFrame::Process_Special_Functions) +// Vertical toolbar (right click): +EVT_TOOL_RCLICKED( ID_MODEDIT_ADD_PAD, WinEDA_ModuleEditFrame::ToolOnRightClick ) +EVT_TOOL_RCLICKED( ID_TRACK_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick ) +EVT_TOOL_RCLICKED( ID_PCB_CIRCLE_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick ) +EVT_TOOL_RCLICKED( ID_PCB_ARC_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick ) +EVT_TOOL_RCLICKED( ID_TEXT_COMMENT_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick ) +EVT_TOOL_RCLICKED( ID_LINE_COMMENT_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick ) +EVT_TOOL_RCLICKED( ID_PCB_COTATION_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick ) - // Vertical toolbar (right click): - EVT_TOOL_RCLICKED(ID_MODEDIT_ADD_PAD, WinEDA_ModuleEditFrame::ToolOnRightClick) - EVT_TOOL_RCLICKED(ID_TRACK_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick) - EVT_TOOL_RCLICKED(ID_PCB_CIRCLE_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick) - EVT_TOOL_RCLICKED(ID_PCB_ARC_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick) - EVT_TOOL_RCLICKED(ID_TEXT_COMMENT_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick) - EVT_TOOL_RCLICKED(ID_LINE_COMMENT_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick) - EVT_TOOL_RCLICKED(ID_PCB_COTATION_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick) +// Options Toolbar +EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END, + WinEDA_ModuleEditFrame::OnSelectOptionToolbar ) - // Options Toolbar - EVT_TOOL_RANGE(ID_TB_OPTIONS_START,ID_TB_OPTIONS_END, - WinEDA_ModuleEditFrame::OnSelectOptionToolbar) +EVT_MENU_RANGE( ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_END_RANGE, + WinEDA_ModuleEditFrame::Process_Special_Functions ) - EVT_MENU_RANGE(ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_END_RANGE, - WinEDA_ModuleEditFrame::Process_Special_Functions) +// Annulation de commande en cours +EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, + WinEDA_PcbFrame::Process_Special_Functions ) - // Annulation de commande en cours - EVT_MENU_RANGE(ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, - WinEDA_PcbFrame::Process_Special_Functions ) +// Transformations du module +EVT_MENU( ID_MODEDIT_MODULE_ROTATE, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_MENU( ID_MODEDIT_MODULE_MIRROR, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_MENU( ID_MODEDIT_MODULE_SCALE, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_MENU( ID_MODEDIT_MODULE_SCALEX, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_MENU( ID_MODEDIT_MODULE_SCALEY, WinEDA_ModuleEditFrame::Process_Special_Functions ) - // Transformations du module - EVT_MENU(ID_MODEDIT_MODULE_ROTATE, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_MENU(ID_MODEDIT_MODULE_MIRROR, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_MENU(ID_MODEDIT_MODULE_SCALE, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_MENU(ID_MODEDIT_MODULE_SCALEX, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_MENU(ID_MODEDIT_MODULE_SCALEY, WinEDA_ModuleEditFrame::Process_Special_Functions) +EVT_MENU( ID_PCB_DRAWINGS_WIDTHS_SETUP, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_MENU( ID_PCB_PAD_SETUP, WinEDA_ModuleEditFrame::Process_Special_Functions ) +EVT_MENU( ID_PCB_USER_GRID_SETUP, WinEDA_PcbFrame::Process_Special_Functions ) - EVT_MENU(ID_PCB_DRAWINGS_WIDTHS_SETUP, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_MENU(ID_PCB_PAD_SETUP, WinEDA_ModuleEditFrame::Process_Special_Functions) - EVT_MENU(ID_PCB_USER_GRID_SETUP, WinEDA_PcbFrame::Process_Special_Functions) +// Menu 3D Frame +EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, WinEDA_ModuleEditFrame::Show3D_Frame ) - // Menu 3D Frame - EVT_MENU(ID_MENU_PCB_SHOW_3D_FRAME, WinEDA_ModuleEditFrame::Show3D_Frame) - - // PopUp Menu Zoom trait�s dans drawpanel.cpp +// PopUp Menu Zoom trait�s dans drawpanel.cpp END_EVENT_TABLE() +/****************/ +/* Constructeur */ +/****************/ - /****************/ - /* Constructeur */ - /****************/ - -WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame(wxWindow * father, WinEDA_App *parent, - const wxString & title, - const wxPoint& pos, const wxSize& size) : - WinEDA_BasePcbFrame(father, parent, MODULE_EDITOR_FRAME, wxEmptyString, pos, size) +WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father, WinEDA_App* parent, + const wxString& title, + const wxPoint& pos, const wxSize& size ) : + WinEDA_BasePcbFrame( father, parent, MODULE_EDITOR_FRAME, wxEmptyString, pos, size ) { - m_FrameName = wxT("ModEditFrame"); - m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines - m_Draw_Grid = TRUE; // TRUE pour avoir la axes dessinee - m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessin� - m_ZoomMaxValue = 1024; - // Give an icon - SetIcon(wxICON(icon_modedit)); + m_FrameName = wxT( "ModEditFrame" ); + m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines + m_Draw_Grid = TRUE; // TRUE pour avoir la axes dessinee + m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessin� + m_ZoomMaxValue = 1024; - SetTitle( wxT("Module Editor (lib: ") + m_CurrentLib + wxT(")") ); + // Give an icon + SetIcon( wxICON( icon_modedit ) ); - if ( ScreenModule == NULL ) - { - ScreenModule = new PCB_SCREEN(PCB_FRAME); - ActiveScreen = ScreenModule; - } - ScreenModule->m_UndoRedoCountMax = 10; + SetTitle( wxT( "Module Editor (lib: " ) + m_CurrentLib + wxT( ")" ) ); - if( g_ModuleEditor_Pcb == NULL ) g_ModuleEditor_Pcb = new BOARD(NULL, this); - m_Pcb = g_ModuleEditor_Pcb; + if( ScreenModule == NULL ) + { + ScreenModule = new PCB_SCREEN( PCB_FRAME ); + ActiveScreen = ScreenModule; + } + ScreenModule->m_UndoRedoCountMax = 10; - m_Pcb->m_PcbFrame = this; - m_CurrentScreen = ScreenModule; - GetScreen()->m_CurrentItem = NULL; - GetSettings(); + if( g_ModuleEditor_Pcb == NULL ) + g_ModuleEditor_Pcb = new BOARD( NULL, this ); + m_Pcb = g_ModuleEditor_Pcb; - wxSize GridSize(500,500); - if ( m_Parent && m_Parent->m_EDA_Config ) - { - long SizeX, SizeY; - if ( m_Parent->m_EDA_Config->Read( wxT("ModEditGrid_X"), &SizeX) && - m_Parent->m_EDA_Config->Read( wxT("ModEditGrid_Y"), &SizeY) ) - { - GridSize.x = SizeX; - GridSize.y = SizeY; - } - } - GetScreen()->SetGrid(GridSize); + m_Pcb->m_PcbFrame = this; + m_CurrentScreen = ScreenModule; + GetScreen()->SetCurItem( NULL ); + GetSettings(); - SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y); - ReCreateMenuBar(); - ReCreateHToolbar(); - ReCreateAuxiliaryToolbar(); - ReCreateVToolbar(); - ReCreateOptToolbar(); + wxSize GridSize( 500, 500 ); + if( m_Parent && m_Parent->m_EDA_Config ) + { + long SizeX, SizeY; + if( m_Parent->m_EDA_Config->Read( wxT( "ModEditGrid_X" ), &SizeX ) + && m_Parent->m_EDA_Config->Read( wxT( "ModEditGrid_Y" ), &SizeY ) ) + { + GridSize.x = SizeX; + GridSize.y = SizeY; + } + } + GetScreen()->SetGrid( GridSize ); - if ( DrawPanel ) DrawPanel->m_Block_Enable = TRUE; + SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); + ReCreateMenuBar(); + ReCreateHToolbar(); + ReCreateAuxiliaryToolbar(); + ReCreateVToolbar(); + ReCreateOptToolbar(); + if( DrawPanel ) + DrawPanel->m_Block_Enable = TRUE; } /****************************************************/ -WinEDA_ModuleEditFrame::~WinEDA_ModuleEditFrame(void) +WinEDA_ModuleEditFrame::~WinEDA_ModuleEditFrame( void ) /****************************************************/ { - m_Parent->m_ModuleEditFrame = NULL; - m_CurrentScreen = ScreenPcb; + m_Parent->m_ModuleEditFrame = NULL; + m_CurrentScreen = ScreenPcb; } + /**************************************************************/ -void WinEDA_ModuleEditFrame::OnCloseWindow(wxCloseEvent & Event) +void WinEDA_ModuleEditFrame::OnCloseWindow( wxCloseEvent& Event ) /**************************************************************/ { - if( GetScreen()->IsModify() ) - { - if( ! IsOK(this, _("Module Editor: module modified!, Continue ?") ) ) - { - Event.Veto(); return; - } - } + if( GetScreen()->IsModify() ) + { + if( !IsOK( this, _( "Module Editor: module modified!, Continue ?" ) ) ) + { + Event.Veto(); return; + } + } - SaveSettings(); - if ( m_Parent && m_Parent->m_EDA_Config ) - { - wxSize GridSize = GetScreen()->GetGrid(); - m_Parent->m_EDA_Config->Write( wxT("ModEditGrid_X"), (long)GridSize.x); - m_Parent->m_EDA_Config->Write( wxT("ModEditGrid_Y"), (long)GridSize.y); - } - Destroy(); + SaveSettings(); + if( m_Parent && m_Parent->m_EDA_Config ) + { + wxSize GridSize = GetScreen()->GetGrid(); + m_Parent->m_EDA_Config->Write( wxT( "ModEditGrid_X" ), (long) GridSize.x ); + m_Parent->m_EDA_Config->Write( wxT( "ModEditGrid_Y" ), (long) GridSize.y ); + } + Destroy(); } /*********************************************/ -void WinEDA_ModuleEditFrame::SetToolbars(void) +void WinEDA_ModuleEditFrame::SetToolbars( void ) /*********************************************/ { -bool active, islib = TRUE; + bool active, islib = TRUE; - if( m_HToolBar == NULL ) return; + if( m_HToolBar == NULL ) + return; - if ( m_CurrentLib == wxEmptyString ) islib = FALSE; + if( m_CurrentLib == wxEmptyString ) + islib = FALSE; - m_HToolBar->EnableTool(ID_MODEDIT_SAVE_LIBMODULE,islib); - m_HToolBar->EnableTool(ID_LIBEDIT_DELETE_PART,islib); + m_HToolBar->EnableTool( ID_MODEDIT_SAVE_LIBMODULE, islib ); + m_HToolBar->EnableTool( ID_LIBEDIT_DELETE_PART, islib ); - if ( m_Pcb->m_Modules == NULL ) active = FALSE; - else active = TRUE; + if( m_Pcb->m_Modules == NULL ) + active = FALSE; + else + active = TRUE; - m_HToolBar->EnableTool(ID_LIBEDIT_EXPORT_PART,active); - m_HToolBar->EnableTool(ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,active); - m_HToolBar->EnableTool(ID_MODEDIT_SAVE_LIBMODULE,active && islib); - MODULE * module_in_edit = m_Pcb->m_Modules; - if ( module_in_edit && module_in_edit->m_Link ) // this is not a new module ... - { - WinEDA_PcbFrame * pcbframe = m_Parent->m_PcbFrame; - BOARD * mainpcb = pcbframe->m_Pcb; - MODULE * source_module = mainpcb->m_Modules; - // search if the source module was not deleted: - for( ; source_module != NULL ; source_module = (MODULE *) source_module->Pnext ) - { - if( module_in_edit->m_Link == source_module->m_TimeStamp ) - break; - } - if ( source_module ) - { - m_HToolBar->EnableTool(ID_MODEDIT_INSERT_MODULE_IN_BOARD, false); - m_HToolBar->EnableTool(ID_MODEDIT_UPDATE_MODULE_IN_BOARD, true); - } - else // The source was deleted, therefore we can insert but not update the module - { - m_HToolBar->EnableTool(ID_MODEDIT_INSERT_MODULE_IN_BOARD, true); - m_HToolBar->EnableTool(ID_MODEDIT_UPDATE_MODULE_IN_BOARD, false); - } - } - else - { - m_HToolBar->EnableTool(ID_MODEDIT_INSERT_MODULE_IN_BOARD,active); - m_HToolBar->EnableTool(ID_MODEDIT_UPDATE_MODULE_IN_BOARD, false); - } + m_HToolBar->EnableTool( ID_LIBEDIT_EXPORT_PART, active ); + m_HToolBar->EnableTool( ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, active ); + m_HToolBar->EnableTool( ID_MODEDIT_SAVE_LIBMODULE, active && islib ); + MODULE* module_in_edit = m_Pcb->m_Modules; + if( module_in_edit && module_in_edit->m_Link ) // this is not a new module ... + { + WinEDA_PcbFrame* pcbframe = m_Parent->m_PcbFrame; + BOARD* mainpcb = pcbframe->m_Pcb; + MODULE* source_module = mainpcb->m_Modules; - if ( GetScreen() ) - { - m_HToolBar->EnableTool(ID_MODEDIT_UNDO,GetScreen()->m_UndoList && active); - m_HToolBar->EnableTool(ID_MODEDIT_REDO,GetScreen()->m_RedoList && active); - } + // search if the source module was not deleted: + for( ; source_module != NULL; source_module = (MODULE*) source_module->Pnext ) + { + if( module_in_edit->m_Link == source_module->m_TimeStamp ) + break; + } - if ( m_Parent->m_PcbFrame->m_Pcb->m_Modules ) - { - m_HToolBar->EnableTool(ID_MODEDIT_LOAD_MODULE_FROM_BOARD,TRUE); - } - else - { - m_HToolBar->EnableTool(ID_MODEDIT_LOAD_MODULE_FROM_BOARD,FALSE); - } + if( source_module ) + { + m_HToolBar->EnableTool( ID_MODEDIT_INSERT_MODULE_IN_BOARD, false ); + m_HToolBar->EnableTool( ID_MODEDIT_UPDATE_MODULE_IN_BOARD, true ); + } + else // The source was deleted, therefore we can insert but not update the module + { + m_HToolBar->EnableTool( ID_MODEDIT_INSERT_MODULE_IN_BOARD, true ); + m_HToolBar->EnableTool( ID_MODEDIT_UPDATE_MODULE_IN_BOARD, false ); + } + } + else + { + m_HToolBar->EnableTool( ID_MODEDIT_INSERT_MODULE_IN_BOARD, active ); + m_HToolBar->EnableTool( ID_MODEDIT_UPDATE_MODULE_IN_BOARD, false ); + } + + if( GetScreen() ) + { + m_HToolBar->EnableTool( ID_MODEDIT_UNDO, GetScreen()->m_UndoList && active ); + m_HToolBar->EnableTool( ID_MODEDIT_REDO, GetScreen()->m_RedoList && active ); + } + + if( m_Parent->m_PcbFrame->m_Pcb->m_Modules ) + { + m_HToolBar->EnableTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, TRUE ); + } + else + { + m_HToolBar->EnableTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FALSE ); + } - if ( m_VToolBar ) - { - m_VToolBar->EnableTool(ID_MODEDIT_ADD_PAD,active); - m_VToolBar->EnableTool(ID_LINE_COMMENT_BUTT,active); - m_VToolBar->EnableTool(ID_PCB_CIRCLE_BUTT,active); - m_VToolBar->EnableTool(ID_PCB_ARC_BUTT,active); - m_VToolBar->EnableTool(ID_TEXT_COMMENT_BUTT,active); - m_VToolBar->EnableTool(ID_MODEDIT_PLACE_ANCHOR,active); - m_VToolBar->EnableTool(ID_PCB_DELETE_ITEM_BUTT,active); - } + if( m_VToolBar ) + { + m_VToolBar->EnableTool( ID_MODEDIT_ADD_PAD, active ); + m_VToolBar->EnableTool( ID_LINE_COMMENT_BUTT, active ); + m_VToolBar->EnableTool( ID_PCB_CIRCLE_BUTT, active ); + m_VToolBar->EnableTool( ID_PCB_ARC_BUTT, active ); + m_VToolBar->EnableTool( ID_TEXT_COMMENT_BUTT, active ); + m_VToolBar->EnableTool( ID_MODEDIT_PLACE_ANCHOR, active ); + m_VToolBar->EnableTool( ID_PCB_DELETE_ITEM_BUTT, active ); + } - if ( m_OptionsToolBar ) - { - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_MM, - g_UnitMetric == MILLIMETRE ? TRUE : FALSE); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_INCH, - g_UnitMetric == INCHES ? TRUE : FALSE); + if( m_OptionsToolBar ) + { + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM, + g_UnitMetric == MILLIMETRE ? TRUE : FALSE ); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, + g_UnitMetric == INCHES ? TRUE : FALSE ); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_POLAR_COORD, - DisplayOpt.DisplayPolarCood); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, + DisplayOpt.DisplayPolarCood ); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_GRID, - m_Draw_Grid); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID, + m_Draw_Grid ); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_CURSOR, - g_CursorShape); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR, + g_CursorShape ); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_PADS_SKETCH, - ! m_DisplayPadFill); - } + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, + !m_DisplayPadFill ); + } - if ( m_AuxiliaryToolBar ) - { - int ii, jj; - if ( m_SelZoomBox ) - { - int old_choice = m_SelZoomBox->GetChoice(); - int new_choice = 1; - int zoom; - for ( jj = 1, zoom = 1; zoom <= m_ZoomMaxValue; zoom <<= 1, jj++ ) - { - if ( m_CurrentScreen && (m_CurrentScreen->GetZoom() == zoom) ) - break; - new_choice++; - } - if ( old_choice != new_choice ) - m_SelZoomBox->SetSelection(new_choice); - } + if( m_AuxiliaryToolBar ) + { + int ii, jj; + if( m_SelZoomBox ) + { + int old_choice = m_SelZoomBox->GetChoice(); + int new_choice = 1; + int zoom; + for( jj = 1, zoom = 1; zoom <= m_ZoomMaxValue; zoom <<= 1, jj++ ) + { + if( m_CurrentScreen && (m_CurrentScreen->GetZoom() == zoom) ) + break; + new_choice++; + } - if ( m_SelGridBox && GetScreen() ) - { - int kk = m_SelGridBox->GetChoice(); - for ( ii = 0; g_GridList[ii].x > 0; ii++ ) - { - if ( !GetScreen()->m_UserGridIsON && - (GetScreen()->GetGrid().x == g_GridList[ii].x) && - (GetScreen()->GetGrid().y == g_GridList[ii].y)) - { - if ( kk != ii )m_SelGridBox->SetSelection(ii); - kk = ii; - break; - } - } - if ( kk != ii ) - m_SelGridBox->SetSelection(ii); /* User Grid */ - } - } + if( old_choice != new_choice ) + m_SelZoomBox->SetSelection( new_choice ); + } - DisplayUnitsMsg(); + if( m_SelGridBox && GetScreen() ) + { + int kk = m_SelGridBox->GetChoice(); + for( ii = 0; g_GridList[ii].x > 0; ii++ ) + { + if( !GetScreen()->m_UserGridIsON + && (GetScreen()->GetGrid().x == g_GridList[ii].x) + && (GetScreen()->GetGrid().y == g_GridList[ii].y) ) + { + if( kk != ii ) + m_SelGridBox->SetSelection( ii ); + kk = ii; + break; + } + } + + if( kk != ii ) + m_SelGridBox->SetSelection( ii );/* User Grid */ + } + } + + DisplayUnitsMsg(); } - diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index 44e8277e1e..faeb8478f8 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -100,7 +100,7 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC ) if( module == NULL ) return; - m_CurrentScreen->m_CurrentItem = module; + m_CurrentScreen->SetCurItem( module ); m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; module->m_Flags |= IS_MOVED; ModuleInitOrient = module->m_Orient; @@ -143,7 +143,7 @@ void Exit_Module( WinEDA_DrawPanel* Panel, wxDC* DC ) MODULE* module; WinEDA_BasePcbFrame* pcbframe = (WinEDA_BasePcbFrame*) Panel->m_Parent; - module = (MODULE*) pcbframe->m_CurrentScreen->m_CurrentItem; + module = (MODULE*) pcbframe->m_CurrentScreen->GetCurItem(); pcbframe->m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; if( module ) @@ -199,7 +199,7 @@ void Exit_Module( WinEDA_DrawPanel* Panel, wxDC* DC ) g_Drag_Pistes_On = FALSE; Panel->ManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL; - pcbframe->m_CurrentScreen->m_CurrentItem = NULL; + pcbframe->m_CurrentScreen->SetCurItem( NULL ); } @@ -238,7 +238,7 @@ void Montre_Position_Empreinte( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /* redessin du contour de l'empreinte lors des deplacements de la souris */ { - MODULE* module = (MODULE*) panel->m_Parent->m_CurrentScreen->m_CurrentItem; + MODULE* module = (MODULE*) panel->m_Parent->m_CurrentScreen->GetCurItem(); if( module == NULL ) return; @@ -351,7 +351,7 @@ void WinEDA_BasePcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) /* Effacement chevelu general si necessaire */ if( DC && g_Show_Ratsnest ) DrawGeneralRatsnest( DC ); - + /* Init des variables utilisees dans la routine Dessine_Drag_segment() */ g_Offset_Module.x = 0; g_Offset_Module.y = 0; @@ -384,7 +384,7 @@ void WinEDA_BasePcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) pt_pad->m_Offset.y = -pt_pad->m_Offset.y; pt_pad->m_DeltaSize.y = -pt_pad->m_DeltaSize.y; NEGATE_AND_NORMALIZE_ANGLE_POS( pt_pad->m_Orient ); - + /* change cote pour pastilles surfaciques */ pt_pad->m_Masque_Layer = ChangeSideMaskLayer( pt_pad->m_Masque_Layer ); } @@ -399,15 +399,15 @@ void WinEDA_BasePcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient ); pt_texte->m_Layer = Module->m_Layer; pt_texte->m_Layer = ChangeSideNumLayer( pt_texte->m_Layer ); - + if( Module->m_Layer == CUIVRE_N ) pt_texte->m_Layer = SILKSCREEN_N_CU; - + if( Module->m_Layer == CMP_N ) pt_texte->m_Layer = SILKSCREEN_N_CMP; - + if( (Module->m_Layer == SILKSCREEN_N_CU) - || (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) ) + || (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) ) pt_texte->m_Miroir = 0; /* Inversion miroir de la Valeur et mise en miroir : */ @@ -420,13 +420,13 @@ void WinEDA_BasePcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient ); pt_texte->m_Layer = Module->m_Layer; pt_texte->m_Layer = ChangeSideNumLayer( pt_texte->m_Layer ); - + if( Module->m_Layer == CUIVRE_N ) pt_texte->m_Layer = SILKSCREEN_N_CU; - + if( Module->m_Layer == CMP_N ) pt_texte->m_Layer = SILKSCREEN_N_CMP; - + if( (Module->m_Layer == SILKSCREEN_N_CU) || (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) ) pt_texte->m_Miroir = 0; @@ -468,15 +468,15 @@ void WinEDA_BasePcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) pt_texte->m_Layer = Module->m_Layer; pt_texte->m_Layer = ChangeSideNumLayer( pt_texte->m_Layer ); - + if( Module->m_Layer == CUIVRE_N ) pt_texte->m_Layer = SILKSCREEN_N_CU; - + if( Module->m_Layer == CMP_N ) pt_texte->m_Layer = SILKSCREEN_N_CMP; - + if( (Module->m_Layer == SILKSCREEN_N_CU) - || (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) ) + || (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) ) pt_texte->m_Miroir = 0; break; diff --git a/pcbnew/move_copy_track.cpp b/pcbnew/move_copy_track.cpp index 13d5f31dda..e962f18f00 100644 --- a/pcbnew/move_copy_track.cpp +++ b/pcbnew/move_copy_track.cpp @@ -93,7 +93,7 @@ static void Exit_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC ) Panel->ManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL; - Panel->GetScreen()->m_CurrentItem = NULL; + Panel->GetScreen()->SetCurItem( NULL ); Panel->m_Parent->EraseMsgBox(); /* Annulation deplacement et Redessin des segments dragges */ @@ -297,7 +297,7 @@ void WinEDA_PcbFrame::Place_Dupl_Route( Track* Track, wxDC* DC ) old_net_code = NewTrack->net_code; /* Placement du flag BUSY de la piste originelle, qui ne doit - * pas etre vue dans les recherches de raccordement suivantes */ + * pas etre vue dans les recherches de raccordement suivantes */ ii = NbPtNewTrack; pt_track = NewTrack; for( ; ii > 0; ii--, pt_track = (TRACK*) pt_track->Pnext ) { @@ -613,7 +613,7 @@ TRACK* CreateLockPoint( int* pX, int* pY, TRACK* ptsegm, TRACK* refsegm ) * Si ptsegm pointe sur une via: * retourne la valeur exacte de pX et pY et ptsegm, * mais ne cree pas de point supplementaire - * + * */ { int cX, cY; @@ -651,7 +651,7 @@ TRACK* CreateLockPoint( int* pX, int* pY, TRACK* ptsegm, TRACK* refsegm ) /* pour que le point soit sur le segment ptsegm: cY/cX = dy/dx */ if( dx == 0 ) - cX = 0; /* segm horizontal */ + cX = 0;/* segm horizontal */ else cY = (cX * dy) / dx; diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 899768efc9..77774e26cc 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -95,7 +95,7 @@ static void Abort_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC ) Panel->ManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL; - Panel->GetScreen()->m_CurrentItem = NULL; + Panel->GetScreen()->SetCurItem( NULL ); Panel->m_Parent->EraseMsgBox(); /* Annulation deplacement et Redessin des segments dragges */ @@ -191,22 +191,22 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel, * > s_MovingSegmentSlope slope = moving track segment slope * > s_StartSegmentSlope slope = slope of the segment connected to the start point of the moving segment * > s_EndSegmentSlope slope = slope of the segment connected to the end point of the moving segment - * + * * moved segment function : * yt=s_MovingSegmentSlope * x + s_MovingSegment_Yorg - * + * * segment connected to moved segment's start: * y1 = s_StartSegmentSlope * x + s_StartSegment_Yorg - * + * * segment connected to moved segment's end: * y2=s_EndSegmentSlope * x + s_EndSegment_Yorg - * + * * first intersection point will be located at * y1=yt -> * xi1=(s_MovingSegment_Yorg-s_StartSegment_Yorg)/(s_StartSegmentSlope-s_MovingSegmentSlope) * yi1=s_MovingSegmentSlope*xi1+s_MovingSegment_Yorg * or yi1=s_StartSegmentSlope*xi1+s_MovingSegment_Yorg - * + * * second intersection point * y2=yt -> * xi2=(s_MovingSegment_Yorg-s_StartSegment_Yorg)/(s_MovingSegmentSlope-s_MovingSegmentSlope) @@ -218,7 +218,7 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel, * !!!!! intersection point will be calculated using the * !!!!! segment intersecting it * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * + * * Slope parametres are computed once, because they can become undetermined when moving segments * (i.e. when a segment lenght is 0) and we want keep them constant */ @@ -888,7 +888,7 @@ TRACK* CreateLockPoint( int* pX, int* pY, TRACK* ptsegm, TRACK* refsegm ) * Si ptsegm pointe sur une via: * retourne la valeur exacte de pX et pY et ptsegm, * mais ne cree pas de point supplementaire - * + * */ { int cX, cY; @@ -926,7 +926,7 @@ TRACK* CreateLockPoint( int* pX, int* pY, TRACK* ptsegm, TRACK* refsegm ) /* pour que le point soit sur le segment ptsegm: cY/cX = dy/dx */ if( dx == 0 ) - cX = 0; /* segm horizontal */ + cX = 0;/* segm horizontal */ else cY = (cX * dy) / dx; diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index 5733058035..f5c7060236 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -96,7 +96,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveBasicShape( wxDC* DC, static void Exit_Muonde( WinEDA_DrawFrame* frame, wxDC* DC ) /**********************************************************/ { - MODULE* Module = (MODULE*) frame->m_CurrentScreen->m_CurrentItem; + MODULE* Module = (MODULE*) frame->m_CurrentScreen->GetCurItem(); if( Module ) { @@ -113,7 +113,7 @@ static void Exit_Muonde( WinEDA_DrawFrame* frame, wxDC* DC ) frame->DrawPanel->ManageCurseur = NULL; frame->DrawPanel->ForceCloseManageCurseur = NULL; - frame->m_CurrentScreen->m_CurrentItem = NULL; + frame->m_CurrentScreen->SetCurItem( NULL ); } diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index 7995a8ab22..75023cb3b2 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -25,6 +25,7 @@ #include "Delete_Line.xpm" #include "Delete_Track.xpm" #include "Move_Module.xpm" + //#include "Move_Track_Segment.xpm" #include "Drag_Track_Segment.xpm" #include "Drag_Segment_WithSlope.xpm" @@ -55,705 +56,733 @@ #include "Flag.xpm" - /* local functions */ -static void CreatePopupMenuForTracks(TRACK * Track, wxPoint CursorPosition, - wxMenu * PopMenu); -static void CreatePopUpMenuForFootprints(MODULE * Footprint, wxMenu * menu, bool full_menu); -static void CreatePopUpMenuForFpTexts(TEXTE_MODULE * FpText, wxMenu * menu); -static void CreatePopUpMenuForPads(D_PAD * Pad, wxMenu * menu); -static void CreatePopUpMenuForTexts(TEXTE_PCB * Text, wxMenu * menu); -static void CreatePopUpBlockMenu(wxMenu * menu); - +static void CreatePopupMenuForTracks( TRACK* Track, wxPoint CursorPosition, + wxMenu* PopMenu ); +static void CreatePopUpMenuForFootprints( MODULE* Footprint, wxMenu* menu, bool full_menu ); +static void CreatePopUpMenuForFpTexts( TEXTE_MODULE* FpText, wxMenu* menu ); +static void CreatePopUpMenuForPads( D_PAD* Pad, wxMenu* menu ); +static void CreatePopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu ); +static void CreatePopUpBlockMenu( wxMenu* menu ); /*****/ /********************************************/ -static wxMenu * Append_Track_Width_List(void) +static wxMenu* Append_Track_Width_List( void ) /********************************************/ + /* Ajoute au menu wxMenu * menu un sous-menu liste des epaisseurs de pistes -disponibles -*/ + * disponibles + */ { -int ii; -wxString msg; -wxMenu * trackwidth; -double value; + int ii; + wxString msg; + wxMenu* trackwidth; + double value; - trackwidth = new wxMenu; - for ( ii = 0; ii < 6; ii++ ) - { - if ( g_DesignSettings.m_TrackWidhtHistory[ii] == 0 ) break; - value = To_User_Unit(g_UnitMetric, g_DesignSettings.m_TrackWidhtHistory[ii], PCB_INTERNAL_UNIT); - if ( g_UnitMetric == INCHES ) // Affichage en mils - msg.Printf(_("Track %.1f"), value * 1000); - else - msg.Printf(_("Track %.3f"), value); + trackwidth = new wxMenu; + for( ii = 0; ii < 6; ii++ ) + { + if( g_DesignSettings.m_TrackWidhtHistory[ii] == 0 ) + break; + value = To_User_Unit( g_UnitMetric, + g_DesignSettings.m_TrackWidhtHistory[ii], + PCB_INTERNAL_UNIT ); + if( g_UnitMetric == INCHES ) // Affichage en mils + msg.Printf( _( "Track %.1f" ), value * 1000 ); + else + msg.Printf( _( "Track %.3f" ), value ); - trackwidth->Append(ID_POPUP_PCB_SELECT_WIDTH1 + ii, msg, wxEmptyString, TRUE); - if( g_DesignSettings.m_TrackWidhtHistory[ii] == g_DesignSettings.m_CurrentTrackWidth ) - trackwidth->Check( ID_POPUP_PCB_SELECT_WIDTH1 + ii, TRUE); - } + trackwidth->Append( ID_POPUP_PCB_SELECT_WIDTH1 + ii, msg, wxEmptyString, TRUE ); + if( g_DesignSettings.m_TrackWidhtHistory[ii] == g_DesignSettings.m_CurrentTrackWidth ) + trackwidth->Check( ID_POPUP_PCB_SELECT_WIDTH1 + ii, TRUE ); + } - trackwidth->AppendSeparator(); - for ( ii = 0; ii < 4; ii++ ) - { - if ( g_DesignSettings.m_ViaSizeHistory[ii] == 0 ) break; - value = To_User_Unit(g_UnitMetric, g_DesignSettings.m_ViaSizeHistory[ii], PCB_INTERNAL_UNIT); - if ( g_UnitMetric == INCHES ) - msg.Printf(_("Via %.1f"), value * 1000); - else - msg.Printf(_("Via %.3f"), value); - trackwidth->Append( ID_POPUP_PCB_SELECT_VIASIZE1 + ii, msg, wxEmptyString, TRUE); - if( g_DesignSettings.m_ViaSizeHistory[ii] == g_DesignSettings.m_CurrentViaSize ) - trackwidth->Check( ID_POPUP_PCB_SELECT_VIASIZE1 + ii, TRUE); - } - return trackwidth; + trackwidth->AppendSeparator(); + for( ii = 0; ii < 4; ii++ ) + { + if( g_DesignSettings.m_ViaSizeHistory[ii] == 0 ) + break; + value = To_User_Unit( g_UnitMetric, + g_DesignSettings.m_ViaSizeHistory[ii], + PCB_INTERNAL_UNIT ); + if( g_UnitMetric == INCHES ) + msg.Printf( _( "Via %.1f" ), value * 1000 ); + else + msg.Printf( _( "Via %.3f" ), value ); + trackwidth->Append( ID_POPUP_PCB_SELECT_VIASIZE1 + ii, msg, wxEmptyString, TRUE ); + if( g_DesignSettings.m_ViaSizeHistory[ii] == g_DesignSettings.m_CurrentViaSize ) + trackwidth->Check( ID_POPUP_PCB_SELECT_VIASIZE1 + ii, TRUE ); + } + + return trackwidth; } /****************************************************************************/ -void WinEDA_PcbFrame::OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu) +void WinEDA_PcbFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) /****************************************************************************/ + /* Create the PopUp menu (click on right mouse button) -de la souris. - The ZOOM menu is added to this menu -*/ + * de la souris. + * The ZOOM menu is added to this menu + */ { -EDA_BaseStruct *DrawStruct = m_CurrentScreen->m_CurrentItem; -wxString msg; -int flags = 0; -bool locate_track = FALSE; -bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE); -wxClientDC dc(DrawPanel); + EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem(); + wxString msg; + int flags = 0; + bool locate_track = FALSE; + bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE); + wxClientDC dc( DrawPanel ); - DrawPanel->CursorOff(&dc); - DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu + DrawPanel->CursorOff( &dc ); + DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu - // Simple localisation des elements si possible - if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - if (m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOPLACE) - { - DrawStruct = Locate_Prefered_Module(m_Pcb, CURSEUR_OFF_GRILLE | VISIBLE_ONLY); - if ( DrawStruct ) ((MODULE*)DrawStruct)->Display_Infos(this); - else DrawStruct = PcbGeneralLocateAndDisplay(); - } - else DrawStruct = PcbGeneralLocateAndDisplay(); - } + // Simple localisation des elements si possible + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + if( m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOPLACE ) + { + DrawStruct = Locate_Prefered_Module( m_Pcb, CURSEUR_OFF_GRILLE | VISIBLE_ONLY ); + if( DrawStruct ) + ( (MODULE*) DrawStruct )->Display_Infos( this ); + else + DrawStruct = PcbGeneralLocateAndDisplay(); + } + else + DrawStruct = PcbGeneralLocateAndDisplay(); + } - // If command in progress: Put the Cancel command (if needed) and End command - if ( m_ID_current_state ) - { - if ( DrawStruct && DrawStruct->m_Flags ) - { - ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, - _("Cancel"), cancel_xpm); - } - else - { - ADD_MENUITEM(PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL, - _("End Tool"), cancel_tool_xpm); - } - PopMenu->AppendSeparator(); - } + // If command in progress: Put the Cancel command (if needed) and End command + if( m_ID_current_state ) + { + if( DrawStruct && DrawStruct->m_Flags ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, + _( "Cancel" ), cancel_xpm ); + } + else + { + ADD_MENUITEM( PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL, + _( "End Tool" ), cancel_tool_xpm ); + } + PopMenu->AppendSeparator(); + } + else + { + if( (DrawStruct && DrawStruct->m_Flags) || BlockActive ) + { + if( BlockActive ) + CreatePopUpBlockMenu( PopMenu ); + else + { + ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, + _( "Cancel" ), cancel_xpm ); + } + PopMenu->AppendSeparator(); + } + } - else - { - if ( (DrawStruct && DrawStruct->m_Flags) || BlockActive ) - { - if ( BlockActive ) - CreatePopUpBlockMenu(PopMenu); - else - { - ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, - _("Cancel"), cancel_xpm); - } - PopMenu->AppendSeparator(); - } - } + if( BlockActive ) + { + DrawPanel->CursorOn( &dc ); return; + } - if ( BlockActive ) - { - DrawPanel->CursorOn(&dc); return; - } + m_CurrentScreen->SetCurItem( DrawStruct ); - m_CurrentScreen->m_CurrentItem = DrawStruct; - - if ( DrawStruct ) flags = DrawStruct->m_Flags; - else flags = 0; - if( !flags ) - { - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST, - _("Get and Move Footprint"), Move_Module_xpm); - } - if ( DrawStruct ) - { - switch ( DrawStruct->m_StructType ) - { - case TYPEMODULE: - if( !flags ) CreatePopUpMenuForFootprints((MODULE *) DrawStruct, PopMenu, TRUE); - else CreatePopUpMenuForFootprints((MODULE *) DrawStruct, PopMenu, FALSE); + if( DrawStruct ) + flags = DrawStruct->m_Flags; + else + flags = 0; + + if( !flags ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST, + _( "Get and Move Footprint" ), Move_Module_xpm ); + } + if( DrawStruct ) + { + switch( DrawStruct->m_StructType ) + { + case TYPEMODULE: + if( !flags ) + CreatePopUpMenuForFootprints( (MODULE*) DrawStruct, PopMenu, TRUE ); + else + CreatePopUpMenuForFootprints( (MODULE*) DrawStruct, PopMenu, FALSE ); - if (m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOPLACE) - { - PopMenu->AppendSeparator(); - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE, _("Lock Module"), - Locked_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_AUTOPLACE_FREE_MODULE, _("Free Module"), - Unlocked_xpm); - if( !flags ) - PopMenu->Append( ID_POPUP_PCB_AUTOPLACE_CURRENT_MODULE, - _("Auto place Module")); - } + if( m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOPLACE ) + { + PopMenu->AppendSeparator(); + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE, _( "Lock Module" ), + Locked_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_AUTOPLACE_FREE_MODULE, _( "Free Module" ), + Unlocked_xpm ); + if( !flags ) + PopMenu->Append( ID_POPUP_PCB_AUTOPLACE_CURRENT_MODULE, + _( "Auto place Module" ) ); + } - if (m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOROUTE) - { - if( !flags ) - PopMenu->Append( ID_POPUP_PCB_AUTOROUTE_MODULE, _("Autoroute")); - } - break; + if( m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOROUTE ) + { + if( !flags ) + PopMenu->Append( ID_POPUP_PCB_AUTOROUTE_MODULE, _( "Autoroute" ) ); + } + break; - case TYPEPAD: - if( !flags ) - { - MODULE * Module = (MODULE *) DrawStruct->m_Parent; - if (Module) - { - CreatePopUpMenuForFootprints(Module, PopMenu, TRUE); - PopMenu->AppendSeparator(); - } - } - CreatePopUpMenuForPads( (D_PAD *)DrawStruct, PopMenu); - if (m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOROUTE) - { - if( !flags ) - { - PopMenu->Append( ID_POPUP_PCB_AUTOROUTE_PAD, _("Autoroute Pad")); - PopMenu->Append( ID_POPUP_PCB_AUTOROUTE_NET, _("Autoroute Net")); - } - } - break; + case TYPEPAD: + if( !flags ) + { + MODULE* Module = (MODULE*) DrawStruct->m_Parent; + if( Module ) + { + CreatePopUpMenuForFootprints( Module, PopMenu, TRUE ); + PopMenu->AppendSeparator(); + } + } + CreatePopUpMenuForPads( (D_PAD*) DrawStruct, PopMenu ); + if( m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOROUTE ) + { + if( !flags ) + { + PopMenu->Append( ID_POPUP_PCB_AUTOROUTE_PAD, _( "Autoroute Pad" ) ); + PopMenu->Append( ID_POPUP_PCB_AUTOROUTE_NET, _( "Autoroute Net" ) ); + } + } + break; - case TYPETEXTEMODULE: - if( !flags ) - { - MODULE * Module = (MODULE *) DrawStruct->m_Parent; - if (Module) - { - CreatePopUpMenuForFootprints(Module, PopMenu, TRUE); - PopMenu->AppendSeparator(); - } - } - CreatePopUpMenuForFpTexts( (TEXTE_MODULE *) DrawStruct, PopMenu); - break; + case TYPETEXTEMODULE: + if( !flags ) + { + MODULE* Module = (MODULE*) DrawStruct->m_Parent; + if( Module ) + { + CreatePopUpMenuForFootprints( Module, PopMenu, TRUE ); + PopMenu->AppendSeparator(); + } + } + CreatePopUpMenuForFpTexts( (TEXTE_MODULE*) DrawStruct, PopMenu ); + break; - case TYPEDRAWSEGMENT: - if( !flags ) - { - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_MOVE_DRAWING_REQUEST, - _("Move Drawing"), move_xpm); - } - if( flags & IS_NEW ) - { - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_STOP_CURRENT_DRAWING, - _("End Drawing"), apply_xpm); - } - PopMenu->Append(ID_POPUP_PCB_EDIT_DRAWING, _("Edit Drawing")); - PopMenu->Append(ID_POPUP_PCB_DELETE_DRAWING, _("Delete Drawing")); - break; + case TYPEDRAWSEGMENT: + if( !flags ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_DRAWING_REQUEST, + _( "Move Drawing" ), move_xpm ); + } + if( flags & IS_NEW ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_STOP_CURRENT_DRAWING, + _( "End Drawing" ), apply_xpm ); + } + PopMenu->Append( ID_POPUP_PCB_EDIT_DRAWING, _( "Edit Drawing" ) ); + PopMenu->Append( ID_POPUP_PCB_DELETE_DRAWING, _( "Delete Drawing" ) ); + break; - case TYPEEDGEZONE: - if( flags & IS_NEW ) - { - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE, - _("End edge zone"), apply_xpm); - } - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DELETE_EDGE_ZONE, - _("Delete edge zone"), delete_xpm); - break; + case TYPEEDGEZONE: + if( flags & IS_NEW ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE, + _( "End edge zone" ), apply_xpm ); + } + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_EDGE_ZONE, + _( "Delete edge zone" ), delete_xpm ); + break; - case TYPETEXTE: - CreatePopUpMenuForTexts( (TEXTE_PCB *) DrawStruct, PopMenu); - break; + case TYPETEXTE: + CreatePopUpMenuForTexts( (TEXTE_PCB*) DrawStruct, PopMenu ); + break; - case TYPETRACK: - case TYPEVIA: - locate_track = TRUE; - CreatePopupMenuForTracks( (TRACK *) DrawStruct, GetScreen()->m_Curseur, - PopMenu); - break; + case TYPETRACK: + case TYPEVIA: + locate_track = TRUE; + CreatePopupMenuForTracks( (TRACK*) DrawStruct, GetScreen()->m_Curseur, + PopMenu ); + break; - case TYPEZONE: - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_EDIT_ZONE, - _("Edit Zone"), edit_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DELETE_ZONE, - _("Delete Zone"), delete_xpm); - break; + case TYPEZONE: + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_ZONE, + _( "Edit Zone" ), edit_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_ZONE, + _( "Delete Zone" ), delete_xpm ); + break; - case TYPEMARQUEUR: - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DELETE_MARKER, - _("Delete Marker"), delete_xpm); - break; + case TYPEMARQUEUR: + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_MARKER, + _( "Delete Marker" ), delete_xpm ); + break; - case TYPECOTATION: - if( !flags ) - { - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_EDIT_COTATION, - _("Edit Cotation"), edit_xpm); - } - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DELETE_COTATION, - _("Delete Cotation"), delete_xpm); - break; + case TYPECOTATION: + if( !flags ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_COTATION, + _( "Edit Cotation" ), edit_xpm ); + } + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_COTATION, + _( "Delete Cotation" ), delete_xpm ); + break; - case TYPEMIRE: - if( !flags ) - { - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_MOVE_MIRE_REQUEST, - _("Move Mire"), move_xpm ); - } - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_EDIT_MIRE, - _("Edit Mire"), edit_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DELETE_MIRE, - _("Delete Mire"), delete_xpm); - break; + case TYPEMIRE: + if( !flags ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_MIRE_REQUEST, + _( "Move Mire" ), move_xpm ); + } + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_MIRE, + _( "Edit Mire" ), edit_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_MIRE, + _( "Delete Mire" ), delete_xpm ); + break; - case TYPEEDGEMODULE: - case TYPESCREEN: - case TYPE_NOT_INIT: - case TYPEPCB: - case PCB_EQUIPOT_STRUCT_TYPE: - msg.Printf( - wxT("WinEDA_PcbFrame::OnRightClick() Error: illegal DrawType %d"), - DrawStruct->m_StructType); - DisplayError(this, msg ); - break; + case TYPEEDGEMODULE: + case TYPESCREEN: + case TYPE_NOT_INIT: + case TYPEPCB: + case PCB_EQUIPOT_STRUCT_TYPE: + msg.Printf( + wxT( "WinEDA_PcbFrame::OnRightClick() Error: illegal DrawType %d" ), + DrawStruct->m_StructType ); + DisplayError( this, msg ); + break; - default: - msg.Printf( - wxT("WinEDA_PcbFrame::OnRightClick() Error: unknown DrawType %d"), - DrawStruct->m_StructType); - DisplayError(this, msg ); - break; - } - PopMenu->AppendSeparator(); - } + default: + msg.Printf( + wxT( "WinEDA_PcbFrame::OnRightClick() Error: unknown DrawType %d" ), + DrawStruct->m_StructType ); + DisplayError( this, msg ); + break; + } - /* Traitement des fonctions specifiques */ - switch ( m_ID_current_state ) - { - case ID_PCB_ZONES_BUTT: - { - bool add_separator = FALSE; - PopMenu->Append(ID_POPUP_PCB_FILL_ZONE, _("Fill zone") ); + PopMenu->AppendSeparator(); + } - if ( DrawStruct && - ( (DrawStruct->m_StructType == TYPEPAD) || - (DrawStruct->m_StructType == TYPETRACK) || - (DrawStruct->m_StructType == TYPEVIA) ) ) - { - add_separator = TRUE; - PopMenu->Append(ID_POPUP_PCB_SELECT_NET_ZONE, _("Select Net")); - } - if( m_Pcb->m_CurrentLimitZone ) - { - add_separator = TRUE; - PopMenu->Append(ID_POPUP_PCB_DELETE_ZONE_LIMIT, _("Delete Zone Limit")); - } - if ( add_separator ) PopMenu->AppendSeparator(); - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_SELECT_LAYER, - _("Select Working Layer"), Select_W_Layer_xpm); - PopMenu->AppendSeparator(); - } - break; + /* Traitement des fonctions specifiques */ + switch( m_ID_current_state ) + { + case ID_PCB_ZONES_BUTT: + { + bool add_separator = FALSE; + PopMenu->Append( ID_POPUP_PCB_FILL_ZONE, _( "Fill zone" ) ); - case ID_TRACK_BUTT: - { - ADD_MENUITEM_WITH_SUBMENU( PopMenu, Append_Track_Width_List(), - ID_POPUP_PCB_SELECT_WIDTH, - _("Select Track Width"), width_track_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_SELECT_CU_LAYER, - _("Select Working Layer"), Select_W_Layer_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_SELECT_LAYER_PAIR, - _("Select layer pair for vias"), select_layer_pair_xpm); - PopMenu->AppendSeparator(); - } - break; + if( DrawStruct + && ( (DrawStruct->m_StructType == TYPEPAD) + || (DrawStruct->m_StructType == TYPETRACK) + || (DrawStruct->m_StructType == TYPEVIA) ) ) + { + add_separator = TRUE; + PopMenu->Append( ID_POPUP_PCB_SELECT_NET_ZONE, _( "Select Net" ) ); + } + if( m_Pcb->m_CurrentLimitZone ) + { + add_separator = TRUE; + PopMenu->Append( ID_POPUP_PCB_DELETE_ZONE_LIMIT, _( "Delete Zone Limit" ) ); + } + if( add_separator ) + PopMenu->AppendSeparator(); + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_SELECT_LAYER, + _( "Select Working Layer" ), Select_W_Layer_xpm ); + PopMenu->AppendSeparator(); + } + break; - case ID_PCB_CIRCLE_BUTT: - case ID_PCB_ARC_BUTT: - case ID_TEXT_COMMENT_BUTT: - case ID_LINE_COMMENT_BUTT: - case ID_PCB_COTATION_BUTT: - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_SELECT_NO_CU_LAYER, - _("Select Working Layer"), Select_W_Layer_xpm); - PopMenu->AppendSeparator(); - break; + case ID_TRACK_BUTT: + { + ADD_MENUITEM_WITH_SUBMENU( PopMenu, Append_Track_Width_List(), + ID_POPUP_PCB_SELECT_WIDTH, + _( "Select Track Width" ), width_track_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_SELECT_CU_LAYER, + _( "Select Working Layer" ), Select_W_Layer_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_SELECT_LAYER_PAIR, + _( "Select layer pair for vias" ), select_layer_pair_xpm ); + PopMenu->AppendSeparator(); + } + break; - case ID_COMPONENT_BUTT: - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DISPLAY_FOOTPRINT_DOC, - _("Footprint documentation"), book_xpm); - PopMenu->AppendSeparator(); - break; + case ID_PCB_CIRCLE_BUTT: + case ID_PCB_ARC_BUTT: + case ID_TEXT_COMMENT_BUTT: + case ID_LINE_COMMENT_BUTT: + case ID_PCB_COTATION_BUTT: + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_SELECT_NO_CU_LAYER, + _( "Select Working Layer" ), Select_W_Layer_xpm ); + PopMenu->AppendSeparator(); + break; - case 0: - if (m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOPLACE) - { - wxMenu * commands = new wxMenu; - ADD_MENUITEM_WITH_SUBMENU(PopMenu, commands, - ID_POPUP_PCB_AUTOPLACE_COMMANDS, _("Glob Move and Place"), move_xpm); - ADD_MENUITEM(commands, ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES, - _("Free All Modules"), Unlocked_xpm); - ADD_MENUITEM(commands, ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES, - _("Fixe All Modules"), Locked_xpm); - commands->AppendSeparator(); - ADD_MENUITEM(commands, ID_POPUP_PCB_AUTOMOVE_ALL_MODULES, - _("Move All Modules"), move_xpm); - commands->Append( ID_POPUP_PCB_AUTOMOVE_NEW_MODULES, _("Move New Modules")); - commands->AppendSeparator(); - commands->Append( ID_POPUP_PCB_AUTOPLACE_ALL_MODULES, _("Autoplace All Modules")); - commands->Append( ID_POPUP_PCB_AUTOPLACE_NEW_MODULES, _("Autoplace New Modules")); - commands->Append( ID_POPUP_PCB_AUTOPLACE_NEXT_MODULE, _("Autoplace Next Module")); - commands->AppendSeparator(); - ADD_MENUITEM(commands, ID_POPUP_PCB_REORIENT_ALL_MODULES, - _("Orient All Modules"), rotate_module_pos_xpm); - PopMenu->AppendSeparator(); - } - if (m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOROUTE) - { - wxMenu * commands = new wxMenu; - PopMenu->Append(ID_POPUP_PCB_AUTOROUTE_COMMANDS, _("Global Autoroute"), commands); - ADD_MENUITEM(commands, ID_POPUP_PCB_SELECT_LAYER_PAIR, - _("Select layer pair"), select_layer_pair_xpm); - commands->AppendSeparator(); - commands->Append( ID_POPUP_PCB_AUTOROUTE_ALL_MODULES, _("Autoroute All Modules")); - commands->AppendSeparator(); - commands->Append( ID_POPUP_PCB_AUTOROUTE_RESET_UNROUTED, _("Reset Unrouted")); - if ( m_Pcb->m_Modules ) - { - commands->AppendSeparator(); - commands->Append( ID_POPUP_PCB_AUTOROUTE_GET_AUTOROUTER, - _("Global AutoRouter")); - commands->Append( ID_POPUP_PCB_AUTOROUTE_GET_AUTOROUTER_DATA, - _("Read Global AutoRouter Data")); - } - PopMenu->AppendSeparator(); - } + case ID_COMPONENT_BUTT: + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DISPLAY_FOOTPRINT_DOC, + _( "Footprint documentation" ), book_xpm ); + PopMenu->AppendSeparator(); + break; - if ( locate_track ) - ADD_MENUITEM_WITH_SUBMENU(PopMenu, Append_Track_Width_List(), - ID_POPUP_PCB_SELECT_WIDTH, _("Select Track Width"), - width_track_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_SELECT_LAYER, - _("Select Working Layer"), Select_W_Layer_xpm); - PopMenu->AppendSeparator(); - break; + case 0: + if( m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOPLACE ) + { + wxMenu* commands = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU( PopMenu, commands, + ID_POPUP_PCB_AUTOPLACE_COMMANDS, _( + "Glob Move and Place" ), move_xpm ); + ADD_MENUITEM( commands, ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES, + _( "Free All Modules" ), Unlocked_xpm ); + ADD_MENUITEM( commands, ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES, + _( "Fixe All Modules" ), Locked_xpm ); + commands->AppendSeparator(); + ADD_MENUITEM( commands, ID_POPUP_PCB_AUTOMOVE_ALL_MODULES, + _( "Move All Modules" ), move_xpm ); + commands->Append( ID_POPUP_PCB_AUTOMOVE_NEW_MODULES, _( "Move New Modules" ) ); + commands->AppendSeparator(); + commands->Append( ID_POPUP_PCB_AUTOPLACE_ALL_MODULES, _( "Autoplace All Modules" ) ); + commands->Append( ID_POPUP_PCB_AUTOPLACE_NEW_MODULES, _( "Autoplace New Modules" ) ); + commands->Append( ID_POPUP_PCB_AUTOPLACE_NEXT_MODULE, _( "Autoplace Next Module" ) ); + commands->AppendSeparator(); + ADD_MENUITEM( commands, ID_POPUP_PCB_REORIENT_ALL_MODULES, + _( "Orient All Modules" ), rotate_module_pos_xpm ); + PopMenu->AppendSeparator(); + } + if( m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOROUTE ) + { + wxMenu* commands = new wxMenu; + PopMenu->Append( ID_POPUP_PCB_AUTOROUTE_COMMANDS, _( "Global Autoroute" ), commands ); + ADD_MENUITEM( commands, ID_POPUP_PCB_SELECT_LAYER_PAIR, + _( "Select layer pair" ), select_layer_pair_xpm ); + commands->AppendSeparator(); + commands->Append( ID_POPUP_PCB_AUTOROUTE_ALL_MODULES, _( "Autoroute All Modules" ) ); + commands->AppendSeparator(); + commands->Append( ID_POPUP_PCB_AUTOROUTE_RESET_UNROUTED, _( "Reset Unrouted" ) ); + if( m_Pcb->m_Modules ) + { + commands->AppendSeparator(); + commands->Append( ID_POPUP_PCB_AUTOROUTE_GET_AUTOROUTER, + _( "Global AutoRouter" ) ); + commands->Append( ID_POPUP_PCB_AUTOROUTE_GET_AUTOROUTER_DATA, + _( "Read Global AutoRouter Data" ) ); + } + PopMenu->AppendSeparator(); + } - } + if( locate_track ) + ADD_MENUITEM_WITH_SUBMENU( PopMenu, Append_Track_Width_List(), + ID_POPUP_PCB_SELECT_WIDTH, _( "Select Track Width" ), + width_track_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_SELECT_LAYER, + _( "Select Working Layer" ), Select_W_Layer_xpm ); + PopMenu->AppendSeparator(); + break; + } - DrawPanel->CursorOn(&dc); + DrawPanel->CursorOn( &dc ); } /****************************************/ -void CreatePopUpBlockMenu(wxMenu * menu) +void CreatePopUpBlockMenu( wxMenu* menu ) /****************************************/ + /* Create Pop sub menu for block commands -*/ + */ { - ADD_MENUITEM(menu, ID_POPUP_CANCEL_CURRENT_COMMAND, - _("Cancel Block"), cancel_xpm ); - ADD_MENUITEM(menu, ID_POPUP_ZOOM_BLOCK, - _("Zoom Block (Midd butt drag)"), zoom_selected_xpm ); - menu->AppendSeparator(); - ADD_MENUITEM(menu, ID_POPUP_PLACE_BLOCK, - _("Place Block"), apply_xpm ); - ADD_MENUITEM(menu, ID_POPUP_COPY_BLOCK, - _("Copy Block (shift + drag mouse)"), copyblock_xpm ); - ADD_MENUITEM(menu, ID_POPUP_INVERT_BLOCK, - _("Flip Block (alt + drag mouse)"), invert_module_xpm ); - ADD_MENUITEM(menu, ID_POPUP_ROTATE_BLOCK, - _("Rotate Block (ctrl + drag mouse)"), rotate_pos_xpm ); - ADD_MENUITEM(menu, ID_POPUP_DELETE_BLOCK, - _("Delete Block (shift+ctrl + drag mouse)"), delete_xpm ); + ADD_MENUITEM( menu, ID_POPUP_CANCEL_CURRENT_COMMAND, + _( "Cancel Block" ), cancel_xpm ); + ADD_MENUITEM( menu, ID_POPUP_ZOOM_BLOCK, + _( "Zoom Block (Midd butt drag)" ), zoom_selected_xpm ); + menu->AppendSeparator(); + ADD_MENUITEM( menu, ID_POPUP_PLACE_BLOCK, + _( "Place Block" ), apply_xpm ); + ADD_MENUITEM( menu, ID_POPUP_COPY_BLOCK, + _( "Copy Block (shift + drag mouse)" ), copyblock_xpm ); + ADD_MENUITEM( menu, ID_POPUP_INVERT_BLOCK, + _( "Flip Block (alt + drag mouse)" ), invert_module_xpm ); + ADD_MENUITEM( menu, ID_POPUP_ROTATE_BLOCK, + _( "Rotate Block (ctrl + drag mouse)" ), rotate_pos_xpm ); + ADD_MENUITEM( menu, ID_POPUP_DELETE_BLOCK, + _( "Delete Block (shift+ctrl + drag mouse)" ), delete_xpm ); } /********************************************************************/ -void CreatePopupMenuForTracks(TRACK * Track, wxPoint CursorPosition, - wxMenu * PopMenu) +void CreatePopupMenuForTracks( TRACK* Track, wxPoint CursorPosition, + wxMenu* PopMenu ) /*******************************************************************/ + /* Create command lines for a popup menu, for track editing -*/ + */ { -int flags = Track->m_Flags; - - if ( flags == 0 ) - { - if ( Track->m_StructType == TYPEVIA) - { - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_MOVE_TRACK_NODE, _("Drag Via"), move_xpm); - wxMenu * via_mnu= new wxMenu(); - ADD_MENUITEM_WITH_SUBMENU(PopMenu, via_mnu, - ID_POPUP_PCB_VIA_EDITING, _("Edit Via"), edit_xpm); - ADD_MENUITEM(via_mnu, ID_POPUP_PCB_VIA_HOLE_TO_DEFAULT, - _("Set via hole to Default"), apply_xpm); - ADD_MENUITEM(via_mnu, ID_POPUP_PCB_VIA_HOLE_TO_VALUE, _("Set via hole to alt value"), options_new_pad_xpm); - ADD_MENUITEM(via_mnu, ID_POPUP_PCB_VIA_HOLE_ENTER_VALUE, _("Set the via hole alt value"), edit_xpm); - ADD_MENUITEM(via_mnu, ID_POPUP_PCB_VIA_HOLE_EXPORT, _("Export Via hole to alt value"), Export_Options_Pad_xpm); - ADD_MENUITEM(via_mnu, ID_POPUP_PCB_VIA_HOLE_EXPORT_TO_OTHERS, _("Export via hole to others id vias"), global_options_pad_xpm); - ADD_MENUITEM(via_mnu, ID_POPUP_PCB_VIA_HOLE_RESET_TO_DEFAULT, _("Set ALL via holes to default"), apply_xpm); - if ( Track->m_Drill <= 0 ) - { - via_mnu->Enable(ID_POPUP_PCB_VIA_HOLE_EXPORT,FALSE); - } - if ( g_ViaHoleLastValue <= 0 ) - via_mnu->Enable(ID_POPUP_PCB_VIA_HOLE_TO_VALUE,FALSE); - } - else - { - if ( Track->IsPointOnEnds(CursorPosition, -1) != 0 ) - { - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_MOVE_TRACK_NODE, - _("Move Node"), move_xpm); - } - else - { - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DRAG_TRACK_SEGMENT_KEEP_SLOPE, - _("Drag Segments, keep slope"), drag_segment_withslope_xpm); - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DRAG_TRACK_SEGMENT, - _("Drag Segment"), drag_track_segment_xpm); + int flags = Track->m_Flags; + + if( flags == 0 ) + { + if( Track->m_StructType == TYPEVIA ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_TRACK_NODE, _( "Drag Via" ), move_xpm ); + wxMenu* via_mnu = new wxMenu(); + ADD_MENUITEM_WITH_SUBMENU( PopMenu, via_mnu, + ID_POPUP_PCB_VIA_EDITING, _( "Edit Via" ), edit_xpm ); + ADD_MENUITEM( via_mnu, ID_POPUP_PCB_VIA_HOLE_TO_DEFAULT, + _( "Set via hole to Default" ), apply_xpm ); + ADD_MENUITEM( via_mnu, ID_POPUP_PCB_VIA_HOLE_TO_VALUE, _( + "Set via hole to alt value" ), options_new_pad_xpm ); + ADD_MENUITEM( via_mnu, ID_POPUP_PCB_VIA_HOLE_ENTER_VALUE, + _( "Set the via hole alt value" ), edit_xpm ); + ADD_MENUITEM( via_mnu, ID_POPUP_PCB_VIA_HOLE_EXPORT, _( + "Export Via hole to alt value" ), Export_Options_Pad_xpm ); + ADD_MENUITEM( via_mnu, ID_POPUP_PCB_VIA_HOLE_EXPORT_TO_OTHERS, + _( "Export via hole to others id vias" ), global_options_pad_xpm ); + ADD_MENUITEM( via_mnu, ID_POPUP_PCB_VIA_HOLE_RESET_TO_DEFAULT, + _( "Set ALL via holes to default" ), apply_xpm ); + if( Track->m_Drill <= 0 ) + { + via_mnu->Enable( ID_POPUP_PCB_VIA_HOLE_EXPORT, FALSE ); + } + if( g_ViaHoleLastValue <= 0 ) + via_mnu->Enable( ID_POPUP_PCB_VIA_HOLE_TO_VALUE, FALSE ); + } + else + { + if( Track->IsPointOnEnds( CursorPosition, -1 ) != 0 ) + { + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_TRACK_NODE, + _( "Move Node" ), move_xpm ); + } + else + { + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DRAG_TRACK_SEGMENT_KEEP_SLOPE, + _( "Drag Segments, keep slope" ), drag_segment_withslope_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DRAG_TRACK_SEGMENT, + _( "Drag Segment" ), drag_track_segment_xpm ); #if 0 - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_MOVE_TRACK_SEGMENT, - _("Move Segment"), move_track_segment_xpm); + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_TRACK_SEGMENT, + _( "Move Segment" ), move_track_segment_xpm ); #endif - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_BREAK_TRACK, - _("Break Track"), Break_Line_xpm); - } - } - } - - else if( flags & IS_DRAGGED ) // Drag via or node in progress - { - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_PLACE_MOVED_TRACK_NODE, - _("Place Node"), apply_xpm); - return; - } - - else // Edition in progress - { - if( flags & IS_NEW ) - ADD_MENUITEM(PopMenu, ID_POPUP_PCB_END_TRACK, _("End Track (end)"), apply_xpm); - PopMenu->Append(ID_POPUP_PCB_PLACE_VIA, _("Place Via (V)")); - } - - // track Width control : - wxMenu * track_mnu = new wxMenu; - ADD_MENUITEM_WITH_SUBMENU(PopMenu, track_mnu, - ID_POPUP_PCB_EDIT_TRACK_MNU, _("Change Width"), width_track_xpm); - ADD_MENUITEM(track_mnu, ID_POPUP_PCB_EDIT_TRACKSEG, - _("Edit Segment"), width_segment_xpm); - if( !flags ) - { - ADD_MENUITEM(track_mnu, ID_POPUP_PCB_EDIT_TRACK, - _("Edit Track"), width_track_xpm); - ADD_MENUITEM(track_mnu, ID_POPUP_PCB_EDIT_NET, - _("Edit Net"), width_net_xpm); - ADD_MENUITEM(track_mnu, ID_POPUP_PCB_EDIT_ALL_VIAS_AND_TRACK_SIZE, - _("Edit ALL Tracks and Vias"), width_track_via_xpm); - ADD_MENUITEM(track_mnu, ID_POPUP_PCB_EDIT_ALL_VIAS_SIZE, - _("Edit ALL Vias (no track)"), width_vias_xpm); - ADD_MENUITEM(track_mnu, ID_POPUP_PCB_EDIT_ALL_TRACK_SIZE, - _("Edit ALL Tracks (no via)"), width_track_xpm); - } + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_BREAK_TRACK, + _( "Break Track" ), Break_Line_xpm ); + } + } + } + else if( flags & IS_DRAGGED ) // Drag via or node in progress + { + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_PLACE_MOVED_TRACK_NODE, + _( "Place Node" ), apply_xpm ); + return; + } + else // Edition in progress + { + if( flags & IS_NEW ) + ADD_MENUITEM( PopMenu, ID_POPUP_PCB_END_TRACK, _( "End Track (end)" ), apply_xpm ); + PopMenu->Append( ID_POPUP_PCB_PLACE_VIA, _( "Place Via (V)" ) ); + } - // Delete control: - track_mnu = new wxMenu; - ADD_MENUITEM_WITH_SUBMENU( PopMenu, track_mnu, - ID_POPUP_PCB_DELETE_TRACK_MNU, _("Delete"), delete_xpm); - ADD_MENUITEM(track_mnu, ID_POPUP_PCB_DELETE_TRACKSEG, - _("Delete Segment (backspace)"), Delete_Line_xpm); - if( !flags ) - { - ADD_MENUITEM(track_mnu, ID_POPUP_PCB_DELETE_TRACK, - _("Delete Track (delete)"), Delete_Track_xpm); - ADD_MENUITEM(track_mnu, ID_POPUP_PCB_DELETE_TRACKNET, - _("Delete Net"), Delete_Net_xpm); - } - track_mnu = new wxMenu; - ADD_MENUITEM_WITH_SUBMENU( PopMenu, track_mnu, - ID_POPUP_PCB_SETFLAGS_TRACK_MNU, _("Set Flags"), Flag_xpm); - track_mnu->Append(ID_POPUP_PCB_LOCK_ON_TRACKSEG, _("Locked: Yes"), wxEmptyString, TRUE); - track_mnu->Append(ID_POPUP_PCB_LOCK_OFF_TRACKSEG, _("Locked: No"), wxEmptyString, TRUE); - if( Track->GetState(SEGM_FIXE) ) - track_mnu->Check( ID_POPUP_PCB_LOCK_ON_TRACKSEG, TRUE); - else track_mnu->Check( ID_POPUP_PCB_LOCK_OFF_TRACKSEG, TRUE); + // track Width control : + wxMenu* track_mnu = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU( PopMenu, track_mnu, + ID_POPUP_PCB_EDIT_TRACK_MNU, _( "Change Width" ), width_track_xpm ); + ADD_MENUITEM( track_mnu, ID_POPUP_PCB_EDIT_TRACKSEG, + _( "Edit Segment" ), width_segment_xpm ); + if( !flags ) + { + ADD_MENUITEM( track_mnu, ID_POPUP_PCB_EDIT_TRACK, + _( "Edit Track" ), width_track_xpm ); + ADD_MENUITEM( track_mnu, ID_POPUP_PCB_EDIT_NET, + _( "Edit Net" ), width_net_xpm ); + ADD_MENUITEM( track_mnu, ID_POPUP_PCB_EDIT_ALL_VIAS_AND_TRACK_SIZE, + _( "Edit ALL Tracks and Vias" ), width_track_via_xpm ); + ADD_MENUITEM( track_mnu, ID_POPUP_PCB_EDIT_ALL_VIAS_SIZE, + _( "Edit ALL Vias (no track)" ), width_vias_xpm ); + ADD_MENUITEM( track_mnu, ID_POPUP_PCB_EDIT_ALL_TRACK_SIZE, + _( "Edit ALL Tracks (no via)" ), width_track_xpm ); + } - if( !flags ) - { - track_mnu->AppendSeparator(); - track_mnu->Append(ID_POPUP_PCB_LOCK_ON_TRACK, _("Track Locked: Yes")); - track_mnu->Append(ID_POPUP_PCB_LOCK_OFF_TRACK, _("Track Locked: No")); - track_mnu->AppendSeparator(); - track_mnu->Append(ID_POPUP_PCB_LOCK_ON_NET, _("Net Locked: Yes")); - track_mnu->Append(ID_POPUP_PCB_LOCK_OFF_NET, _("Net Locked: No")); - } + // Delete control: + track_mnu = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU( PopMenu, track_mnu, + ID_POPUP_PCB_DELETE_TRACK_MNU, _( "Delete" ), delete_xpm ); + ADD_MENUITEM( track_mnu, ID_POPUP_PCB_DELETE_TRACKSEG, + _( "Delete Segment (backspace)" ), Delete_Line_xpm ); + if( !flags ) + { + ADD_MENUITEM( track_mnu, ID_POPUP_PCB_DELETE_TRACK, + _( "Delete Track (delete)" ), Delete_Track_xpm ); + ADD_MENUITEM( track_mnu, ID_POPUP_PCB_DELETE_TRACKNET, + _( "Delete Net" ), Delete_Net_xpm ); + } + track_mnu = new wxMenu; + + ADD_MENUITEM_WITH_SUBMENU( PopMenu, track_mnu, + ID_POPUP_PCB_SETFLAGS_TRACK_MNU, _( "Set Flags" ), Flag_xpm ); + track_mnu->Append( ID_POPUP_PCB_LOCK_ON_TRACKSEG, _( "Locked: Yes" ), wxEmptyString, TRUE ); + track_mnu->Append( ID_POPUP_PCB_LOCK_OFF_TRACKSEG, _( "Locked: No" ), wxEmptyString, TRUE ); + + if( Track->GetState( SEGM_FIXE ) ) + track_mnu->Check( ID_POPUP_PCB_LOCK_ON_TRACKSEG, TRUE ); + else + track_mnu->Check( ID_POPUP_PCB_LOCK_OFF_TRACKSEG, TRUE ); + + if( !flags ) + { + track_mnu->AppendSeparator(); + track_mnu->Append( ID_POPUP_PCB_LOCK_ON_TRACK, _( "Track Locked: Yes" ) ); + track_mnu->Append( ID_POPUP_PCB_LOCK_OFF_TRACK, _( "Track Locked: No" ) ); + track_mnu->AppendSeparator(); + track_mnu->Append( ID_POPUP_PCB_LOCK_ON_NET, _( "Net Locked: Yes" ) ); + track_mnu->Append( ID_POPUP_PCB_LOCK_OFF_NET, _( "Net Locked: No" ) ); + } } + /*********************************************************************************/ -void CreatePopUpMenuForFootprints(MODULE * Module, wxMenu * menu, bool full_menu) +void CreatePopUpMenuForFootprints( MODULE* Module, wxMenu* menu, bool full_menu ) /*********************************************************************************/ + /* Create the wxMenuitem list for footprint editing -*/ + */ { -wxMenu * sub_menu_footprint; -wxString msg; -int flags = Module->m_Flags; - - msg = _("Footprint"); - msg << wxT(" ") << Module->m_Reference->m_Text; + wxMenu* sub_menu_footprint; + wxString msg; + int flags = Module->m_Flags; - sub_menu_footprint = new wxMenu; - ADD_MENUITEM_WITH_SUBMENU(menu, sub_menu_footprint, -1, msg, module_xpm) - if ( full_menu ) - { - ADD_MENUITEM(sub_menu_footprint, ID_POPUP_PCB_MOVE_MODULE_REQUEST, - _("Move (M)"), Move_Module_xpm) - ADD_MENUITEM(sub_menu_footprint, ID_POPUP_PCB_DRAG_MODULE_REQUEST, - _("Drag (G)"), Drag_Module_xpm); - } - ADD_MENUITEM(sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE, - _("Rotate + (R)"), rotate_module_pos_xpm); - ADD_MENUITEM(sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE, - _("Rotate -"), rotate_module_neg_xpm); - ADD_MENUITEM(sub_menu_footprint, ID_POPUP_PCB_CHANGE_SIDE_MODULE, - _("Flip (S)"), invert_module_xpm); - ADD_MENUITEM(sub_menu_footprint, ID_POPUP_PCB_EDIT_MODULE, - _("Edit"), Edit_Module_xpm); + msg = _( "Footprint" ); + msg << wxT( " " ) << Module->m_Reference->m_Text; - if( !flags ) - { - sub_menu_footprint->AppendSeparator(); - ADD_MENUITEM(sub_menu_footprint, ID_POPUP_PCB_DELETE_MODULE, - _("Delete Module"), Delete_Module_xpm); - } + sub_menu_footprint = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_footprint, -1, msg, module_xpm ) + if( full_menu ) + { + ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_MOVE_MODULE_REQUEST, + _( "Move (M)" ), Move_Module_xpm ) + ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_DRAG_MODULE_REQUEST, + _( "Drag (G)" ), Drag_Module_xpm ); + } + ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE, + _( "Rotate + (R)" ), rotate_module_pos_xpm ); + ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE, + _( "Rotate -" ), rotate_module_neg_xpm ); + ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_CHANGE_SIDE_MODULE, + _( "Flip (S)" ), invert_module_xpm ); + ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_EDIT_MODULE, + _( "Edit" ), Edit_Module_xpm ); + + if( !flags ) + { + sub_menu_footprint->AppendSeparator(); + ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_DELETE_MODULE, + _( "Delete Module" ), Delete_Module_xpm ); + } } /********************************************************************/ -void CreatePopUpMenuForFpTexts(TEXTE_MODULE * FpText, wxMenu * menu) +void CreatePopUpMenuForFpTexts( TEXTE_MODULE* FpText, wxMenu* menu ) /********************************************************************/ + /* Create the wxMenuitem list for editing texts on footprints -*/ + */ { -wxMenu * sub_menu_Fp_text; -wxString msg; -int flags = FpText->m_Flags; - - switch ( FpText->m_Type ) - { - case TEXT_is_REFERENCE: - msg = _("Footprint ref"); - break; + wxMenu* sub_menu_Fp_text; + wxString msg; + int flags = FpText->m_Flags; - case TEXT_is_VALUE: - msg = _("Footprint value"); - break; + switch( FpText->m_Type ) + { + case TEXT_is_REFERENCE: + msg = _( "Footprint ref" ); + break; - default: - msg = _("Footprint text"); - break; - } - msg << wxT(" ") << FpText->m_Text; + case TEXT_is_VALUE: + msg = _( "Footprint value" ); + break; - sub_menu_Fp_text = new wxMenu; - ADD_MENUITEM_WITH_SUBMENU(menu, sub_menu_Fp_text, -1, msg, footprint_text_xpm) + default: + msg = _( "Footprint text" ); + break; + } - if( !flags ) - ADD_MENUITEM(sub_menu_Fp_text, ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST, - _("Move"), Move_Field_xpm); + msg << wxT( " " ) << FpText->m_Text; - ADD_MENUITEM(sub_menu_Fp_text, ID_POPUP_PCB_ROTATE_TEXTMODULE, - _("Rotate"), Rotate_Field_xpm); - ADD_MENUITEM(sub_menu_Fp_text, ID_POPUP_PCB_EDIT_TEXTMODULE, - _("Edit"), edit_text_xpm); - if ( FpText->m_Type == TEXT_is_DIVERS) - ADD_MENUITEM(sub_menu_Fp_text, ID_POPUP_PCB_DELETE_TEXTMODULE, - _("Delete"), delete_xpm); + sub_menu_Fp_text = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_Fp_text, -1, msg, footprint_text_xpm ) + + if( !flags ) + ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST, + _( "Move" ), Move_Field_xpm ); + + ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_ROTATE_TEXTMODULE, + _( "Rotate" ), Rotate_Field_xpm ); + ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_EDIT_TEXTMODULE, + _( "Edit" ), edit_text_xpm ); + + if( FpText->m_Type == TEXT_is_DIVERS ) + ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_DELETE_TEXTMODULE, + _( "Delete" ), delete_xpm ); } /***************************************************************/ -void CreatePopUpMenuForPads( D_PAD * Pad, wxMenu * menu) +void CreatePopUpMenuForPads( D_PAD* Pad, wxMenu* menu ) /***************************************************************/ /* Create pop menu for pads */ { -wxMenu * sub_menu_Pad; -wxString msg; -int flags = Pad->m_Flags; - - msg = _("Pad"); - msg << wxT(" ") << Pad->ReturnStringPadName(); + wxMenu* sub_menu_Pad; + wxString msg; + int flags = Pad->m_Flags; - sub_menu_Pad = new wxMenu; - ADD_MENUITEM_WITH_SUBMENU(menu, sub_menu_Pad, -1, msg, pad_xpm) - if( !flags ) - { - ADD_MENUITEM(sub_menu_Pad, ID_POPUP_PCB_MOVE_PAD_REQUEST, - _("Move"), move_pad_xpm); - ADD_MENUITEM(sub_menu_Pad, ID_POPUP_PCB_DRAG_PAD_REQUEST, - _("Drag"), drag_pad_xpm); - } - ADD_MENUITEM(sub_menu_Pad, ID_POPUP_PCB_EDIT_PAD, _("Edit Pad"), options_pad_xpm); - sub_menu_Pad->AppendSeparator(); - ADD_MENUITEM(sub_menu_Pad, ID_POPUP_PCB_IMPORT_PAD_SETTINGS, - _("New Pad Settings"), options_new_pad_xpm); - ADD_MENUITEM(sub_menu_Pad, ID_POPUP_PCB_EXPORT_PAD_SETTINGS, - _("Export Pad Settings"), Export_Options_Pad_xpm); + msg = _( "Pad" ); + msg << wxT( " " ) << Pad->ReturnStringPadName(); - if( !flags ) - { - ADD_MENUITEM(sub_menu_Pad, ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS, - _("Global Pad Settings"), global_options_pad_xpm); - sub_menu_Pad->AppendSeparator(); - ADD_MENUITEM(sub_menu_Pad, ID_POPUP_PCB_DELETE_PAD, - _("delete"), Delete_Pad_xpm); - } + sub_menu_Pad = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_Pad, -1, msg, pad_xpm ) + if( !flags ) + { + ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_MOVE_PAD_REQUEST, + _( "Move" ), move_pad_xpm ); + ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_DRAG_PAD_REQUEST, + _( "Drag" ), drag_pad_xpm ); + } + ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_EDIT_PAD, _( "Edit Pad" ), options_pad_xpm ); + sub_menu_Pad->AppendSeparator(); + ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_IMPORT_PAD_SETTINGS, + _( "New Pad Settings" ), options_new_pad_xpm ); + ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_EXPORT_PAD_SETTINGS, + _( "Export Pad Settings" ), Export_Options_Pad_xpm ); + + if( !flags ) + { + ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS, + _( "Global Pad Settings" ), global_options_pad_xpm ); + sub_menu_Pad->AppendSeparator(); + ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_DELETE_PAD, + _( "delete" ), Delete_Pad_xpm ); + } } /*************************************************************/ -void CreatePopUpMenuForTexts(TEXTE_PCB * Text, wxMenu * menu) +void CreatePopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu ) /*************************************************************/ /* Create pop menu for pcb texts */ { -wxMenu * sub_menu_Text; -wxString msg; -int flags = Text->m_Flags; - - msg = _("Pcb Text");msg << wxT(" "); - if ( Text->m_Text.Len() < 8 ) - msg << Text->m_Text; - else - msg += Text->m_Text.Left(5) + wxT(".."); + wxMenu* sub_menu_Text; + wxString msg; + int flags = Text->m_Flags; - sub_menu_Text = new wxMenu; - ADD_MENUITEM_WITH_SUBMENU(menu, sub_menu_Text, -1, msg, add_text_xpm) + msg = _( "Pcb Text" ); msg << wxT( " " ); + if( Text->m_Text.Len() < 8 ) + msg << Text->m_Text; + else + msg += Text->m_Text.Left( 5 ) + wxT( ".." ); - if( !flags ) - { - ADD_MENUITEM(sub_menu_Text, ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST, - _("Move"), move_text_xpm); - } - ADD_MENUITEM(sub_menu_Text, ID_POPUP_PCB_ROTATE_TEXTEPCB, - _("Rotate"), rotate_pos_xpm); - ADD_MENUITEM(sub_menu_Text, ID_POPUP_PCB_EDIT_TEXTEPCB, - _("Edit"), edit_text_xpm); + sub_menu_Text = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_Text, -1, msg, add_text_xpm ) - sub_menu_Text->AppendSeparator(); - ADD_MENUITEM(sub_menu_Text, ID_POPUP_PCB_DELETE_TEXTEPCB, - _("Delete"), delete_text_xpm); + if( !flags ) + { + ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST, + _( "Move" ), move_text_xpm ); + } + ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_ROTATE_TEXTEPCB, + _( "Rotate" ), rotate_pos_xpm ); + ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_EDIT_TEXTEPCB, + _( "Edit" ), edit_text_xpm ); + + sub_menu_Text->AppendSeparator(); + ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_DELETE_TEXTEPCB, + _( "Delete" ), delete_text_xpm ); } - diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 151f1ae414..4e4996b018 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -11,480 +11,551 @@ #include "protos.h" #include "id.h" +#if defined(DEBUG) +#include <class_collector.h> +#endif - /*******************************/ - /* class WinEDA_PcbFrame */ - /*******************************/ +/*******************************/ +/* class WinEDA_PcbFrame */ +/*******************************/ -BEGIN_EVENT_TABLE(WinEDA_PcbFrame, wxFrame) +BEGIN_EVENT_TABLE( WinEDA_PcbFrame, wxFrame ) - COMMON_EVENTS_DRAWFRAME - - EVT_SOCKET(ID_EDA_SOCKET_EVENT_SERV, WinEDA_PcbFrame::OnSockRequestServer) - EVT_SOCKET(ID_EDA_SOCKET_EVENT, WinEDA_PcbFrame::OnSockRequest) - - EVT_KICAD_CHOICEBOX(ID_ON_ZOOM_SELECT,WinEDA_PcbFrame::OnSelectZoom) - EVT_KICAD_CHOICEBOX(ID_ON_GRID_SELECT,WinEDA_PcbFrame::OnSelectGrid) - - EVT_CLOSE(WinEDA_PcbFrame::OnCloseWindow) - EVT_SIZE(WinEDA_PcbFrame::OnSize) - - EVT_TOOL_RANGE(ID_ZOOM_PLUS_BUTT, ID_ZOOM_PAGE_BUTT, - WinEDA_PcbFrame::Process_Zoom) - - EVT_TOOL(ID_LOAD_FILE, WinEDA_PcbFrame::Files_io) - EVT_TOOL(ID_MENU_READ_LAST_SAVED_VERSION_BOARD, WinEDA_PcbFrame::Files_io) - EVT_TOOL(ID_MENU_RECOVER_BOARD, WinEDA_PcbFrame::Files_io) - EVT_TOOL(ID_NEW_BOARD, WinEDA_PcbFrame::Files_io) - EVT_TOOL(ID_SAVE_BOARD, WinEDA_PcbFrame::Files_io) - EVT_TOOL(ID_OPEN_MODULE_EDITOR, WinEDA_PcbFrame::Process_Special_Functions) - - EVT_MENU_RANGE(ID_PREFERENCES_FONT_INFOSCREEN, ID_PREFERENCES_FONT_END, - WinEDA_DrawFrame::ProcessFontPreferences) - - // Menu Files: - - EVT_MENU(ID_MAIN_MENUBAR, WinEDA_PcbFrame::Process_Special_Functions) - - EVT_MENU(ID_MENU_LOAD_FILE, WinEDA_PcbFrame::Files_io) - EVT_MENU(ID_MENU_NEW_BOARD, WinEDA_PcbFrame::Files_io) - EVT_MENU(ID_MENU_SAVE_BOARD, WinEDA_PcbFrame::Files_io) - EVT_MENU(ID_MENU_APPEND_FILE, WinEDA_PcbFrame::Files_io) - EVT_MENU(ID_MENU_SAVE_BOARD_AS, WinEDA_PcbFrame::Files_io) - EVT_MENU(ID_GEN_PLOT, WinEDA_PcbFrame::ToPlotter) - EVT_MENU_RANGE(ID_LOAD_FILE_1,ID_LOAD_FILE_10, - WinEDA_PcbFrame::Files_io) - - EVT_MENU(ID_GEN_EXPORT_FILE_GENCADFORMAT, WinEDA_PcbFrame::ExportToGenCAD) - EVT_MENU(ID_GEN_EXPORT_FILE_MODULE_REPORT, WinEDA_PcbFrame::GenModuleReport) - - EVT_MENU(ID_MENU_ARCHIVE_NEW_MODULES, WinEDA_PcbFrame::Process_Special_Functions) - EVT_MENU(ID_MENU_ARCHIVE_ALL_MODULES, WinEDA_PcbFrame::Process_Special_Functions) - - EVT_MENU(ID_EXIT, WinEDA_PcbFrame::Process_Special_Functions) - - // menu Config - EVT_MENU(ID_CONFIG_REQ, WinEDA_PcbFrame::Process_Config) - EVT_MENU(ID_COLORS_SETUP, WinEDA_PcbFrame::Process_Config) - EVT_MENU(ID_OPTIONS_SETUP, WinEDA_PcbFrame::Process_Config) - EVT_MENU(ID_PCB_TRACK_SIZE_SETUP, WinEDA_PcbFrame::Process_Config) - EVT_MENU(ID_PCB_DRAWINGS_WIDTHS_SETUP, WinEDA_PcbFrame::Process_Config) - EVT_MENU(ID_PCB_PAD_SETUP, WinEDA_PcbFrame::Process_Config) - EVT_MENU(ID_PCB_LOOK_SETUP, WinEDA_PcbFrame::Process_Config) - EVT_MENU(ID_CONFIG_SAVE, WinEDA_PcbFrame::Process_Config) - EVT_MENU(ID_CONFIG_READ, WinEDA_PcbFrame::Process_Config) - EVT_MENU(ID_PCB_USER_GRID_SETUP, WinEDA_PcbFrame::Process_Special_Functions) - - EVT_MENU_RANGE(ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, - WinEDA_DrawFrame::SetLanguage) - - // menu Postprocess - EVT_MENU(ID_PCB_GEN_POS_MODULES_FILE,WinEDA_PcbFrame::GenModulesPosition) - EVT_MENU(ID_PCB_GEN_DRILL_FILE,WinEDA_PcbFrame::InstallDrillFrame) - EVT_MENU(ID_PCB_GEN_CMP_FILE,WinEDA_PcbFrame::Files_io) - - // menu Miscellaneous - EVT_MENU(ID_MENU_LIST_NETS, WinEDA_PcbFrame::Liste_Equipot) - EVT_MENU(ID_PCB_GLOBAL_DELETE, WinEDA_PcbFrame::Process_Special_Functions) - EVT_MENU(ID_MENU_PCB_CLEAN, WinEDA_PcbFrame::Process_Special_Functions) - EVT_MENU(ID_MENU_PCB_SWAP_LAYERS, WinEDA_PcbFrame::Process_Special_Functions) - - // Menu Help - EVT_MENU(ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp) - EVT_MENU(ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout) - - // Menu 3D Frame - EVT_MENU(ID_MENU_PCB_SHOW_3D_FRAME, WinEDA_PcbFrame::Show3D_Frame) - - // Horizontal toolbar - EVT_TOOL(ID_TO_LIBRARY, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_SHEET_SET, WinEDA_DrawFrame::Process_PageSettings) - EVT_TOOL(wxID_CUT, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(wxID_COPY, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(wxID_PASTE, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_UNDO_BUTT, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_GEN_PRINT, WinEDA_DrawFrame::ToPrinter) - EVT_TOOL(ID_GEN_PLOT, WinEDA_DrawFrame::Process_Special_Functions) - EVT_TOOL(ID_FIND_ITEMS, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_GET_NETLIST, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_DRC_CONTROL, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, WinEDA_PcbFrame::Process_Special_Functions) - EVT_KICAD_CHOICEBOX(ID_TOOLBARH_PCB_SELECT_LAYER, - WinEDA_PcbFrame::Process_Special_Functions) - EVT_KICAD_CHOICEBOX(ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, - WinEDA_PcbFrame::Process_Special_Functions) - EVT_KICAD_CHOICEBOX(ID_AUX_TOOLBAR_PCB_VIA_SIZE, - WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_TOOLBARH_PCB_AUTOPLACE, WinEDA_PcbFrame::AutoPlace) - EVT_TOOL(ID_TOOLBARH_PCB_AUTOROUTE, WinEDA_PcbFrame::AutoPlace) - - // Option toolbar - EVT_TOOL_RANGE(ID_TB_OPTIONS_START,ID_TB_OPTIONS_END, - WinEDA_PcbFrame::OnSelectOptionToolbar) - - // Vertical toolbar: - EVT_TOOL(ID_NO_SELECT_BUTT, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_PCB_HIGHLIGHT_BUTT, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_COMPONENT_BUTT, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_TRACK_BUTT, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_PCB_ZONES_BUTT, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_PCB_MIRE_BUTT, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_PCB_ARC_BUTT, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_PCB_CIRCLE_BUTT, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_TEXT_COMMENT_BUTT, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_LINE_COMMENT_BUTT, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_PCB_COTATION_BUTT, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_PCB_DELETE_ITEM_BUTT, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_PCB_SHOW_1_RATSNEST_BUTT, WinEDA_PcbFrame::Process_Special_Functions) - EVT_TOOL(ID_PCB_PLACE_OFFSET_COORD_BUTT, WinEDA_PcbFrame::Process_Special_Functions) - - EVT_TOOL_RANGE(ID_PCB_MUWAVE_START_CMD,ID_PCB_MUWAVE_END_CMD, - WinEDA_PcbFrame::ProcessMuWaveFunctions) - - EVT_TOOL_RCLICKED(ID_TRACK_BUTT, WinEDA_PcbFrame::ToolOnRightClick) - EVT_TOOL_RCLICKED(ID_PCB_CIRCLE_BUTT, WinEDA_PcbFrame::ToolOnRightClick) - EVT_TOOL_RCLICKED(ID_PCB_ARC_BUTT, WinEDA_PcbFrame::ToolOnRightClick) - EVT_TOOL_RCLICKED(ID_TEXT_COMMENT_BUTT, WinEDA_PcbFrame::ToolOnRightClick) - EVT_TOOL_RCLICKED(ID_LINE_COMMENT_BUTT, WinEDA_PcbFrame::ToolOnRightClick) - EVT_TOOL_RCLICKED(ID_PCB_COTATION_BUTT, WinEDA_PcbFrame::ToolOnRightClick) - - EVT_MENU_RANGE(ID_POPUP_PCB_AUTOPLACE_START_RANGE, - ID_POPUP_PCB_AUTOPLACE_END_RANGE, - WinEDA_PcbFrame::AutoPlace) - - EVT_MENU_RANGE(ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_END_RANGE, - WinEDA_PcbFrame::Process_Special_Functions) - - // Annulation de commande en cours - EVT_MENU_RANGE(ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, - WinEDA_PcbFrame::Process_Special_Functions ) - - // PopUp Menus pour Zooms traites dans drawpanel.cpp + COMMON_EVENTS_DRAWFRAME EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV, WinEDA_PcbFrame::OnSockRequestServer ) + EVT_SOCKET( ID_EDA_SOCKET_EVENT, WinEDA_PcbFrame::OnSockRequest ) + + EVT_KICAD_CHOICEBOX( ID_ON_ZOOM_SELECT, WinEDA_PcbFrame::OnSelectZoom ) + EVT_KICAD_CHOICEBOX( ID_ON_GRID_SELECT, WinEDA_PcbFrame::OnSelectGrid ) + + EVT_CLOSE( WinEDA_PcbFrame::OnCloseWindow ) + EVT_SIZE( WinEDA_PcbFrame::OnSize ) + + EVT_TOOL_RANGE( ID_ZOOM_PLUS_BUTT, ID_ZOOM_PAGE_BUTT, + WinEDA_PcbFrame::Process_Zoom ) + + EVT_TOOL( ID_LOAD_FILE, WinEDA_PcbFrame::Files_io ) + EVT_TOOL( ID_MENU_READ_LAST_SAVED_VERSION_BOARD, WinEDA_PcbFrame::Files_io ) + EVT_TOOL( ID_MENU_RECOVER_BOARD, WinEDA_PcbFrame::Files_io ) + EVT_TOOL( ID_NEW_BOARD, WinEDA_PcbFrame::Files_io ) + EVT_TOOL( ID_SAVE_BOARD, WinEDA_PcbFrame::Files_io ) + EVT_TOOL( ID_OPEN_MODULE_EDITOR, WinEDA_PcbFrame::Process_Special_Functions ) + + EVT_MENU_RANGE( ID_PREFERENCES_FONT_INFOSCREEN, ID_PREFERENCES_FONT_END, + WinEDA_DrawFrame::ProcessFontPreferences ) + + // Menu Files: + + EVT_MENU( ID_MAIN_MENUBAR, WinEDA_PcbFrame::Process_Special_Functions ) + + EVT_MENU( ID_MENU_LOAD_FILE, WinEDA_PcbFrame::Files_io ) + EVT_MENU( ID_MENU_NEW_BOARD, WinEDA_PcbFrame::Files_io ) + EVT_MENU( ID_MENU_SAVE_BOARD, WinEDA_PcbFrame::Files_io ) + EVT_MENU( ID_MENU_APPEND_FILE, WinEDA_PcbFrame::Files_io ) + EVT_MENU( ID_MENU_SAVE_BOARD_AS, WinEDA_PcbFrame::Files_io ) + EVT_MENU( ID_GEN_PLOT, WinEDA_PcbFrame::ToPlotter ) + EVT_MENU_RANGE( ID_LOAD_FILE_1, ID_LOAD_FILE_10, + WinEDA_PcbFrame::Files_io ) + + EVT_MENU( ID_GEN_EXPORT_FILE_GENCADFORMAT, WinEDA_PcbFrame::ExportToGenCAD ) + EVT_MENU( ID_GEN_EXPORT_FILE_MODULE_REPORT, WinEDA_PcbFrame::GenModuleReport ) + + EVT_MENU( ID_MENU_ARCHIVE_NEW_MODULES, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_MENU( ID_MENU_ARCHIVE_ALL_MODULES, WinEDA_PcbFrame::Process_Special_Functions ) + + EVT_MENU( ID_EXIT, WinEDA_PcbFrame::Process_Special_Functions ) + + // menu Config + EVT_MENU( ID_CONFIG_REQ, WinEDA_PcbFrame::Process_Config ) + EVT_MENU( ID_COLORS_SETUP, WinEDA_PcbFrame::Process_Config ) + EVT_MENU( ID_OPTIONS_SETUP, WinEDA_PcbFrame::Process_Config ) + EVT_MENU( ID_PCB_TRACK_SIZE_SETUP, WinEDA_PcbFrame::Process_Config ) + EVT_MENU( ID_PCB_DRAWINGS_WIDTHS_SETUP, WinEDA_PcbFrame::Process_Config ) + EVT_MENU( ID_PCB_PAD_SETUP, WinEDA_PcbFrame::Process_Config ) + EVT_MENU( ID_PCB_LOOK_SETUP, WinEDA_PcbFrame::Process_Config ) + EVT_MENU( ID_CONFIG_SAVE, WinEDA_PcbFrame::Process_Config ) + EVT_MENU( ID_CONFIG_READ, WinEDA_PcbFrame::Process_Config ) + EVT_MENU( ID_PCB_USER_GRID_SETUP, WinEDA_PcbFrame::Process_Special_Functions ) + + EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, + WinEDA_DrawFrame::SetLanguage ) + + // menu Postprocess + EVT_MENU( ID_PCB_GEN_POS_MODULES_FILE, WinEDA_PcbFrame::GenModulesPosition ) + EVT_MENU( ID_PCB_GEN_DRILL_FILE, WinEDA_PcbFrame::InstallDrillFrame ) + EVT_MENU( ID_PCB_GEN_CMP_FILE, WinEDA_PcbFrame::Files_io ) + + // menu Miscellaneous + EVT_MENU( ID_MENU_LIST_NETS, WinEDA_PcbFrame::Liste_Equipot ) + EVT_MENU( ID_PCB_GLOBAL_DELETE, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_MENU( ID_MENU_PCB_CLEAN, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_MENU( ID_MENU_PCB_SWAP_LAYERS, WinEDA_PcbFrame::Process_Special_Functions ) + + // Menu Help + EVT_MENU( ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp ) + EVT_MENU( ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout ) + + // Menu 3D Frame + EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, WinEDA_PcbFrame::Show3D_Frame ) + + // Horizontal toolbar + EVT_TOOL( ID_TO_LIBRARY, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_SHEET_SET, WinEDA_DrawFrame::Process_PageSettings ) + EVT_TOOL( wxID_CUT, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( wxID_COPY, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( wxID_PASTE, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_UNDO_BUTT, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_GEN_PRINT, WinEDA_DrawFrame::ToPrinter ) + EVT_TOOL( ID_GEN_PLOT, WinEDA_DrawFrame::Process_Special_Functions ) + EVT_TOOL( ID_FIND_ITEMS, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_GET_NETLIST, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_DRC_CONTROL, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_KICAD_CHOICEBOX( ID_TOOLBARH_PCB_SELECT_LAYER, + WinEDA_PcbFrame::Process_Special_Functions ) + EVT_KICAD_CHOICEBOX( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, + WinEDA_PcbFrame::Process_Special_Functions ) + EVT_KICAD_CHOICEBOX( ID_AUX_TOOLBAR_PCB_VIA_SIZE, + WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_TOOLBARH_PCB_AUTOPLACE, WinEDA_PcbFrame::AutoPlace ) + EVT_TOOL( ID_TOOLBARH_PCB_AUTOROUTE, WinEDA_PcbFrame::AutoPlace ) + + // Option toolbar + EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END, + WinEDA_PcbFrame::OnSelectOptionToolbar ) + + // Vertical toolbar: + EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_PCB_HIGHLIGHT_BUTT, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_COMPONENT_BUTT, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_TRACK_BUTT, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_PCB_ZONES_BUTT, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_PCB_MIRE_BUTT, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_PCB_ARC_BUTT, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_PCB_CIRCLE_BUTT, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_TEXT_COMMENT_BUTT, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_LINE_COMMENT_BUTT, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_PCB_COTATION_BUTT, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_PCB_DELETE_ITEM_BUTT, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_PCB_SHOW_1_RATSNEST_BUTT, WinEDA_PcbFrame::Process_Special_Functions ) + EVT_TOOL( ID_PCB_PLACE_OFFSET_COORD_BUTT, WinEDA_PcbFrame::Process_Special_Functions ) + + EVT_TOOL_RANGE( ID_PCB_MUWAVE_START_CMD, ID_PCB_MUWAVE_END_CMD, + WinEDA_PcbFrame::ProcessMuWaveFunctions ) + + EVT_TOOL_RCLICKED( ID_TRACK_BUTT, WinEDA_PcbFrame::ToolOnRightClick ) + EVT_TOOL_RCLICKED( ID_PCB_CIRCLE_BUTT, WinEDA_PcbFrame::ToolOnRightClick ) + EVT_TOOL_RCLICKED( ID_PCB_ARC_BUTT, WinEDA_PcbFrame::ToolOnRightClick ) + EVT_TOOL_RCLICKED( ID_TEXT_COMMENT_BUTT, WinEDA_PcbFrame::ToolOnRightClick ) + EVT_TOOL_RCLICKED( ID_LINE_COMMENT_BUTT, WinEDA_PcbFrame::ToolOnRightClick ) + EVT_TOOL_RCLICKED( ID_PCB_COTATION_BUTT, WinEDA_PcbFrame::ToolOnRightClick ) + + EVT_MENU_RANGE( ID_POPUP_PCB_AUTOPLACE_START_RANGE, + ID_POPUP_PCB_AUTOPLACE_END_RANGE, + WinEDA_PcbFrame::AutoPlace ) + + EVT_MENU_RANGE( ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_END_RANGE, + WinEDA_PcbFrame::Process_Special_Functions ) + + // Annulation de commande en cours + EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, + WinEDA_PcbFrame::Process_Special_Functions ) + + // PopUp Menus pour Zooms traites dans drawpanel.cpp END_EVENT_TABLE() + +#if defined(DEBUG) +class RAT1COLLECTOR : public COLLECTOR +{ +}; + + +class ARROWCOLLECTOR : public COLLECTOR +{ +}; +#endif + + + ///////****************************///////////: - /****************/ - /* Constructeur */ - /****************/ +/****************/ +/* Constructeur */ +/****************/ -WinEDA_PcbFrame::WinEDA_PcbFrame(wxWindow * father, WinEDA_App *parent, - const wxString & title, - const wxPoint& pos, const wxSize& size) : - WinEDA_BasePcbFrame(father, parent, PCB_FRAME, title, pos, size) +WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, WinEDA_App* parent, + const wxString& title, + const wxPoint& pos, const wxSize& size ) : + WinEDA_BasePcbFrame( father, parent, PCB_FRAME, title, pos, size ) { - m_FrameName = wxT("PcbFrame"); - m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines - m_Draw_Grid = g_ShowGrid; // TRUE pour avoir la grille dessinee - m_Draw_Sheet_Ref = TRUE; // TRUE pour avoir le cartouche dessine - m_Draw_Auxiliary_Axis = TRUE; - m_SelTrackWidthBox = NULL; - m_SelViaSizeBox = NULL; - m_SelLayerBox = NULL; - m_ZoomMaxValue = 2048; - m_SelTrackWidthBox_Changed = FALSE; - m_SelViaSizeBox_Changed = FALSE; + m_FrameName = wxT( "PcbFrame" ); + m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines + m_Draw_Grid = g_ShowGrid; // TRUE pour avoir la grille dessinee + m_Draw_Sheet_Ref = TRUE; // TRUE pour avoir le cartouche dessine + m_Draw_Auxiliary_Axis = TRUE; + m_SelTrackWidthBox = NULL; + m_SelViaSizeBox = NULL; + m_SelLayerBox = NULL; + m_ZoomMaxValue = 2048; + m_SelTrackWidthBox_Changed = FALSE; + m_SelViaSizeBox_Changed = FALSE; + +#if defined(DEBUG) + m_GeneralCollector = NULL; + m_RatsModuleCollector = NULL; +#endif - m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; - m_DisplayPadFill = DisplayOpt.DisplayPadFill; - m_DisplayPadNum = DisplayOpt.DisplayPadNum; + m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; + m_DisplayPadFill = DisplayOpt.DisplayPadFill; + m_DisplayPadNum = DisplayOpt.DisplayPadNum; - m_DisplayModEdge = DisplayOpt.DisplayModEdge; - m_DisplayModText = DisplayOpt.DisplayModText; + m_DisplayModEdge = DisplayOpt.DisplayModEdge; + m_DisplayModText = DisplayOpt.DisplayModText; - // Give an icon - SetIcon( wxICON(a_icon_pcbnew) ); + // Give an icon + SetIcon( wxICON( a_icon_pcbnew ) ); - m_InternalUnits = PCB_INTERNAL_UNIT; // Unites internes = 1/10000 inch - m_CurrentScreen = ScreenPcb; - GetSettings(); - SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y); + m_InternalUnits = PCB_INTERNAL_UNIT; // Unites internes = 1/10000 inch + m_CurrentScreen = ScreenPcb; + GetSettings(); + SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); - wxSize GridSize(500,500); - if ( m_Parent && m_Parent->m_EDA_Config ) - { - long SizeX, SizeY; - if ( m_Parent->m_EDA_Config->Read( wxT("PcbEditGrid_X"), &SizeX) && - m_Parent->m_EDA_Config->Read( wxT("PcbEditGrid_Y"), &SizeY) ) - { - GridSize.x = SizeX; - GridSize.y = SizeY; - } - m_Parent->m_EDA_Config->Read( wxT("PcbMagPadOpt"), & g_MagneticPadOption); - } - GetScreen()->SetGrid(GridSize); - - if ( DrawPanel ) DrawPanel->m_Block_Enable = TRUE; - ReCreateMenuBar(); - ReCreateHToolbar(); - ReCreateAuxiliaryToolbar(); - ReCreateVToolbar(); - ReCreateOptToolbar(); + wxSize GridSize( 500, 500 ); + + if( m_Parent && m_Parent->m_EDA_Config ) + { + long SizeX, SizeY; + + if( m_Parent->m_EDA_Config->Read( wxT( "PcbEditGrid_X" ), &SizeX ) + && m_Parent->m_EDA_Config->Read( wxT( "PcbEditGrid_Y" ), &SizeY ) ) + { + GridSize.x = SizeX; + GridSize.y = SizeY; + } + m_Parent->m_EDA_Config->Read( wxT( "PcbMagPadOpt" ), &g_MagneticPadOption ); + } + GetScreen()->SetGrid( GridSize ); + + if( DrawPanel ) + DrawPanel->m_Block_Enable = TRUE; + ReCreateMenuBar(); + ReCreateHToolbar(); + ReCreateAuxiliaryToolbar(); + ReCreateVToolbar(); + ReCreateOptToolbar(); } -WinEDA_PcbFrame::~WinEDA_PcbFrame(void) + +WinEDA_PcbFrame::~WinEDA_PcbFrame( void ) { - m_Parent->m_PcbFrame = NULL; - m_CurrentScreen = ScreenPcb; + m_Parent->m_PcbFrame = NULL; + m_CurrentScreen = ScreenPcb; } /********************************************************/ -void WinEDA_PcbFrame::OnCloseWindow(wxCloseEvent & Event) +void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event ) /********************************************************/ { -PCB_SCREEN * screen; + PCB_SCREEN* screen; - DrawPanel->m_AbortRequest = TRUE; + DrawPanel->m_AbortRequest = TRUE; - screen = ScreenPcb ; - while( screen ) - { - if(screen->IsModify()) break; - screen = screen->Next(); - } + screen = ScreenPcb; + while( screen ) + { + if( screen->IsModify() ) + break; + screen = screen->Next(); + } - if ( screen ) - { - unsigned ii; - wxMessageDialog dialog(this, _("Board modified, Save before exit ?"), - _("Confirmation"), wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT); - ii = dialog.ShowModal(); - switch ( ii ) - { - case wxID_CANCEL: - Event.Veto(); - return; + if( screen ) + { + unsigned ii; + wxMessageDialog dialog( this, _( "Board modified, Save before exit ?" ), + _( "Confirmation" ), wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | + wxYES_DEFAULT ); - case wxID_NO: - break; + ii = dialog.ShowModal(); - case wxID_OK: - case wxID_YES: - SavePcbFile(GetScreen()->m_FileName); - break; - } - } + switch( ii ) + { + case wxID_CANCEL: + Event.Veto(); + return; - while( screen ) // suppression flag modify pour eviter d'autres message - { - screen->ClrModify(); - screen = screen->Next(); - } + case wxID_NO: + break; - /* Reselection de l'ecran de base, - pour les evenements de refresh generes par wxWindows */ - m_CurrentScreen = ActiveScreen = ScreenPcb; + case wxID_OK: + case wxID_YES: + SavePcbFile( GetScreen()->m_FileName ); + break; + } + } - SaveSettings(); - if ( m_Parent && m_Parent->m_EDA_Config ) - { - wxSize GridSize = GetScreen()->GetGrid(); - m_Parent->m_EDA_Config->Write( wxT("PcbEditGrid_X"), (long)GridSize.x); - m_Parent->m_EDA_Config->Write( wxT("PcbEditGrid_Y"), (long)GridSize.y); - m_Parent->m_EDA_Config->Write( wxT("PcbMagPadOpt"), (long)g_MagneticPadOption); - } - Destroy(); + while( screen ) // suppression flag modify pour eviter d'autres message + { + screen->ClrModify(); + screen = screen->Next(); + } + + /* Reselection de l'ecran de base, + * pour les evenements de refresh generes par wxWindows */ + m_CurrentScreen = ActiveScreen = ScreenPcb; + + SaveSettings(); + if( m_Parent && m_Parent->m_EDA_Config ) + { + wxSize GridSize = GetScreen()->GetGrid(); + m_Parent->m_EDA_Config->Write( wxT( "PcbEditGrid_X" ), (long) GridSize.x ); + m_Parent->m_EDA_Config->Write( wxT( "PcbEditGrid_Y" ), (long) GridSize.y ); + m_Parent->m_EDA_Config->Write( wxT( "PcbMagPadOpt" ), (long) g_MagneticPadOption ); + } + Destroy(); } /***************************************/ -void WinEDA_PcbFrame::SetToolbars(void) +void WinEDA_PcbFrame::SetToolbars( void ) /***************************************/ + /* -Active ou desactive les tools des toolbars, en fonction des commandes -en cours -*/ + * Active ou desactive les tools des toolbars, en fonction des commandes + * en cours + */ { -int ii, jj; + int ii, jj; - if ( m_ID_current_state == ID_TRACK_BUTT ) - { - if ( Drc_On ) DrawPanel->SetCursor(wxCursor(wxCURSOR_PENCIL)); - else DrawPanel->SetCursor(wxCursor(wxCURSOR_QUESTION_ARROW)); - } + if( m_ID_current_state == ID_TRACK_BUTT ) + { + if( Drc_On ) + DrawPanel->SetCursor( wxCursor( wxCURSOR_PENCIL ) ); + else + DrawPanel->SetCursor( wxCursor( wxCURSOR_QUESTION_ARROW ) ); + } - if( m_HToolBar == NULL ) return; + if( m_HToolBar == NULL ) + return; - m_HToolBar->EnableTool(ID_SAVE_BOARD,m_CurrentScreen->IsModify()); + m_HToolBar->EnableTool( ID_SAVE_BOARD, m_CurrentScreen->IsModify() ); - if ( m_CurrentScreen->BlockLocate.m_Command == BLOCK_MOVE ) - { - m_HToolBar->EnableTool(wxID_CUT,TRUE); - m_HToolBar->EnableTool(wxID_COPY,TRUE); - } - else - { - m_HToolBar->EnableTool(wxID_CUT,FALSE); - m_HToolBar->EnableTool(wxID_COPY,FALSE); - } + if( m_CurrentScreen->BlockLocate.m_Command == BLOCK_MOVE ) + { + m_HToolBar->EnableTool( wxID_CUT, TRUE ); + m_HToolBar->EnableTool( wxID_COPY, TRUE ); + } + else + { + m_HToolBar->EnableTool( wxID_CUT, FALSE ); + m_HToolBar->EnableTool( wxID_COPY, FALSE ); + } - if ( g_UnDeleteStackPtr ) - { - m_HToolBar->EnableTool(wxID_PASTE,TRUE); - } - else - { - m_HToolBar->EnableTool(wxID_PASTE,FALSE); - } + if( g_UnDeleteStackPtr ) + { + m_HToolBar->EnableTool( wxID_PASTE, TRUE ); + } + else + { + m_HToolBar->EnableTool( wxID_PASTE, FALSE ); + } - if ( g_UnDeleteStackPtr ) - { - m_HToolBar->EnableTool(ID_UNDO_BUTT,TRUE); - } - else m_HToolBar->EnableTool(ID_UNDO_BUTT,FALSE); + if( g_UnDeleteStackPtr ) + { + m_HToolBar->EnableTool( ID_UNDO_BUTT, TRUE ); + } + else + m_HToolBar->EnableTool( ID_UNDO_BUTT, FALSE ); - if ( m_OptionsToolBar ) - { - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_DRC_OFF, - ! Drc_On); - m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_DRC_OFF, - Drc_On ? _("DRC Off (Disable !!!), Currently: DRC is active") : _("DRC On (Currently: DRC is inactive !!!)")); + if( m_OptionsToolBar ) + { + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_DRC_OFF, + !Drc_On ); + m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_DRC_OFF, Drc_On ? + _( "DRC Off (Disable !!!), Currently: DRC is active" ) : + _( "DRC On (Currently: DRC is inactive !!!)" ) ); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_MM, - g_UnitMetric == MILLIMETRE ? TRUE : FALSE); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_INCH, - g_UnitMetric == INCHES ? TRUE : FALSE); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM, + g_UnitMetric == MILLIMETRE ? TRUE : FALSE ); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, + g_UnitMetric == INCHES ? TRUE : FALSE ); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_POLAR_COORD, - DisplayOpt.DisplayPolarCood); - m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_POLAR_COORD, - DisplayOpt.DisplayPolarCood ? _("Polar Coords not show") : _("Display Polar Coords")); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, + DisplayOpt.DisplayPolarCood ); + m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_POLAR_COORD, + DisplayOpt.DisplayPolarCood ? + _( "Polar Coords not show" ) : + _( "Display Polar Coords" ) ); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_GRID, - m_Draw_Grid); - m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_GRID, - m_Draw_Grid ? _("Grid not show") : _("Show Grid")); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID, + m_Draw_Grid ); + m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID, + m_Draw_Grid ? _( "Grid not show" ) : _( "Show Grid" ) ); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_CURSOR, - g_CursorShape); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR, + g_CursorShape ); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_RATSNEST, - g_Show_Ratsnest); - m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_RATSNEST, - g_Show_Ratsnest ? _("General ratsnest not show") : _("Show General ratsnest")); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_RATSNEST, + g_Show_Ratsnest ); + m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_RATSNEST, + g_Show_Ratsnest ? + _( "General ratsnest not show" ) : _( "Show General ratsnest" ) ); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_MODULE_RATSNEST, - g_Show_Module_Ratsnest); - m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_MODULE_RATSNEST, - g_Show_Module_Ratsnest ? _("Module ratsnest not show") : _("Show Module ratsnest")); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_MODULE_RATSNEST, + g_Show_Module_Ratsnest ); + m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_RATSNEST, + g_Show_Module_Ratsnest ? + _( "Module ratsnest not show" ) : + _( "Show Module ratsnest" ) ); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_AUTO_DEL_TRACK, - g_AutoDeleteOldTrack); - m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_AUTO_DEL_TRACK, - g_AutoDeleteOldTrack ? _("Disable Auto Delete old Track") : _("Enable Auto Delete old Track")); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_AUTO_DEL_TRACK, + g_AutoDeleteOldTrack ); + + m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_AUTO_DEL_TRACK, + g_AutoDeleteOldTrack ? + _( "Disable Auto Delete old Track" ) : + _( "Enable Auto Delete old Track" ) ); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_ZONES, - DisplayOpt.DisplayZones); - m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_ZONES, - DisplayOpt.DisplayZones ? _("Do not Show Zones") : _("Show Zones")); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_ZONES, + DisplayOpt.DisplayZones ); + + m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_ZONES, + DisplayOpt.DisplayZones ? + _( "Do not Show Zones" ) : _( "Show Zones" ) ); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_PADS_SKETCH, - ! m_DisplayPadFill); - m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_PADS_SKETCH, - m_DisplayPadFill ? _("Show Pads Sketch mode") : _("Show pads filled mode")); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, + !m_DisplayPadFill ); + m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_PADS_SKETCH, + m_DisplayPadFill ? + _( "Show Pads Sketch mode" ) : + _( "Show pads filled mode" ) ); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, - ! m_DisplayPcbTrackFill); - m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, - m_DisplayPcbTrackFill ? _("Show Tracks Sketch mode") : _("Show Tracks filled mode")); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, + !m_DisplayPcbTrackFill ); + m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, + m_DisplayPcbTrackFill ? + _( "Show Tracks Sketch mode" ) : + _( "Show Tracks filled mode" ) ); - m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_HIGHT_CONTRAST_MODE, - DisplayOpt.ContrastModeDisplay); - m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_HIGHT_CONTRAST_MODE, - DisplayOpt.ContrastModeDisplay ? _("Normal Contrast Mode Display") : _("Hight Contrast Mode Display")); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_HIGHT_CONTRAST_MODE, + DisplayOpt.ContrastModeDisplay ); + m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_HIGHT_CONTRAST_MODE, + DisplayOpt.ContrastModeDisplay ? + _( "Normal Contrast Mode Display" ) : + _( "Hight Contrast Mode Display" ) ); + } - } + if( m_AuxiliaryToolBar ) + { + wxString msg; + if( m_SelTrackWidthBox && m_SelTrackWidthBox_Changed ) + { + m_SelTrackWidthBox_Changed = FALSE; + m_SelTrackWidthBox->Clear(); + wxString format = _( "Track" ); + + if( g_UnitMetric == INCHES ) + format += wxT( " %.1f" ); + else + format += wxT( " %.3f" ); + + for( ii = 0; ii < HIST0RY_NUMBER; ii++ ) + { + if( g_DesignSettings.m_TrackWidhtHistory[ii] == 0 ) + break; // Fin de liste + double value = To_User_Unit( g_UnitMetric, + g_DesignSettings.m_TrackWidhtHistory[ii], + PCB_INTERNAL_UNIT ); - if ( m_AuxiliaryToolBar ) - { - wxString msg; - if ( m_SelTrackWidthBox && m_SelTrackWidthBox_Changed) - { - m_SelTrackWidthBox_Changed = FALSE; - m_SelTrackWidthBox->Clear(); - wxString format = _("Track"); - if ( g_UnitMetric == INCHES ) format += wxT(" %.1f"); - else format += wxT(" %.3f"); - for ( ii = 0; ii < HIST0RY_NUMBER; ii++) - { - if ( g_DesignSettings.m_TrackWidhtHistory[ii] == 0 ) break; // Fin de liste - double value = To_User_Unit(g_UnitMetric, - g_DesignSettings.m_TrackWidhtHistory[ii], PCB_INTERNAL_UNIT); + if( g_UnitMetric == INCHES ) + msg.Printf( format.GetData(), value * 1000 ); + else + msg.Printf( format.GetData(), value ); + + m_SelTrackWidthBox->Append( msg ); + + if( g_DesignSettings.m_TrackWidhtHistory[ii] == + g_DesignSettings.m_CurrentTrackWidth ) + m_SelTrackWidthBox->SetSelection( ii ); + } + } - if ( g_UnitMetric == INCHES ) - msg.Printf(format.GetData(), value * 1000); - else - msg.Printf(format.GetData(), value); - m_SelTrackWidthBox->Append(msg); - if ( g_DesignSettings.m_TrackWidhtHistory[ii] == g_DesignSettings.m_CurrentTrackWidth ) - m_SelTrackWidthBox->SetSelection(ii); - } - } + if( m_SelViaSizeBox && m_SelViaSizeBox_Changed ) + { + m_SelViaSizeBox_Changed = FALSE; + m_SelViaSizeBox->Clear(); + wxString format = _( "Via" ); + + if( g_UnitMetric == INCHES ) + format += wxT( " %.1f" ); + else + format += wxT( " %.3f" ); + + for( ii = 0; ii < HIST0RY_NUMBER; ii++ ) + { + if( g_DesignSettings.m_ViaSizeHistory[ii] == 0 ) + break; // Fin de liste + + double value = To_User_Unit( g_UnitMetric, + g_DesignSettings.m_ViaSizeHistory[ii], + PCB_INTERNAL_UNIT ); - if ( m_SelViaSizeBox && m_SelViaSizeBox_Changed ) - { - m_SelViaSizeBox_Changed = FALSE; - m_SelViaSizeBox->Clear(); - wxString format = _("Via"); - if ( g_UnitMetric == INCHES ) format += wxT(" %.1f"); - else format += wxT(" %.3f"); - for ( ii = 0; ii < HIST0RY_NUMBER; ii++) - { - if ( g_DesignSettings.m_ViaSizeHistory[ii] == 0 ) break; // Fin de liste - double value = To_User_Unit(g_UnitMetric, - g_DesignSettings.m_ViaSizeHistory[ii], PCB_INTERNAL_UNIT); + if( g_UnitMetric == INCHES ) + msg.Printf( format.GetData(), value * 1000 ); + else + msg.Printf( format.GetData(), value ); + + m_SelViaSizeBox->Append( msg ); + if( g_DesignSettings.m_ViaSizeHistory[ii] == g_DesignSettings.m_CurrentViaSize ) + m_SelViaSizeBox->SetSelection( ii ); + } + } - if ( g_UnitMetric == INCHES ) - msg.Printf(format.GetData(), value * 1000); - else - msg.Printf(format.GetData(), value); - m_SelViaSizeBox->Append(msg); - if ( g_DesignSettings.m_ViaSizeHistory[ii] == g_DesignSettings.m_CurrentViaSize ) - m_SelViaSizeBox->SetSelection(ii); - } - } + if( m_SelZoomBox ) + { + int old_choice = m_SelZoomBox->GetChoice(); + int new_choice = 1; + int zoom; + + for( jj = 1, zoom = 1; zoom <= m_ZoomMaxValue; zoom <<= 1, jj++ ) + { + if( m_CurrentScreen && (m_CurrentScreen->GetZoom() == zoom) ) + break; + new_choice++; + } - if ( m_SelZoomBox ) - { - int old_choice = m_SelZoomBox->GetChoice(); - int new_choice = 1; - int zoom; - for ( jj = 1, zoom = 1; zoom <= m_ZoomMaxValue; zoom <<= 1, jj++ ) - { - if ( m_CurrentScreen && (m_CurrentScreen->GetZoom() == zoom) ) - break; - new_choice++; - } - if ( old_choice != new_choice ) - m_SelZoomBox->SetSelection(new_choice); - } + if( old_choice != new_choice ) + m_SelZoomBox->SetSelection( new_choice ); + } - if ( m_SelGridBox && m_CurrentScreen) - { - int kk = m_SelGridBox->GetChoice(); - for ( ii = 0; g_GridList[ii].x > 0; ii++ ) - { - if ( !m_CurrentScreen->m_UserGridIsON && - (m_CurrentScreen->GetGrid().x == g_GridList[ii].x) && - (m_CurrentScreen->GetGrid().y == g_GridList[ii].y) ) - { - if (kk != ii) m_SelGridBox->SetSelection(ii); - kk = ii; - break; - } - } - if ( kk != ii ) - m_SelGridBox->SetSelection(ii); /* User Grid */ - } - } + if( m_SelGridBox && m_CurrentScreen ) + { + int kk = m_SelGridBox->GetChoice(); + + for( ii = 0; g_GridList[ii].x > 0; ii++ ) + { + if( !m_CurrentScreen->m_UserGridIsON + && (m_CurrentScreen->GetGrid().x == g_GridList[ii].x) + && (m_CurrentScreen->GetGrid().y == g_GridList[ii].y) ) + { + if( kk != ii ) + m_SelGridBox->SetSelection( ii ); + kk = ii; + break; + } + } - ReCreateLayerBox(NULL); - PrepareLayerIndicator(); + if( kk != ii ) + m_SelGridBox->SetSelection( ii ); /* User Grid */ + } + } - DisplayUnitsMsg(); + ReCreateLayerBox( NULL ); + PrepareLayerIndicator(); + + DisplayUnitsMsg(); } diff --git a/pcbnew/pcbnew.h b/pcbnew/pcbnew.h index 0c66a1ae15..90223bd494 100644 --- a/pcbnew/pcbnew.h +++ b/pcbnew/pcbnew.h @@ -331,7 +331,7 @@ eda_global PCB_SCREEN* ScreenModule; /* Ecran de l'editeur de modules */ /* Gestion du deplacement des modules et des pistes */ /****************************************************/ -eda_global wxPoint g_Offset_Module;/* Offset de trace du modul en depl */ +eda_global wxPoint g_Offset_Module; /* Offset de trace du modul en depl */ /* Pad editing */ eda_global wxString g_Current_PadName; // Last used pad name (pad num) diff --git a/pcbnew/pcbtexte.cpp b/pcbnew/pcbtexte.cpp index 94d93443aa..5aa2d90711 100644 --- a/pcbnew/pcbtexte.cpp +++ b/pcbnew/pcbtexte.cpp @@ -1,6 +1,6 @@ - /**************************************************/ - /* traitement des editions des textes sur modules */ - /**************************************************/ +/**************************************************/ +/* traitement des editions des textes sur modules */ +/**************************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -13,377 +13,393 @@ #define L_MIN_DESSIN 1 /* seuil de largeur des segments pour trace autre que filaire */ /* Routines Locales */ -static void Move_Texte_Pcb(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) ; -static void Exit_Texte_Pcb(WinEDA_DrawPanel * Panel, wxDC *DC) ; +static void Move_Texte_Pcb( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); +static void Exit_Texte_Pcb( WinEDA_DrawPanel* Panel, wxDC* DC ); /* Variables locales : */ -static wxPoint old_pos; // position originelle du texte selecte +static wxPoint old_pos; // position originelle du texte selecte -enum id_TextPCB_properties -{ - ID_ACCEPT_TEXTE_PCB_PROPERTIES = 1900, - ID_CLOSE_TEXTE_PCB_PROPERTIES, - ID_TEXTPCB_SELECT_LAYER +enum id_TextPCB_properties { + ID_ACCEPT_TEXTE_PCB_PROPERTIES = 1900, + ID_CLOSE_TEXTE_PCB_PROPERTIES, + ID_TEXTPCB_SELECT_LAYER }; - /************************************/ - /* class WinEDA_TextPCBPropertiesFrame */ - /************************************/ +/************************************/ +/* class WinEDA_TextPCBPropertiesFrame */ +/************************************/ -class WinEDA_TextPCBPropertiesFrame: public wxDialog +class WinEDA_TextPCBPropertiesFrame : public wxDialog { private: - WinEDA_PcbFrame * m_Parent; - wxDC * m_DC; - TEXTE_PCB * CurrentTextPCB; - WinEDA_EnterText * m_Name; - WinEDA_PositionCtrl * m_TxtPosCtrl; - WinEDA_SizeCtrl * m_TxtSizeCtrl; - WinEDA_ValueCtrl * m_TxtWidthCtlr; - wxRadioBox * m_Orient; - wxRadioBox * m_Mirror; - WinEDAChoiceBox * m_SelLayerBox; + WinEDA_PcbFrame* m_Parent; + wxDC* m_DC; + TEXTE_PCB* CurrentTextPCB; + WinEDA_EnterText* m_Name; + WinEDA_PositionCtrl* m_TxtPosCtrl; + WinEDA_SizeCtrl* m_TxtSizeCtrl; + WinEDA_ValueCtrl* m_TxtWidthCtlr; + wxRadioBox* m_Orient; + wxRadioBox* m_Mirror; + WinEDAChoiceBox* m_SelLayerBox; public: - // Constructor and destructor - WinEDA_TextPCBPropertiesFrame(WinEDA_PcbFrame *parent, - TEXTE_PCB * TextPCB, wxDC * DC, const wxPoint & pos); - ~WinEDA_TextPCBPropertiesFrame(void) - { - } + + // Constructor and destructor + WinEDA_TextPCBPropertiesFrame( WinEDA_PcbFrame* parent, + TEXTE_PCB* TextPCB, wxDC* DC, const wxPoint& pos ); + ~WinEDA_TextPCBPropertiesFrame( void ) + { + } + private: - void TextPCBPropertiesAccept(wxCommandEvent& event); - void OnQuit(wxCommandEvent& event); + void TextPCBPropertiesAccept( wxCommandEvent& event ); + void OnQuit( wxCommandEvent& event ); - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() }; -BEGIN_EVENT_TABLE(WinEDA_TextPCBPropertiesFrame, wxDialog) - EVT_BUTTON(ID_ACCEPT_TEXTE_PCB_PROPERTIES, - WinEDA_TextPCBPropertiesFrame::TextPCBPropertiesAccept) - EVT_BUTTON(ID_CLOSE_TEXTE_PCB_PROPERTIES, - WinEDA_TextPCBPropertiesFrame::OnQuit) +BEGIN_EVENT_TABLE( WinEDA_TextPCBPropertiesFrame, wxDialog ) +EVT_BUTTON( ID_ACCEPT_TEXTE_PCB_PROPERTIES, + WinEDA_TextPCBPropertiesFrame::TextPCBPropertiesAccept ) +EVT_BUTTON( ID_CLOSE_TEXTE_PCB_PROPERTIES, + WinEDA_TextPCBPropertiesFrame::OnQuit ) END_EVENT_TABLE() /********************************************************************/ -void WinEDA_PcbFrame::InstallTextPCBOptionsFrame(TEXTE_PCB * TextPCB, - wxDC * DC, const wxPoint & pos) +void WinEDA_PcbFrame::InstallTextPCBOptionsFrame( TEXTE_PCB* TextPCB, + wxDC* DC, const wxPoint& pos ) /********************************************************************/ { - DrawPanel->m_IgnoreMouseEvents = TRUE; - WinEDA_TextPCBPropertiesFrame * frame = new WinEDA_TextPCBPropertiesFrame(this, - TextPCB, DC, pos); - frame->ShowModal(); frame->Destroy(); - DrawPanel->MouseToCursorSchema(); - DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->m_IgnoreMouseEvents = TRUE; + WinEDA_TextPCBPropertiesFrame* frame = new WinEDA_TextPCBPropertiesFrame( this, + TextPCB, DC, pos ); + frame->ShowModal(); frame->Destroy(); + DrawPanel->MouseToCursorSchema(); + DrawPanel->m_IgnoreMouseEvents = FALSE; } /************************************************************************************/ -WinEDA_TextPCBPropertiesFrame::WinEDA_TextPCBPropertiesFrame(WinEDA_PcbFrame *parent, - TEXTE_PCB * TextPCB,wxDC * DC, - const wxPoint & framepos): - wxDialog(parent, -1, _("TextPCB properties"), framepos, wxSize(390, 340), - DIALOG_STYLE) +WinEDA_TextPCBPropertiesFrame::WinEDA_TextPCBPropertiesFrame( WinEDA_PcbFrame* parent, + TEXTE_PCB* TextPCB, wxDC* DC, + const wxPoint& framepos ) : + wxDialog( parent, -1, _( "TextPCB properties" ), framepos, wxSize( 390, 340 ), + DIALOG_STYLE ) /************************************************************************************/ { -wxButton * Button; + wxButton* Button; - m_Parent = parent; - SetFont(*g_DialogFont); - m_DC = DC; - Centre(); + m_Parent = parent; + SetFont( *g_DialogFont ); + m_DC = DC; + Centre(); - CurrentTextPCB = TextPCB; + CurrentTextPCB = TextPCB; - wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); - SetSizer(MainBoxSizer); - wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); - wxBoxSizer * MiddleBoxSizer = new wxBoxSizer(wxVERTICAL); - wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); - MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); - MainBoxSizer->Add(MiddleBoxSizer, 0, wxGROW|wxALL, 5); - MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); + SetSizer( MainBoxSizer ); + wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* MiddleBoxSizer = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL ); + MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 ); + MainBoxSizer->Add( MiddleBoxSizer, 0, wxGROW | wxALL, 5 ); + MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - /* Creation des boutons de commande */ - Button = new wxButton(this, ID_ACCEPT_TEXTE_PCB_PROPERTIES, _("Ok") ); - Button->SetForegroundColour(*wxRED); - RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); - Button->SetDefault(); + /* Creation des boutons de commande */ + Button = new wxButton( this, ID_ACCEPT_TEXTE_PCB_PROPERTIES, _( "Ok" ) ); + Button->SetForegroundColour( *wxRED ); + RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); + Button->SetDefault(); - Button = new wxButton(this, ID_CLOSE_TEXTE_PCB_PROPERTIES, _("Cancel")); - Button->SetForegroundColour(*wxBLUE); - RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + Button = new wxButton( this, ID_CLOSE_TEXTE_PCB_PROPERTIES, _( "Cancel" ) ); + Button->SetForegroundColour( *wxBLUE ); + RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - m_Name = new WinEDA_EnterText(this, _("Text:"), - TextPCB->m_Text, - LeftBoxSizer, wxSize( 200, -1) ); + m_Name = new WinEDA_EnterText( this, _( "Text:" ), + TextPCB->m_Text, + LeftBoxSizer, wxSize( 200, -1 ) ); m_Name->SetFocus(); - m_Name->SetSelection(-1,-1); + m_Name->SetSelection( -1, -1 ); - m_TxtSizeCtrl = new WinEDA_SizeCtrl(this, _("Size"), - TextPCB->m_Size, - g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits); + m_TxtSizeCtrl = new WinEDA_SizeCtrl( this, _( "Size" ), + TextPCB->m_Size, + g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits ); - m_TxtWidthCtlr = new WinEDA_ValueCtrl(this, _("Width"), - TextPCB->m_Width, - g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits); + m_TxtWidthCtlr = new WinEDA_ValueCtrl( this, _( "Width" ), + TextPCB->m_Width, + g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits ); - m_TxtPosCtrl = new WinEDA_PositionCtrl(this, _("Position"), - TextPCB->m_Pos, - g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits); + m_TxtPosCtrl = new WinEDA_PositionCtrl( this, _( "Position" ), + TextPCB->m_Pos, + g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits ); - m_SelLayerBox = new WinEDAChoiceBox(this, ID_TEXTPCB_SELECT_LAYER, - wxDefaultPosition, wxDefaultSize); - MiddleBoxSizer->Add(m_SelLayerBox, 0, wxGROW|wxALL, 5); + m_SelLayerBox = new WinEDAChoiceBox( this, ID_TEXTPCB_SELECT_LAYER, + wxDefaultPosition, wxDefaultSize ); + MiddleBoxSizer->Add( m_SelLayerBox, 0, wxGROW | wxALL, 5 ); - int ii; - for ( ii = 0; ii < 29 ; ii ++ ) - { - m_SelLayerBox->Append(ReturnPcbLayerName(ii)); - } - m_SelLayerBox->SetSelection( TextPCB->m_Layer ); - + int ii; + for( ii = 0; ii < 29; ii++ ) + { + m_SelLayerBox->Append( ReturnPcbLayerName( ii ) ); + } -wxString orient_msg[4] = { wxT("0"), wxT("90"), wxT("180"), wxT("-90") }; - m_Orient = new wxRadioBox(this, -1, _("Orientation"), - wxDefaultPosition, wxSize(-1,-1), 4, orient_msg, - 1, wxRA_SPECIFY_COLS ); - MiddleBoxSizer->Add(m_Orient, 0, wxGROW|wxALL, 5); - switch(TextPCB->m_Orient ) - { - default: - m_Orient->SetSelection(0); - break; + m_SelLayerBox->SetSelection( TextPCB->m_Layer ); - case 900: - m_Orient->SetSelection(1); - break; - case 1800: - m_Orient->SetSelection(2); - break; + wxString orient_msg[4] = { wxT( "0" ), wxT( "90" ), wxT( "180" ), wxT( "-90" ) }; + m_Orient = new wxRadioBox( this, -1, _( "Orientation" ), + wxDefaultPosition, wxSize( -1, -1 ), 4, orient_msg, + 1, wxRA_SPECIFY_COLS ); + MiddleBoxSizer->Add( m_Orient, 0, wxGROW | wxALL, 5 ); - case 2700: - m_Orient->SetSelection(3); - break; + switch( TextPCB->m_Orient ) + { + default: + m_Orient->SetSelection( 0 ); + break; - } + case 900: + m_Orient->SetSelection( 1 ); + break; -wxString display_msg[2] = { _("Normal"), _("Mirror") }; - m_Mirror = new wxRadioBox(this, -1, _("Display"), - wxDefaultPosition, wxSize(-1,-1), 2, display_msg, - 1, wxRA_SPECIFY_COLS ); - if ( ! TextPCB->m_Miroir ) m_Mirror->SetSelection(1);; - MiddleBoxSizer->Add(m_Mirror, 0, wxGROW|wxALL, 5); + case 1800: + m_Orient->SetSelection( 2 ); + break; - GetSizer()->Fit(this); - GetSizer()->SetSizeHints(this); + case 2700: + m_Orient->SetSelection( 3 ); + break; + } + + wxString display_msg[2] = { _( "Normal" ), _( "Mirror" ) }; + m_Mirror = new wxRadioBox( this, -1, _( "Display" ), + wxDefaultPosition, wxSize( -1, -1 ), 2, display_msg, + 1, wxRA_SPECIFY_COLS ); + if( !TextPCB->m_Miroir ) + m_Mirror->SetSelection( 1 );; + MiddleBoxSizer->Add( m_Mirror, 0, wxGROW | wxALL, 5 ); + + GetSizer()->Fit( this ); + GetSizer()->SetSizeHints( this ); } /**********************************************************************/ -void WinEDA_TextPCBPropertiesFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +void WinEDA_TextPCBPropertiesFrame::OnQuit( wxCommandEvent& WXUNUSED (event) ) /**********************************************************************/ { // true is to force the frame to close - Close(true); + Close( true ); } /**************************************************************************************/ -void WinEDA_TextPCBPropertiesFrame::TextPCBPropertiesAccept(wxCommandEvent& event) +void WinEDA_TextPCBPropertiesFrame::TextPCBPropertiesAccept( wxCommandEvent& event ) /**************************************************************************************/ { - if ( m_DC ) // Effacement ancien texte - { - CurrentTextPCB->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0, 0), GR_XOR); - } + if( m_DC ) // Effacement ancien texte + { + CurrentTextPCB->Draw( m_Parent->DrawPanel, m_DC, wxPoint( 0, 0 ), GR_XOR ); + } - if ( ! m_Name->GetValue().IsEmpty() ) - { - CurrentTextPCB->m_Text = m_Name->GetValue(); - } - CurrentTextPCB->m_Pos = m_TxtPosCtrl->GetValue(); - CurrentTextPCB->m_Size = m_TxtSizeCtrl->GetValue(); - CurrentTextPCB->m_Width = m_TxtWidthCtlr->GetValue(); - CurrentTextPCB->m_Miroir = (m_Mirror->GetSelection() == 0) ? 1 : 0; - CurrentTextPCB->m_Orient = m_Orient->GetSelection() * 900; - CurrentTextPCB->m_Layer = m_SelLayerBox->GetChoice(); - CurrentTextPCB->CreateDrawData(); - if ( m_DC ) // Affichage nouveau texte - { - /* Redessin du Texte */ - CurrentTextPCB->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0, 0), GR_OR); - } - m_Parent->m_CurrentScreen->SetModify(); - Close(TRUE); + if( !m_Name->GetValue().IsEmpty() ) + { + CurrentTextPCB->m_Text = m_Name->GetValue(); + } + CurrentTextPCB->m_Pos = m_TxtPosCtrl->GetValue(); + CurrentTextPCB->m_Size = m_TxtSizeCtrl->GetValue(); + CurrentTextPCB->m_Width = m_TxtWidthCtlr->GetValue(); + CurrentTextPCB->m_Miroir = (m_Mirror->GetSelection() == 0) ? 1 : 0; + CurrentTextPCB->m_Orient = m_Orient->GetSelection() * 900; + CurrentTextPCB->m_Layer = m_SelLayerBox->GetChoice(); + CurrentTextPCB->CreateDrawData(); + if( m_DC ) // Affichage nouveau texte + { + /* Redessin du Texte */ + CurrentTextPCB->Draw( m_Parent->DrawPanel, m_DC, wxPoint( 0, 0 ), GR_OR ); + } + m_Parent->m_CurrentScreen->SetModify(); + Close( TRUE ); } /******************************************************/ -void Exit_Texte_Pcb(WinEDA_DrawPanel * Panel, wxDC * DC) +void Exit_Texte_Pcb( WinEDA_DrawPanel* Panel, wxDC* DC ) /*******************************************************/ + /* - Routine de sortie du menu edit texte Pcb -Si un texte est selectionne, ses coord initiales sont regenerees -*/ + * Routine de sortie du menu edit texte Pcb + * Si un texte est selectionne, ses coord initiales sont regenerees + */ { -TEXTE_PCB * TextePcb; + TEXTE_PCB* TextePcb; - TextePcb = (TEXTE_PCB *) Panel->GetScreen()->m_CurrentItem; + TextePcb = (TEXTE_PCB*) Panel->GetScreen()->GetCurItem(); - if ( TextePcb ) - { - TextePcb->Draw(Panel, DC, wxPoint(0, 0), GR_XOR) ; - TextePcb->m_Pos = old_pos; - TextePcb->Draw(Panel, DC, wxPoint(0, 0), GR_OR) ; - TextePcb->m_Flags = 0; - } + if( TextePcb ) + { + TextePcb->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR ); + TextePcb->m_Pos = old_pos; + TextePcb->Draw( Panel, DC, wxPoint( 0, 0 ), GR_OR ); + TextePcb->m_Flags = 0; + } - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; - Panel->GetScreen()->m_CurrentItem = NULL; + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + Panel->GetScreen()->SetCurItem( NULL ); } + /*********************************************************************/ -void WinEDA_PcbFrame::Place_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC) +void WinEDA_PcbFrame::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) /*********************************************************************/ + /* - Routine de placement du texte en cours de deplacement -*/ + * Routine de placement du texte en cours de deplacement + */ { - if( TextePcb == NULL ) return; + if( TextePcb == NULL ) + return; - TextePcb->CreateDrawData(); - TextePcb->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR) ; - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - m_CurrentScreen->m_CurrentItem = NULL; - m_CurrentScreen->SetModify(); - TextePcb->m_Flags = 0; + TextePcb->CreateDrawData(); + TextePcb->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + m_CurrentScreen->SetCurItem( NULL ); + m_CurrentScreen->SetModify(); + TextePcb->m_Flags = 0; } + /***********************************************************************/ -void WinEDA_PcbFrame::StartMoveTextePcb(TEXTE_PCB * TextePcb, wxDC * DC) +void WinEDA_PcbFrame::StartMoveTextePcb( TEXTE_PCB* TextePcb, wxDC* DC ) /***********************************************************************/ - /* Routine de preparation du deplacement d'un texte -*/ + +/* Routine de preparation du deplacement d'un texte + */ { - if( TextePcb == NULL ) return; - old_pos = TextePcb->m_Pos; - TextePcb->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR) ; - TextePcb->m_Flags |= IS_MOVED; - Affiche_Infos_PCB_Texte(this, TextePcb); - DrawPanel->ManageCurseur = Move_Texte_Pcb; - DrawPanel->ForceCloseManageCurseur = Exit_Texte_Pcb; - m_CurrentScreen->m_CurrentItem = TextePcb; - DrawPanel->ManageCurseur( DrawPanel, DC, FALSE); + if( TextePcb == NULL ) + return; + old_pos = TextePcb->m_Pos; + TextePcb->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); + TextePcb->m_Flags |= IS_MOVED; + Affiche_Infos_PCB_Texte( this, TextePcb ); + DrawPanel->ManageCurseur = Move_Texte_Pcb; + DrawPanel->ForceCloseManageCurseur = Exit_Texte_Pcb; + m_CurrentScreen->SetCurItem( TextePcb ); + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); } + /*************************************************************************/ -static void Move_Texte_Pcb(WinEDA_DrawPanel * panel, wxDC *DC, bool erase ) +static void Move_Texte_Pcb( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /*************************************************************************/ /* Routine deplacant le texte PCB suivant le curseur de la souris */ { -TEXTE_PCB * TextePcb = (TEXTE_PCB *) - panel->m_Parent->m_CurrentScreen->m_CurrentItem; + TEXTE_PCB* TextePcb = (TEXTE_PCB*) + panel->m_Parent->m_CurrentScreen->GetCurItem(); - if (TextePcb == NULL ) return ; + if( TextePcb == NULL ) + return; - /* effacement du texte : */ + /* effacement du texte : */ - if ( erase ) - TextePcb->Draw(panel, DC, wxPoint(0, 0), GR_XOR) ; + if( erase ) + TextePcb->Draw( panel, DC, wxPoint( 0, 0 ), GR_XOR ); - TextePcb->m_Pos = panel->m_Parent->m_CurrentScreen->m_Curseur; + TextePcb->m_Pos = panel->m_Parent->m_CurrentScreen->m_Curseur; - /* Redessin du Texte */ - TextePcb->Draw(panel, DC, wxPoint(0, 0), GR_XOR) ; + /* Redessin du Texte */ + TextePcb->Draw( panel, DC, wxPoint( 0, 0 ), GR_XOR ); } /**********************************************************************/ -void WinEDA_PcbFrame::Delete_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC) +void WinEDA_PcbFrame::Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) /**********************************************************************/ { + if( TextePcb == NULL ) + return; - if( TextePcb == NULL ) return; + TextePcb->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); - TextePcb->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); - - /* Suppression du texte en Memoire*/ - DeleteStructure(TextePcb); - DrawPanel->ManageCurseur = NULL; - DrawPanel->ForceCloseManageCurseur = NULL; - m_CurrentScreen->m_CurrentItem = NULL; + /* Suppression du texte en Memoire*/ + DeleteStructure( TextePcb ); + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + m_CurrentScreen->SetCurItem( NULL ); } /*******************************************************/ -TEXTE_PCB * WinEDA_PcbFrame::Create_Texte_Pcb( wxDC * DC) +TEXTE_PCB* WinEDA_PcbFrame::Create_Texte_Pcb( wxDC* DC ) /*******************************************************/ { -TEXTE_PCB * TextePcb; + TEXTE_PCB* TextePcb; - TextePcb = new TEXTE_PCB(m_Pcb); + TextePcb = new TEXTE_PCB( m_Pcb ); - /* Chainage de la nouvelle structure en debut de liste */ - TextePcb->Pnext = m_Pcb->m_Drawings; - TextePcb->Pback = (EDA_BaseStruct * )m_Pcb; - if( m_Pcb->m_Drawings) - m_Pcb->m_Drawings->Pback = (EDA_BaseStruct*) TextePcb; - m_Pcb->m_Drawings = (EDA_BaseStruct*) TextePcb; + /* Chainage de la nouvelle structure en debut de liste */ + TextePcb->Pnext = m_Pcb->m_Drawings; + TextePcb->Pback = (EDA_BaseStruct*) m_Pcb; + if( m_Pcb->m_Drawings ) + m_Pcb->m_Drawings->Pback = (EDA_BaseStruct*) TextePcb; + m_Pcb->m_Drawings = (EDA_BaseStruct*) TextePcb; - /* Mise a jour des caracteristiques */ - TextePcb->m_Flags = IS_NEW; - TextePcb->m_Layer = GetScreen()->m_Active_Layer; - TextePcb->m_Miroir = 1; - if(TextePcb->m_Layer == CUIVRE_N) TextePcb->m_Miroir = 0; + /* Mise a jour des caracteristiques */ + TextePcb->m_Flags = IS_NEW; + TextePcb->m_Layer = GetScreen()->m_Active_Layer; + TextePcb->m_Miroir = 1; + if( TextePcb->m_Layer == CUIVRE_N ) + TextePcb->m_Miroir = 0; - TextePcb->m_Size = g_DesignSettings.m_PcbTextSize; - TextePcb->m_Pos = m_CurrentScreen->m_Curseur; - TextePcb->m_Width = g_DesignSettings.m_PcbTextWidth; + TextePcb->m_Size = g_DesignSettings.m_PcbTextSize; + TextePcb->m_Pos = m_CurrentScreen->m_Curseur; + TextePcb->m_Width = g_DesignSettings.m_PcbTextWidth; - InstallTextPCBOptionsFrame(TextePcb, DC, TextePcb->m_Pos); - if ( TextePcb->m_Text.IsEmpty() ) - { - DeleteStructure(TextePcb); - TextePcb = NULL; - } + InstallTextPCBOptionsFrame( TextePcb, DC, TextePcb->m_Pos ); + if( TextePcb->m_Text.IsEmpty() ) + { + DeleteStructure( TextePcb ); + TextePcb = NULL; + } + else + StartMoveTextePcb( TextePcb, DC ); - else StartMoveTextePcb(TextePcb, DC); - - return TextePcb; + return TextePcb; } + /***********************************************************************/ -void WinEDA_PcbFrame::Rotate_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC) +void WinEDA_PcbFrame::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) /***********************************************************************/ { -int angle = 900; -int drawmode = GR_XOR; + int angle = 900; + int drawmode = GR_XOR; - if( TextePcb == NULL ) return; + if( TextePcb == NULL ) + return; - /* effacement du texte : */ - TextePcb->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR) ; + /* effacement du texte : */ + TextePcb->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); - TextePcb->m_Orient += angle; - if(TextePcb->m_Orient >= 3600) TextePcb->m_Orient -= 3600 ; - if(TextePcb->m_Orient < 0) TextePcb->m_Orient += 3600 ; + TextePcb->m_Orient += angle; + if( TextePcb->m_Orient >= 3600 ) + TextePcb->m_Orient -= 3600; + if( TextePcb->m_Orient < 0 ) + TextePcb->m_Orient += 3600; - TextePcb->CreateDrawData(); + TextePcb->CreateDrawData(); - /* Redessin du Texte */ - TextePcb->Draw(DrawPanel, DC, wxPoint(0, 0), drawmode); - Affiche_Infos_PCB_Texte(this, TextePcb); + /* Redessin du Texte */ + TextePcb->Draw( DrawPanel, DC, wxPoint( 0, 0 ), drawmode ); + Affiche_Infos_PCB_Texte( this, TextePcb ); - m_CurrentScreen->SetModify(); + m_CurrentScreen->SetModify(); } - diff --git a/pcbnew/zones.cpp b/pcbnew/zones.cpp index 96f8613e5c..8c03527a0d 100644 --- a/pcbnew/zones.cpp +++ b/pcbnew/zones.cpp @@ -83,11 +83,11 @@ WinEDA_ZoneFrame::WinEDA_ZoneFrame() WinEDA_ZoneFrame::WinEDA_ZoneFrame( WinEDA_PcbFrame* parent, - wxWindowID id, - const wxString& caption, - const wxPoint& pos, - const wxSize& size, - long style ) + wxWindowID id, + const wxString& caption, + const wxPoint& pos, + const wxSize& size, + long style ) { m_Parent = parent; Create( parent, id, caption, pos, size, style ); @@ -98,12 +98,12 @@ WinEDA_ZoneFrame::WinEDA_ZoneFrame( WinEDA_PcbFrame* parent, * WinEDA_ZoneFrame creator */ -bool WinEDA_ZoneFrame::Create( wxWindow* parent, - wxWindowID id, +bool WinEDA_ZoneFrame::Create( wxWindow* parent, + wxWindowID id, const wxString& caption, - const wxPoint& pos, - const wxSize& size, - long style ) + const wxPoint& pos, + const wxSize& size, + long style ) { ////@begin WinEDA_ZoneFrame member initialisation m_GridCtrl = NULL; @@ -140,12 +140,12 @@ void WinEDA_ZoneFrame::CreateControls() ////@begin WinEDA_ZoneFrame content construction // Generated by DialogBlocks, 03/03/2006 13:36:21 (unregistered) - WinEDA_ZoneFrame* itemDialog1 = this; + WinEDA_ZoneFrame* itemDialog1 = this; - wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxHORIZONTAL ); itemDialog1->SetSizer( itemBoxSizer2 ); - wxBoxSizer* itemBoxSizer3 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer( wxVERTICAL ); itemBoxSizer2->Add( itemBoxSizer3, 0, wxGROW | wxALL, 5 ); static const wxString m_GridCtrlStrings[] = { @@ -154,14 +154,14 @@ void WinEDA_ZoneFrame::CreateControls() _( "0.00000" ), _( "0.00000" ) }; - + m_GridCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX, _( "Grid size:" ), wxDefaultPosition, wxDefaultSize, 4, m_GridCtrlStrings, 1, wxRA_SPECIFY_COLS ); itemBoxSizer3->Add( m_GridCtrl, 0, wxALIGN_LEFT | wxALL, 5 ); m_ClearanceValueTitle = new wxStaticText( itemDialog1, wxID_STATIC, - _("Zone clearance value (mm):"), + _( "Zone clearance value (mm):" ), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer3->Add( m_ClearanceValueTitle, 0, @@ -174,15 +174,15 @@ void WinEDA_ZoneFrame::CreateControls() itemBoxSizer2->Add( 5, 5, 0, wxGROW | wxALL, 5 ); - wxBoxSizer* itemBoxSizer8 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* itemBoxSizer8 = new wxBoxSizer( wxVERTICAL ); itemBoxSizer2->Add( itemBoxSizer8, 0, wxGROW | wxALL, 5 ); - static const wxString m_FillOptStrings[] = { + static const wxString m_FillOptStrings[] = { _( "Include Pads" ), _( "Thermal" ), _( "Exclude Pads" ) }; - + m_FillOpt = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _( "Pad options:" ), wxDefaultPosition, wxDefaultSize, 3, m_FillOptStrings, 1, wxRA_SPECIFY_COLS ); @@ -192,12 +192,12 @@ void WinEDA_ZoneFrame::CreateControls() _( "Any" ), _( "H , V and 45 deg" ) }; - - m_OrientEdgesOpt = new wxRadioBox( itemDialog1, ID_RADIOBOX2, - _("Zone edges orient:" ), wxDefaultPosition, - wxDefaultSize, 2, m_OrientEdgesOptStrings, 1, - wxRA_SPECIFY_COLS ); - + + m_OrientEdgesOpt = new wxRadioBox( itemDialog1, ID_RADIOBOX2, + _( "Zone edges orient:" ), wxDefaultPosition, + wxDefaultSize, 2, m_OrientEdgesOptStrings, 1, + wxRA_SPECIFY_COLS ); + itemBoxSizer8->Add( m_OrientEdgesOpt, 0, wxALIGN_RIGHT | wxALL, 5 ); itemBoxSizer2->Add( 5, 5, 0, wxGROW | wxALL, 5 ); @@ -205,22 +205,24 @@ void WinEDA_ZoneFrame::CreateControls() wxBoxSizer* itemBoxSizer12 = new wxBoxSizer( wxVERTICAL ); itemBoxSizer2->Add( itemBoxSizer12, 0, wxALIGN_TOP | wxALL, 5 ); - wxButton* itemButton13 = new wxButton( itemDialog1, ID_FILL_ZONE, - _("Fill"), wxDefaultPosition, wxDefaultSize, 0 ); - + wxButton* itemButton13 = new wxButton( itemDialog1, ID_FILL_ZONE, + _( "Fill" ), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton13->SetDefault(); itemButton13->SetForegroundColour( wxColour( 204, 0, 0 ) ); itemBoxSizer12->Add( itemButton13, 0, wxGROW | wxALL, 5 ); - wxButton* itemButton14 = new wxButton( itemDialog1, wxID_CANCEL, - _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); - + wxButton* itemButton14 = new wxButton( itemDialog1, wxID_CANCEL, + _( "&Cancel" ), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton14->SetForegroundColour( wxColour( 0, 0, 255 ) ); itemBoxSizer12->Add( itemButton14, 0, wxGROW | wxALL, 5 ); - wxButton* itemButton15 = new wxButton( itemDialog1, ID_SET_OPTIONS_ZONE, - _("Update Options" ), wxDefaultPosition, wxDefaultSize, 0 ); - + wxButton* itemButton15 = new wxButton( itemDialog1, ID_SET_OPTIONS_ZONE, + _( + "Update Options" ), wxDefaultPosition, + wxDefaultSize, 0 ); + itemButton15->SetForegroundColour( wxColour( 0, 100, 0 ) ); itemBoxSizer12->Add( itemButton15, 0, wxGROW | wxALL, 5 ); @@ -245,7 +247,7 @@ void WinEDA_ZoneFrame::CreateControls() static const int GridList[4] = { 50, 100, 250, 500 }; int selection = 0; - + for( unsigned ii = 0; ii < m_GridCtrl->GetCount(); ii++ ) { wxString msg = ReturnStringFromValue( g_UnitMetric, @@ -403,16 +405,17 @@ void WinEDA_PcbFrame::Edit_Zone_Width( wxDC* DC, SEGZONE* Zone ) f_new_width = To_User_Unit( g_UnitMetric, Zone->m_Width, GetScreen()->GetInternalUnits() ); Line.Printf( wxT( "%.4f" ), f_new_width ); - + Msg += g_UnitMetric ? wxT( "(mm)" ) : wxT( "(\")" ); if( Get_Message( Msg, Line, this ) != 0 ) return; w_tmp = g_DesignSettings.m_CurrentTrackWidth; Line.ToDouble( &f_new_width ); - - g_DesignSettings.m_CurrentTrackWidth = From_User_Unit( g_UnitMetric, - f_new_width, GetScreen()->GetInternalUnits() ); + + g_DesignSettings.m_CurrentTrackWidth = From_User_Unit( g_UnitMetric, + f_new_width, GetScreen( + )->GetInternalUnits() ); TimeStamp = Zone->m_TimeStamp; @@ -491,8 +494,8 @@ EDGE_ZONE* WinEDA_PcbFrame::Del_SegmEdgeZone( wxDC* DC, EDGE_ZONE* edge_zone ) delete Segm; Segm = previous_segm; - m_Pcb->m_CurrentLimitZone = Segm; - GetScreen()->m_CurrentItem = Segm; + m_Pcb->m_CurrentLimitZone = Segm; + GetScreen()->SetCurItem( Segm ); if( Segm ) { @@ -504,7 +507,7 @@ EDGE_ZONE* WinEDA_PcbFrame::Del_SegmEdgeZone( wxDC* DC, EDGE_ZONE* edge_zone ) { DrawPanel->ManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL; - GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetCurItem( NULL ); } return Segm; } @@ -623,7 +626,7 @@ static void Exit_Zones( WinEDA_DrawPanel* Panel, wxDC* DC ) Panel->ManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL; - pcbframe->GetScreen()->m_CurrentItem = NULL; + pcbframe->GetScreen()->SetCurItem( NULL ); } @@ -653,8 +656,8 @@ void WinEDA_BasePcbFrame::DelLimitesZone( wxDC* DC, bool Redraw ) segment->Pnext = NULL; delete segment; } - GetScreen()->m_CurrentItem = NULL; - m_Pcb->m_CurrentLimitZone = NULL; + GetScreen()->SetCurItem( NULL ); + m_Pcb->m_CurrentLimitZone = NULL; } @@ -692,7 +695,7 @@ EDGE_ZONE* WinEDA_PcbFrame::Begin_Zone( void ) * a jour par la routine Show_Zone_Edge_While_MoveMouse*/ { if( (oldedge->m_Start.x != oldedge->m_End.x) - || (oldedge->m_Start.y != oldedge->m_End.y) ) + || (oldedge->m_Start.y != oldedge->m_End.y) ) { newedge = new EDGE_ZONE( oldedge ); newedge->Pback = oldedge; @@ -805,15 +808,15 @@ void WinEDA_PcbFrame::Fill_Zone( wxDC* DC ) /* * Fonction generale de creation de zone * Un contour de zone doit exister, sinon l'ensemble du PCB est utilise - * + * * ce qui permet de creer des obstacles et donc des parties non remplies. - * + * * Le remplissage s'effectue a partir du point d'ancrage, jusque ves les limites - * - * + * + * * On place la zone sur la couche (layer) active. - * - * + * + * * "Hight Light" la zone fera partie de ce net */ { @@ -1080,7 +1083,7 @@ static void Genere_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code if( !current_cell || (col == Ncols - 1) ) /* peut etre fin d'un segment */ { if( (old_cell) && (ux0 != ux1) ) - { + { /* un segment avait debute de longueur > 0 */ pt_track = new SEGZONE( frame->m_Pcb ); pt_track->m_Layer = layer; @@ -1118,7 +1121,7 @@ static void Genere_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code if( !current_cell || (row == Nrows - 1) ) /* peut etre fin d'un segment */ { if( (old_cell) && (uy0 != uy1) ) - { + { /* un segment avait debute de longueur > 0 */ pt_track = new SEGZONE( frame->m_Pcb ); pt_track->m_Layer = layer; @@ -1157,7 +1160,7 @@ int Propagation( WinEDA_PcbFrame* frame ) * et pour chaque balayage, on considere des 2 cellules voisines de * la cellule courants: cellule precedente sur la ligne et cellule precedente * sur la colonne. - * + * * La routine peut demander plusieurs iterations * les iterations doivent continuer juqu'a ce que la routine ne trouve plus * de cellules a modifier. @@ -1191,7 +1194,7 @@ int Propagation( WinEDA_PcbFrame* frame ) if( current_cell == 0 ) /* une cellule libre a ete trouvee */ { if( (old_cell_H & CELL_is_ZONE) - || (pt_cell_V[col] & CELL_is_ZONE) ) + || (pt_cell_V[col] & CELL_is_ZONE) ) { OrCell( row, col, BOTTOM, CELL_is_ZONE ); current_cell = CELL_is_ZONE;