LibEDA_BaseStruct * WinEDA_LibeditFrame::CreateGraphicItem(wxDC * DC) /*********************************************************************/ /* Routine de creation d'un nouvel element type LibraryDrawStruct POLYLINE ARC CIRCLE RECTANGLE */ { int DrawType; int * ptpoly; if(CurrentDrawItem) return NULL; // Creation du nouvel element switch ( m_ID_current_state ) { case ID_LIBEDIT_BODY_LINE_BUTT: DrawType = COMPONENT_POLYLINE_DRAW_TYPE; break; case ID_LIBEDIT_BODY_ARC_BUTT: DrawType = COMPONENT_ARC_DRAW_TYPE; break; case ID_LIBEDIT_BODY_CIRCLE_BUTT: DrawType = COMPONENT_CIRCLE_DRAW_TYPE; break; case ID_LIBEDIT_BODY_RECT_BUTT: DrawType = COMPONENT_RECT_DRAW_TYPE; break; case ID_LIBEDIT_BODY_TEXT_BUTT: DrawType = COMPONENT_GRAPHIC_TEXT_DRAW_TYPE; break; default: DisplayError(this, wxT("SymbolBeginDrawItem Internal err: Id error")); return NULL; } m_CurrentScreen->ManageCurseur = SymbolDisplayDraw; m_CurrentScreen->ForceCloseManageCurseur = AbortSymbolTraceOn; switch ( DrawType ) { case COMPONENT_ARC_DRAW_TYPE: { LibDrawArc * Arc = new LibDrawArc(); CurrentDrawItem = Arc; ArcStartX = ArcEndX = m_CurrentScreen->m_Curseur.x; ArcStartY = ArcEndY = - m_CurrentScreen->m_Curseur.y; StateDrawArc = 1; Arc->m_Fill = FlSymbol_Fill; } break; case COMPONENT_CIRCLE_DRAW_TYPE: { LibDrawCircle * Circle = new LibDrawCircle(); CurrentDrawItem = Circle; Circle->m_Pos.x = m_CurrentScreen->m_Curseur.x; Circle->m_Pos.y = - m_CurrentScreen->m_Curseur.y; Circle->m_Fill = FlSymbol_Fill; } break; case COMPONENT_RECT_DRAW_TYPE: { LibDrawSquare * Square = new LibDrawSquare(); CurrentDrawItem = Square; Square->m_Start.x = m_CurrentScreen->m_Curseur.x; Square->m_Start.y = - m_CurrentScreen->m_Curseur.y; Square->m_End = Square->m_Start; Square->m_Fill = FlSymbol_Fill; } break; case COMPONENT_POLYLINE_DRAW_TYPE: { LibDrawPolyline* polyline = new LibDrawPolyline(); CurrentDrawItem = polyline; polyline->n = 2; ptpoly = (int*)MyZMalloc( 4 * sizeof(int)); polyline->PolyList = ptpoly; ptpoly[0] = ptpoly[2] = m_CurrentScreen->m_Curseur.x; ptpoly[1] = ptpoly[3] = - m_CurrentScreen->m_Curseur.y; polyline->m_Fill = FlSymbol_Fill; } break; case COMPONENT_LINE_DRAW_TYPE: { LibDrawSegment* Segment = new LibDrawSegment(); CurrentDrawItem = Segment; Segment->m_Start.x = m_CurrentScreen->m_Curseur.x; Segment->m_Start.y = -m_CurrentScreen->m_Curseur.y; Segment->m_End = Segment->m_Start; } break; case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: { LibDrawText* Text = new LibDrawText(); CurrentDrawItem = Text; Text->m_Size.x = Text->m_Size.y = g_LastTextSize; Text->m_Horiz = g_LastTextOrient; Text->m_Pos.x = m_CurrentScreen->m_Curseur.x; Text->m_Pos.y = - m_CurrentScreen->m_Curseur.y; EditSymbolText(NULL, Text); if ( Text->m_Text.IsEmpty() ) { delete Text; CurrentDrawItem = NULL; m_CurrentScreen->ManageCurseur = NULL; m_CurrentScreen->ForceCloseManageCurseur = NULL; } else { StartMoveDrawSymbol(DC); DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, 0 , 0, Text, CurrentUnit, g_XorMode); } } break; } if ( CurrentDrawItem ) { CurrentDrawItem->m_Flags |= IS_NEW; if(g_FlDrawSpecificUnit) CurrentDrawItem->m_Unit = CurrentUnit; if(g_FlDrawSpecificConvert) CurrentDrawItem->m_Convert = CurrentConvert; } return CurrentDrawItem; }
void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) { int id = event.GetId(); wxPoint pos; m_canvas->SetIgnoreMouseEvents( true ); wxGetMousePosition( &pos.x, &pos.y ); pos.y += 20; switch( id ) // Stop placement commands before handling new command. { case ID_POPUP_LIBEDIT_END_CREATE_ITEM: case ID_LIBEDIT_EDIT_PIN: case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM: case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM: case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM: case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM: case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM: case ID_POPUP_ZOOM_BLOCK: case ID_POPUP_DELETE_BLOCK: case ID_POPUP_COPY_BLOCK: case ID_POPUP_SELECT_ITEMS_BLOCK: case ID_POPUP_MIRROR_X_BLOCK: case ID_POPUP_MIRROR_Y_BLOCK: case ID_POPUP_ROTATE_BLOCK: case ID_POPUP_PLACE_BLOCK: case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT: break; case ID_POPUP_LIBEDIT_CANCEL_EDITING: if( m_canvas->IsMouseCaptured() ) m_canvas->EndMouseCapture(); else m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); break; case ID_POPUP_LIBEDIT_DELETE_ITEM: m_canvas->EndMouseCapture(); break; default: m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); break; } INSTALL_UNBUFFERED_DC( dc, m_canvas ); switch( id ) { case ID_POPUP_LIBEDIT_CANCEL_EDITING: break; case ID_LIBEDIT_SELECT_CURRENT_LIB: SelectActiveLibrary(); break; case ID_LIBEDIT_SAVE_CURRENT_PART: { LIB_PART* part = GetCurPart(); if( !part ) { DisplayError( this, _( "No part to save." ) ); break; } PART_LIB* lib = GetCurLib(); if( !lib ) SelectActiveLibrary(); lib = GetCurLib(); if( !lib ) { DisplayError( this, _( "No library specified." ) ); break; } SaveOnePart( lib ); } break; case ID_LIBEDIT_EDIT_PIN_BY_PIN: m_editPinsPerPartOrConvert = m_mainToolBar->GetToolToggled( ID_LIBEDIT_EDIT_PIN_BY_PIN ); break; case ID_POPUP_LIBEDIT_END_CREATE_ITEM: m_canvas->MoveCursorToCrossHair(); if( m_drawItem ) { EndDrawGraphicItem( &dc ); } break; case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM: if( m_drawItem ) { m_canvas->CrossHairOff( &dc ); switch( m_drawItem->Type() ) { case LIB_ARC_T: case LIB_CIRCLE_T: case LIB_RECTANGLE_T: case LIB_POLYLINE_T: EditGraphicSymbol( &dc, m_drawItem ); break; case LIB_TEXT_T: EditSymbolText( &dc, m_drawItem ); break; default: ; } m_canvas->CrossHairOn( &dc ); } break; case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT: { // Delete the last created segment, while creating a polyline draw item if( m_drawItem == NULL ) break; m_canvas->MoveCursorToCrossHair(); STATUS_FLAGS oldFlags = m_drawItem->GetFlags(); m_drawItem->ClearFlags(); m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform ); ( (LIB_POLYLINE*) m_drawItem )->DeleteSegment( GetCrossHairPosition( true ) ); m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform ); m_drawItem->SetFlags( oldFlags ); m_lastDrawItem = NULL; } break; case ID_POPUP_LIBEDIT_DELETE_ITEM: if( m_drawItem ) deleteItem( &dc ); break; case ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST: if( m_drawItem == NULL ) break; if( m_drawItem->Type() == LIB_PIN_T ) StartMovePin( &dc ); else StartMoveDrawSymbol( &dc ); break; case ID_POPUP_LIBEDIT_MODIFY_ITEM: if( m_drawItem == NULL ) break; m_canvas->MoveCursorToCrossHair(); if( m_drawItem->Type() == LIB_RECTANGLE_T || m_drawItem->Type() == LIB_CIRCLE_T || m_drawItem->Type() == LIB_POLYLINE_T || m_drawItem->Type() == LIB_ARC_T ) { StartModifyDrawSymbol( &dc ); } break; case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM: if( m_drawItem == NULL ) break; m_canvas->CrossHairOff( &dc ); if( m_drawItem->Type() == LIB_FIELD_T ) { EditField( (LIB_FIELD*) m_drawItem ); } m_canvas->MoveCursorToCrossHair(); m_canvas->CrossHairOn( &dc ); break; case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM: case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM: case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM: { if( !m_drawItem || m_drawItem->Type() != LIB_PIN_T ) break; LIB_PART* part = GetCurPart(); SaveCopyInUndoList( part ); GlobalSetPins( (LIB_PIN*) m_drawItem, id ); m_canvas->MoveCursorToCrossHair(); m_canvas->Refresh(); } break; case ID_POPUP_ZOOM_BLOCK: m_canvas->SetAutoPanRequest( false ); GetScreen()->m_BlockLocate.SetCommand( BLOCK_ZOOM ); HandleBlockEnd( &dc ); break; case ID_POPUP_DELETE_BLOCK: m_canvas->SetAutoPanRequest( false ); GetScreen()->m_BlockLocate.SetCommand( BLOCK_DELETE ); m_canvas->MoveCursorToCrossHair(); HandleBlockEnd( &dc ); break; case ID_POPUP_COPY_BLOCK: m_canvas->SetAutoPanRequest( false ); GetScreen()->m_BlockLocate.SetCommand( BLOCK_COPY ); m_canvas->MoveCursorToCrossHair(); HandleBlockEnd( &dc ); break; case ID_POPUP_SELECT_ITEMS_BLOCK: m_canvas->SetAutoPanRequest( false ); GetScreen()->m_BlockLocate.SetCommand( BLOCK_SELECT_ITEMS_ONLY ); m_canvas->MoveCursorToCrossHair(); HandleBlockEnd( &dc ); break; case ID_POPUP_MIRROR_Y_BLOCK: m_canvas->SetAutoPanRequest( false ); GetScreen()->m_BlockLocate.SetCommand( BLOCK_MIRROR_Y ); m_canvas->MoveCursorToCrossHair(); HandleBlockPlace( &dc ); break; case ID_POPUP_MIRROR_X_BLOCK: m_canvas->SetAutoPanRequest( false ); GetScreen()->m_BlockLocate.SetCommand( BLOCK_MIRROR_X ); m_canvas->MoveCursorToCrossHair(); HandleBlockPlace( &dc ); break; case ID_POPUP_ROTATE_BLOCK: m_canvas->SetAutoPanRequest( false ); GetScreen()->m_BlockLocate.SetCommand( BLOCK_ROTATE ); m_canvas->MoveCursorToCrossHair(); HandleBlockPlace( &dc ); break; case ID_POPUP_PLACE_BLOCK: m_canvas->SetAutoPanRequest( false ); m_canvas->MoveCursorToCrossHair(); HandleBlockPlace( &dc ); break; default: DisplayError( this, wxT( "LIB_EDIT_FRAME::Process_Special_Functions error" ) ); break; } m_canvas->SetIgnoreMouseEvents( false ); if( GetToolId() == ID_NO_TOOL_SELECTED ) m_lastDrawItem = NULL; }