// reassign copper text to new layers // enter with layer[] = table of new copper layers for each old copper layer // void CTextList::ReassignCopperLayers( int n_new_layers, int * layer ) { CText * t = GetFirstText(); while( t ) { int old_layer = t->m_layer; if( old_layer >= LAY_TOP_COPPER ) { int index = old_layer - LAY_TOP_COPPER; int new_layer = layer[index]; if( new_layer == old_layer ) { // do nothing } else if( new_layer == -1 ) { // delete this text t->Undraw(); RemoveText( t ); } else { // move to new layer t->Undraw(); t->m_layer = new_layer + LAY_TOP_COPPER; t->Draw( m_dlist, m_smfontutil ); } } t = GetNextText(); } }
void CTextList::TextUndoCallback( int type, void * ptr, BOOL undo ) { int ifound; undo_text * un_t = (undo_text*)ptr; CText * text = 0; if( undo ) { CTextList * tlist = un_t->m_tlist; if( type == CTextList::UNDO_TEXT_ADD || type == CTextList::UNDO_TEXT_MODIFY ) { // find existing CText object ifound = -1; for( int it=0; it<tlist->text_ptr.GetSize(); it++ ) { text = tlist->text_ptr[it]; if( text->m_guid == un_t->m_guid ) { ifound = it; break; } } if( ifound == -1 ) ASSERT(0); // text string not found if( type == CTextList::UNDO_TEXT_ADD ) { // delete text tlist->RemoveText( text ); } else if( type == CTextList::UNDO_TEXT_MODIFY ) { // modify text back CDisplayList * dl = text->m_dlist; SMFontUtil * smf = text->m_smfontutil; text->Undraw(); text->m_guid = un_t->m_guid; text->m_x = un_t->m_x; text->m_y = un_t->m_y; text->m_angle = un_t->m_angle; text->m_layer = un_t->m_layer; text->m_mirror = un_t->m_mirror; text->m_font_size = un_t->m_font_size; text->m_stroke_width = un_t->m_stroke_width; text->m_nchars = un_t->m_str.GetLength(); text->m_str = un_t->m_str; text->Draw( dl, smf ); } } else if( type == CTextList::UNDO_TEXT_DELETE ) { // add deleted text back into list CText * new_text = tlist->AddText( un_t->m_x, un_t->m_y, un_t->m_angle, un_t->m_mirror, un_t->m_bNegative, un_t->m_layer, un_t->m_font_size, un_t->m_stroke_width, &un_t->m_str ); new_text->m_guid = un_t->m_guid; } } delete un_t; }
void CTextList::MoveOrigin( int x_off, int y_off ) { for( int it=0; it<text_ptr.GetSize(); it++ ) { CText * t = text_ptr[it]; t->Undraw(); t->m_x += x_off; t->m_y += y_off; t->Draw( m_dlist, m_smfontutil ); } }