/* * Traces the outline of the search block structures * The entire block follows the cursor */ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { SCH_DRAW_PANEL* panel =static_cast<SCH_DRAW_PANEL*>( aPanel ); LIB_EDIT_FRAME* frame = (LIB_EDIT_FRAME*) aPanel->GetParent(); KIGFX::SCH_VIEW* view = panel->GetView(); KIGFX::VIEW_GROUP* preview = view->GetPreview(); BASE_SCREEN* screen = aPanel->GetScreen(); BLOCK_SELECTOR* block = &screen->m_BlockLocate; LIB_PART* component = frame->GetCurPart(); if( component == NULL ) return; block->SetMoveVector( frame->GetCrossHairPosition( true ) - block->GetLastCursorPosition() ); preview->Clear(); view->SetVisible( preview, true ); for( unsigned ii = 0; ii < block->GetCount(); ii++ ) { LIB_ITEM* libItem = (LIB_ITEM*) block->GetItem( ii ); LIB_ITEM* copy = static_cast<LIB_ITEM*>( libItem->Clone() ); copy->Move( copy->GetPosition() + block->GetMoveVector() ); copy->SetFlags( IS_MOVED ); preview->Add( copy ); view->Hide( libItem ); } view->Update( preview ); }
/* * Draw (on m_panelShowPin) the pin currently edited * accroding to current settings in dialog */ void DIALOG_LIB_EDIT_PIN::OnPaintShowPanel( wxPaintEvent& event ) { wxPaintDC dc( m_panelShowPin ); wxSize dc_size = dc.GetSize(); dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 ); // Give a parent to m_dummyPin only from draw purpose. // In fact m_dummyPin should not have a parent, but draw functions need a parent // to know some options, about pin texts LIB_EDIT_FRAME* libframe = (LIB_EDIT_FRAME*) GetParent(); m_dummyPin->SetParent( libframe->GetCurPart() ); // Calculate a suitable scale to fit the available draw area EDA_RECT bBox = m_dummyPin->GetBoundingBox(); double xscale = (double) dc_size.x / bBox.GetWidth(); double yscale = (double) dc_size.y / bBox.GetHeight(); double scale = std::min( xscale, yscale ); // Give a 10% margin scale *= 0.9; dc.SetUserScale( scale, scale ); wxPoint offset = -bBox.Centre(); GRResetPenAndBrush( &dc ); // This is a flag for m_dummyPin->Draw uintptr_t flags = uintptr_t( PIN_DRAW_TEXTS | PIN_DRAW_DANGLING ); m_dummyPin->Draw( NULL, &dc, offset, COLOR4D::UNSPECIFIED, GR_COPY, (void*)flags, DefaultTransform ); m_dummyPin->SetParent(NULL); event.Skip(); }