void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) { SCH_ITEM* repeater = GetRepeatItem(); if( !repeater ) return; //D( repeater>Show( 0, std::cout ); ) // clone the repeater, move it, insert into display list, then save a copy // via SetRepeatItem(); SCH_ITEM* my_clone = (SCH_ITEM*) repeater->Clone(); // If cloning a component then put into 'move' mode. if( my_clone->Type() == SCH_COMPONENT_T ) { wxPoint pos = GetCrossHairPosition() - ( (SCH_COMPONENT*) my_clone )->GetPosition(); my_clone->SetFlags( IS_NEW ); ( (SCH_COMPONENT*) my_clone )->SetTimeStamp( GetNewTimeStamp() ); my_clone->Move( pos ); my_clone->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode ); PrepareMoveItem( my_clone, DC ); } else { my_clone->Move( GetRepeatStep() ); if( my_clone->CanIncrementLabel() ) ( (SCH_TEXT*) my_clone )->IncrementLabel( GetRepeatDeltaLabel() ); GetScreen()->Append( my_clone ); if( my_clone->IsConnectable() ) { GetScreen()->TestDanglingEnds(); m_canvas->Refresh(); } else { my_clone->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); } SaveCopyInUndoList( my_clone, UR_NEW ); my_clone->ClearFlags(); } // clone my_clone, now that it has been moved, thus saving new position. SetRepeatItem( my_clone ); }
void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event ) { wxArrayString units; GRIDS grid_list = GetScreen()->GetGrids(); bool saveProjectConfig = false; DIALOG_EESCHEMA_OPTIONS dlg( this ); units.Add( GetUnitsLabel( INCHES ) ); units.Add( GetUnitsLabel( MILLIMETRES ) ); dlg.SetUnits( units, g_UserUnit ); dlg.SetGridSizes( grid_list, GetScreen()->GetGridCmdId() ); dlg.SetBusWidth( GetDefaultBusThickness() ); dlg.SetLineWidth( GetDefaultLineThickness() ); dlg.SetTextSize( GetDefaultTextSize() ); dlg.SetRepeatHorizontal( GetRepeatStep().x ); dlg.SetRepeatVertical( GetRepeatStep().y ); dlg.SetRepeatLabel( GetRepeatDeltaLabel() ); dlg.SetAutoSaveInterval( GetAutoSaveInterval() / 60 ); dlg.SetRefIdSeparator( LIB_PART::GetSubpartIdSeparator(), LIB_PART::GetSubpartFirstId() ); dlg.SetShowGrid( IsGridVisible() ); dlg.SetShowHiddenPins( m_showAllPins ); dlg.SetEnableMousewheelPan( m_canvas->GetEnableMousewheelPan() ); dlg.SetEnableZoomNoCenter( m_canvas->GetEnableZoomNoCenter() ); dlg.SetEnableAutoPan( m_canvas->GetEnableAutoPan() ); dlg.SetEnableHVBusOrientation( GetForceHVLines() ); dlg.SetShowPageLimits( m_showPageLimits ); dlg.SetFootprintPreview( m_footprintPreview ); dlg.SetAutoplaceFields( m_autoplaceFields ); dlg.SetAutoplaceJustify( m_autoplaceJustify ); dlg.SetAutoplaceAlign( m_autoplaceAlign ); dlg.Layout(); dlg.Fit(); dlg.SetMinSize( dlg.GetSize() ); dlg.SetTemplateFields( m_TemplateFieldNames.GetTemplateFieldNames() ); if( dlg.ShowModal() == wxID_CANCEL ) return; g_UserUnit = (EDA_UNITS_T)dlg.GetUnitsSelection(); wxRealPoint gridsize = grid_list[ (size_t) dlg.GetGridSelection() ].m_Size; m_LastGridSizeId = GetScreen()->SetGrid( gridsize ); int sep, firstId; dlg.GetRefIdSeparator( sep, firstId); if( sep != (int)LIB_PART::GetSubpartIdSeparator() || firstId != (int)LIB_PART::GetSubpartFirstId() ) { LIB_PART::SetSubpartIdNotation( sep, firstId ); saveProjectConfig = true; } SetDefaultBusThickness( dlg.GetBusWidth() ); SetDefaultLineThickness( dlg.GetLineWidth() ); if( dlg.GetTextSize() != GetDefaultTextSize() ) { SetDefaultTextSize( dlg.GetTextSize() ); saveProjectConfig = true; } wxPoint step; step.x = dlg.GetRepeatHorizontal(); step.y = dlg.GetRepeatVertical(); SetRepeatStep( step ); SetRepeatDeltaLabel( dlg.GetRepeatLabel() ); SetAutoSaveInterval( dlg.GetAutoSaveInterval() * 60 ); SetGridVisibility( dlg.GetShowGrid() ); m_showAllPins = dlg.GetShowHiddenPins(); m_canvas->SetEnableMousewheelPan( dlg.GetEnableMousewheelPan() ); m_canvas->SetEnableZoomNoCenter( dlg.GetEnableZoomNoCenter() ); m_canvas->SetEnableAutoPan( dlg.GetEnableAutoPan() ); SetForceHVLines( dlg.GetEnableHVBusOrientation() ); m_showPageLimits = dlg.GetShowPageLimits(); m_autoplaceFields = dlg.GetAutoplaceFields(); m_autoplaceJustify = dlg.GetAutoplaceJustify(); m_autoplaceAlign = dlg.GetAutoplaceAlign(); m_footprintPreview = dlg.GetFootprintPreview(); // Delete all template fieldnames and then restore them using the template field data from // the options dialog DeleteAllTemplateFieldNames(); TEMPLATE_FIELDNAMES newFieldNames = dlg.GetTemplateFields(); for( TEMPLATE_FIELDNAMES::iterator dlgfld = newFieldNames.begin(); dlgfld != newFieldNames.end(); ++dlgfld ) { TEMPLATE_FIELDNAME fld = *dlgfld; AddTemplateFieldName( fld ); } SaveSettings( config() ); // save values shared by eeschema applications. if( saveProjectConfig ) SaveProjectSettings( true ); m_canvas->Refresh( true ); }