void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event ) { if( m_DC ) // Delete old text. { CurrentDimension->Draw( m_Parent->GetCanvas(), m_DC, GR_XOR ); } m_Parent->SaveCopyInUndoList(CurrentDimension, UR_CHANGED); if( m_Name->GetValue() != wxEmptyString ) { CurrentDimension->SetText( m_Name->GetValue() ); } wxString msg; // Get new size value: msg = m_TxtSizeXCtrl->GetValue(); CurrentDimension->Text().SetWidth( ReturnValueFromString( g_UserUnit, msg ) ); msg = m_TxtSizeYCtrl->GetValue(); CurrentDimension->Text().SetHeight( ReturnValueFromString( g_UserUnit, msg ) ); // Get new position value: // It will be copied later in dimension, because msg = m_textCtrlPosX->GetValue(); wxPoint pos; pos.x = ReturnValueFromString( g_UserUnit, msg ); msg = m_textCtrlPosY->GetValue(); pos.y = ReturnValueFromString( g_UserUnit, msg ); CurrentDimension->Text().SetTextPosition( pos ); // Get new line thickness value: msg = m_TxtWidthCtrl->GetValue(); int width = ReturnValueFromString( g_UserUnit, msg ); int maxthickness = Clamp_Text_PenSize( width, CurrentDimension->Text().GetSize() ); if( width > maxthickness ) { DisplayError( NULL, _( "The text thickness is too large for the text size. It will be clamped") ); width = maxthickness; } CurrentDimension->SetWidth( width ); CurrentDimension->Text().SetThickness( width ); CurrentDimension->Text().SetMirrored( ( m_rbMirror->GetSelection() == 1 ) ? true : false ); CurrentDimension->SetLayer( m_SelLayerBox->GetLayerSelection() ); if( m_DC ) // Display new text { CurrentDimension->Draw( m_Parent->GetCanvas(), m_DC, GR_OR ); } m_Parent->OnModify(); EndModal( 1 ); }
/* Returns (in internal units) to coordinate between (in user units) */ wxPoint EDA_POSITION_CTRL::GetValue() { wxPoint coord; coord.x = ReturnValueFromString( m_UserUnit, m_FramePosX->GetValue() ); coord.y = ReturnValueFromString( m_UserUnit, m_FramePosY->GetValue() ); return coord; }
void WinEDA_SetOptionsFrame::Accept(wxCommandEvent& event) /**************************************************************************/ { wxSize grid; bool setgrid = TRUE; wxString msg; msg = m_DeltaStepCtrl_X->GetValue(); g_RepeatStep.x = ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits); msg = m_DeltaStepCtrl_Y->GetValue(); g_RepeatStep.y = ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits); g_RepeatDeltaLabel = m_DeltaLabelCtrl->GetValue(); if ( m_Show_Page_Limits->GetSelection() == 0 ) g_ShowPageLimits = TRUE; else g_ShowPageLimits = FALSE; if ( m_SelDirWires->GetSelection() == 0 ) g_HVLines = 1; else g_HVLines = 0; if ( m_Selunits->GetSelection() == 0 ) g_UnitMetric = 1; else g_UnitMetric = 0; if ( m_SelShowPins->GetSelection() == 0 ) g_ShowAllPins = FALSE; else g_ShowAllPins = TRUE; g_ShowGrid = m_Parent->m_Draw_Grid = m_ShowGridOpt->GetValue(); m_Parent->DrawPanel->m_AutoPAN_Enable = m_AutoPANOpt->GetValue(); m_Parent->m_Draw_Grid = m_ShowGridOpt->GetValue(); switch( m_SelGridSize->GetSelection() ) { default: setgrid = FALSE; break; case 0: grid = wxSize(50,50); break; case 1: grid = wxSize(25,25); break; case 2: grid = wxSize(10,10); break; } if ( m_Parent->m_CurrentScreen ) { if ( setgrid ) m_Parent->m_CurrentScreen->SetGrid(grid); m_Parent->m_CurrentScreen->SetRefreshReq(); } }
void WinEDA_PinPropertiesFrame::PinPropertiesAccept(wxCommandEvent& event) /*************************************************************************/ /* Met a jour les differents parametres pour le composant en cours d'édition */ { wxString msg; LastPinType = m_PinElectricalType->GetSelection(); LastPinShape = CodeShape[m_PinShape->GetSelection()]; LastPinOrient = CodeOrient[m_PinOrient->GetSelection()]; LastPinCommonConvert = m_CommonConvert->GetValue(); LastPinCommonUnit = m_CommonUnit->GetValue(); LastPinNoDraw = m_NoDraw->GetValue(); LastPinSize = m_PinSize->GetValue(); msg = m_PinNameSizeCtrl->GetValue(); LastPinNameSize = ReturnValueFromString(g_UnitMetric, msg, m_Parent->m_InternalUnits); msg = m_PinNumSizeCtrl->GetValue(); LastPinNumSize = ReturnValueFromString(g_UnitMetric, msg, m_Parent->m_InternalUnits); if ( CurrentDrawItem ) // Set Pin Name & Num { if ( ! (CurrentDrawItem->m_Flags & IS_NEW) ) // if IS_NEW, copy for undo is done before place m_Parent->SaveCopyInUndoList(); LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem; wxClientDC dc(m_Parent->DrawPanel); m_Parent->DrawPanel->PrepareGraphicContext(&dc); if ( m_Parent->GetScreen()->ManageCurseur ) // Pin is moving m_Parent->GetScreen()->ManageCurseur(m_Parent->DrawPanel, &dc, FALSE); else DrawLibraryDrawStruct(m_Parent->DrawPanel, &dc, CurrentLibEntry, 0,0, CurrentPin,CurrentUnit, g_XorMode); SetPinName(m_PinNameCtrl->GetValue(), LastPinNameSize); msg = m_PinNumCtrl->GetValue(); if ( msg.IsEmpty() ) msg = wxT("~"); SetPinNum(msg, LastPinNumSize); NewSizePin(LastPinSize); SetPinShape(LastPinShape); SetPinType(LastPinType); SetPinOrient(LastPinOrient); SetAttributsPin(TRUE, TRUE, TRUE); if ( m_Parent->GetScreen()->ManageCurseur ) m_Parent->GetScreen()->ManageCurseur(m_Parent->DrawPanel, &dc, FALSE); else DrawLibraryDrawStruct(m_Parent->DrawPanel, &dc, CurrentLibEntry, 0,0, CurrentPin,CurrentUnit, g_XorMode); } if ( CurrentDrawItem ) CurrentDrawItem->Display_Infos_DrawEntry(m_Parent); Close(); }
void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent ) { wxString text; int value; /* save old text in undo list if not already in edit */ /* or the label to be edited is part of a block */ if( m_CurrentText->GetFlags() == 0 || m_Parent->GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK ) m_Parent->SaveCopyInUndoList( m_CurrentText, UR_CHANGED ); m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() ); text = m_textLabel->GetValue(); if( !text.IsEmpty() ) m_CurrentText->m_Text = text; else if( !m_CurrentText->IsNew() ) { DisplayError( this, _( "Empty Text!" ) ); return; } m_CurrentText->SetOrientation( m_TextOrient->GetSelection() ); text = m_TextSize->GetValue(); value = ReturnValueFromString( g_UserUnit, text ); m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value; if( m_TextShape ) m_CurrentText->SetShape( m_TextShape->GetSelection() ); int style = m_TextStyle->GetSelection(); if( ( style & 1 ) ) m_CurrentText->m_Italic = 1; else m_CurrentText->m_Italic = 0; if( ( style & 2 ) ) { m_CurrentText->m_Bold = true; m_CurrentText->m_Thickness = GetPenSizeForBold( m_CurrentText->m_Size.x ); } else { m_CurrentText->m_Bold = false; m_CurrentText->m_Thickness = 0; } m_Parent->OnModify(); /* Make the text size as new default size if it is a new text */ if( m_CurrentText->IsNew() ) m_Parent->SetDefaultLabelSize( m_CurrentText->m_Size.x ); m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() ); m_Parent->GetCanvas()->MoveCursorToCrossHair(); EndModal( wxID_OK ); }
int EDA_VALUE_CTRL::GetValue() { int coord; wxString txtvalue = m_ValueCtrl->GetValue(); coord = ReturnValueFromString( m_UserUnit, txtvalue ); return coord; }
void WinEDA_TextModPropertiesFrame::TextModPropertiesAccept(wxCommandEvent& event) /*********************************************************************************/ { wxString msg; m_Parent->SaveCopyInUndoList(); if ( m_DC ) // Effacement ancien texte { m_CurrentTextMod->Draw(m_Parent->DrawPanel, m_DC, (m_CurrentTextMod->m_Flags & IS_MOVED) ? MoveVector : wxPoint(0,0), GR_XOR ); } m_CurrentTextMod->m_Text = m_Name->GetValue(); msg = m_TxtPosCtrlX->GetValue(); m_CurrentTextMod->m_Pos0.x = ReturnValueFromString(g_UnitMetric, msg, m_Parent->m_InternalUnits); msg = m_TxtPosCtrlY->GetValue(); m_CurrentTextMod->m_Pos0.y = ReturnValueFromString(g_UnitMetric, msg, m_Parent->m_InternalUnits); msg = m_TxtSizeCtrlX->GetValue(); m_CurrentTextMod->m_Size.x = ReturnValueFromString(g_UnitMetric, msg, m_Parent->m_InternalUnits); msg = m_TxtSizeCtrlY->GetValue(); m_CurrentTextMod->m_Size.y = ReturnValueFromString(g_UnitMetric, msg, m_Parent->m_InternalUnits); msg = m_TxtWidthCtlr->GetValue(); m_CurrentTextMod->SetWidth( ReturnValueFromString(g_UnitMetric, msg, m_Parent->m_InternalUnits) ); m_CurrentTextMod->m_NoShow = (m_Show->GetSelection() == 0) ? 0 : 1; m_CurrentTextMod->m_Orient = (m_Orient->GetSelection() == 0) ? 0 : 900; m_CurrentTextMod->SetDrawCoord(); if ( m_DC ) // Affichage nouveau texte { m_CurrentTextMod->Draw(m_Parent->DrawPanel, m_DC, (m_CurrentTextMod->m_Flags & IS_MOVED) ? MoveVector : wxPoint(0,0), GR_XOR ); } m_Parent->GetScreen()->SetModify(); ((MODULE*)m_CurrentTextMod->m_Parent)->m_LastEdit_Time = time(NULL); Close(TRUE); }
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; } ChangeFileNameExt( FileName,g_SchExtBuffer ); m_CurrentSheet->m_Field[SHEET_FILENAME].m_Text = FileName; msg = m_FileNameSize->GetValue(); m_CurrentSheet->m_Field[SHEET_FILENAME].m_Size.x = m_CurrentSheet->m_Field[SHEET_FILENAME].m_Size.y = ReturnValueFromString(g_UnitMetric, msg, m_Parent->m_InternalUnits); m_CurrentSheet->m_Field[VALUE].m_Text = m_SheetNameWin->GetValue(); msg = m_SheetNameSize->GetValue(); m_CurrentSheet->m_Field[VALUE].m_Size.x = m_CurrentSheet->m_Field[VALUE].m_Size.y = ReturnValueFromString(g_UnitMetric, msg, m_Parent->m_InternalUnits); if( (m_CurrentSheet->m_Field[VALUE].m_Text.IsEmpty() ) ) m_CurrentSheet->m_Field[VALUE].m_Text = m_CurrentSheet->m_Field[SHEET_FILENAME].m_Text; EndModal(TRUE); }
int EDA_GRAPHIC_TEXT_CTRL::ParseSize( const wxString& sizeText, EDA_UNITS_T aUnit ) { int textsize; textsize = ReturnValueFromString( aUnit, sizeText ); // Limit to reasonable size if( textsize < 10 ) textsize = 10; if( textsize > 3000 ) textsize = 3000; return textsize; }
void DIALOG_GRAPHIC_ITEM_PROPERTIES::OnOkClick( wxCommandEvent& event ) /*******************************************************************/ /* Copy values in text control to the item parameters */ { m_parent->SaveCopyInUndoList( m_Item, UR_CHANGED ); wxString msg; if( m_DC ) m_Item->Draw( m_parent->GetCanvas(), m_DC, GR_XOR ); msg = m_Center_StartXCtrl->GetValue(); m_Item->SetStartX( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() )); msg = m_Center_StartYCtrl->GetValue(); m_Item->SetStartY( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() )); msg = m_EndX_Radius_Ctrl->GetValue(); m_Item->SetEndX( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() )); msg = m_EndY_Ctrl->GetValue(); m_Item->SetEndY( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() )); msg = m_ThicknessCtrl->GetValue(); m_Item->SetWidth( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() )); msg = m_DefaultThicknessCtrl->GetValue(); int thickness = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ); m_Item->SetLayer( m_LayerSelectionCtrl->GetCurrentSelection() + FIRST_NO_COPPER_LAYER); if( m_Item->GetLayer() == EDGE_N ) m_brdSettings.m_EdgeSegmentWidth = thickness; else m_brdSettings.m_DrawSegmentWidth = thickness; if( m_Item->GetShape() == S_ARC ) { double angle; m_Angle_Ctrl->GetValue().ToDouble( &angle ); NORMALIZE_ANGLE_360(angle); m_Item->SetAngle( angle ); } m_parent->OnModify(); if( m_DC ) m_Item->Draw( m_parent->GetCanvas(), m_DC, GR_OR ); m_Item->DisplayInfo( m_parent ); m_parent->SetDesignSettings( m_brdSettings ); Close( true ); }
void WinEDA_LabelPropertiesFrame::TextPropertiesAccept(wxCommandEvent& event) { 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, wxT("Empty Text!") ); 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(); SetFlagModify(m_Parent->GetScreen()); Close(TRUE); }
void FOOTPRINT_EDIT_FRAME::Enter_Edge_Width( EDGE_MODULE* aEdge ) { wxString buffer; buffer = ReturnStringFromValue( g_UserUnit, GetDesignSettings().m_ModuleSegmentWidth, GetScreen()->GetInternalUnits() ); wxTextEntryDialog dlg( this, _( "New Width:" ), _( "Edge Width" ), buffer ); if( dlg.ShowModal() != wxID_OK ) return; // canceled by user buffer = dlg.GetValue( ); GetDesignSettings().m_ModuleSegmentWidth = ReturnValueFromString( g_UserUnit, buffer, GetScreen()->GetInternalUnits() ); if( aEdge ) { MODULE* module = GetBoard()->m_Modules; aEdge->SetWidth( GetDesignSettings().m_ModuleSegmentWidth ); module->CalculateBoundingBox(); OnModify(); } }
void DIALOG_EDIT_ONE_FIELD::TransfertDataToField() { m_textorient = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; wxString msg = m_TextSize->GetValue(); m_textsize = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ); switch( m_TextHJustificationOpt->GetSelection() ) { case 0: m_textHjustify = GR_TEXT_HJUSTIFY_LEFT; break; case 1: m_textHjustify = GR_TEXT_HJUSTIFY_CENTER; break; case 2: m_textHjustify = GR_TEXT_HJUSTIFY_RIGHT; break; } switch( m_TextVJustificationOpt->GetSelection() ) { case 0: m_textVjustify = GR_TEXT_VJUSTIFY_BOTTOM; break; case 1: m_textVjustify = GR_TEXT_VJUSTIFY_CENTER; break; case 2: m_textVjustify = GR_TEXT_VJUSTIFY_TOP; break; } }
void DialogEditModuleText::OnOkClick( wxCommandEvent& event ) { wxString msg; if ( m_module) m_parent->SaveCopyInUndoList( m_module, UR_CHANGED ); if( m_dc ) //Erase old text on screen { m_currentText->Draw( m_parent->GetCanvas(), m_dc, GR_XOR, (m_currentText->IsMoving()) ? MoveVector : wxPoint( 0, 0 ) ); } m_currentText->SetText( m_Name->GetValue() ); m_currentText->SetItalic( m_Style->GetSelection() == 1 ); wxPoint tmp; msg = m_TxtPosCtrlX->GetValue(); tmp.x = ReturnValueFromString( g_UserUnit, msg ); msg = m_TxtPosCtrlY->GetValue(); tmp.y = ReturnValueFromString( g_UserUnit, msg ); m_currentText->SetPos0( tmp ); wxSize textSize( wxSize( ReturnValueFromString( g_UserUnit, m_TxtSizeCtrlX->GetValue() ), ReturnValueFromString( g_UserUnit, m_TxtSizeCtrlY->GetValue() ) ) ); // Test for a reasonnable size: if( textSize.x < TEXTS_MIN_SIZE ) textSize.x = TEXTS_MIN_SIZE; if( textSize.y < TEXTS_MIN_SIZE ) textSize.y = TEXTS_MIN_SIZE; m_currentText->SetSize( textSize ), msg = m_TxtWidthCtlr->GetValue(); int width = ReturnValueFromString( g_UserUnit, msg ); // Test for a reasonnable width: if( width <= 1 ) width = 1; int maxthickness = Clamp_Text_PenSize(width, m_currentText->GetSize() ); if( width > maxthickness ) { DisplayError( NULL, _( "The text thickness is too large for the text size. It will be clamped" ) ); width = maxthickness; } m_currentText->SetThickness( width ); m_currentText->SetVisible( m_Show->GetSelection() == 0 ); int text_orient = (m_Orient->GetSelection() == 0) ? 0 : 900; m_currentText->SetOrientation( text_orient ); m_currentText->SetDrawCoord(); if( m_dc ) // Display new text { m_currentText->Draw( m_parent->GetCanvas(), m_dc, GR_XOR, (m_currentText->IsMoving()) ? MoveVector : wxPoint( 0, 0 ) ); } m_parent->OnModify(); if( m_module ) m_module->SetLastEditTime(); EndModal(1); }
bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC ) { if( aSheet == NULL ) return false; // Get the new texts DIALOG_SCH_SHEET_PROPS dlg( this ); wxString units = GetUnitsLabel( g_UserUnit ); dlg.SetFileName( aSheet->GetFileName() ); dlg.SetFileNameTextSize( ReturnStringFromValue( g_UserUnit, aSheet->GetFileNameSize() ) ); dlg.SetFileNameTextSizeUnits( units ); dlg.SetSheetName( aSheet->GetName() ); dlg.SetSheetNameTextSize( ReturnStringFromValue( g_UserUnit, aSheet->GetSheetNameSize() ) ); dlg.SetSheetNameTextSizeUnits( units ); /* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier * versions for the flex grid sizer in wxGTK that prevents the last * column from being sized correctly. It doesn't cause any problems * on win32 so it doesn't need to wrapped in ugly #ifdef __WXGTK__ * #endif. */ dlg.Layout(); dlg.Fit(); dlg.SetMinSize( dlg.GetSize() ); if( dlg.ShowModal() == wxID_CANCEL ) return false; wxFileName fileName = dlg.GetFileName(); fileName.SetExt( SchematicFileExtension ); if( !fileName.IsOk() ) { DisplayError( this, _( "File name is not valid!" ) ); return false; } // Duplicate sheet names are not valid. const SCH_SHEET* sheet = GetScreen()->GetSheet( dlg.GetSheetName() ); if( (sheet != NULL) && (sheet != aSheet) ) { DisplayError( this, wxString::Format( _( "A sheet named \"%s\" already exists." ), GetChars( dlg.GetSheetName() ) ) ); return false; } wxString msg; wxString tmp; bool loadFromFile = false; SCH_SCREEN* useScreen = NULL; wxString newFullFilename = fileName.GetFullPath(); // Inside Eeschema, filenames are stored using unix notation newFullFilename.Replace( wxT("\\"), wxT("/") ); // Search for a schematic file having the same filename exists, // already in use in the hierarchy, or on disk, // in order to reuse it if( !g_RootSheet->SearchHierarchy( newFullFilename, &useScreen ) ) loadFromFile = fileName.FileExists(); if( aSheet->GetScreen() == NULL ) // New sheet. { if( ( useScreen != NULL ) || loadFromFile ) // Load from existing file. { if( useScreen != NULL ) { msg.Printf( _( "A file named <%s> already exists in the current schematic hierarchy." ), GetChars( newFullFilename ) ); } else { msg.Printf( _( "A file named <%s> already exists." ), GetChars( newFullFilename ) ); } msg += _("\n\nDo you want to create a sheet with the contents of this file?" ); if( !IsOK( this, msg ) ) return false; } else // New file. { aSheet->SetScreen( new SCH_SCREEN() ); aSheet->GetScreen()->SetFileName( newFullFilename ); } } else // Existing sheet. { bool isUndoable = true; bool renameFile = false; // We are always using here a case insensitive comparison // to avoid issues under Windows, although under Unix // filenames are case sensitive. // But many users create schematic under both Unix and Windows if( newFullFilename.CmpNoCase( aSheet->GetFileName() ) != 0 ) { // Sheet file name changes cannot be undone. isUndoable = false; msg = _( "Changing the sheet file name cannot be undone. " ); if( ( useScreen != NULL ) || loadFromFile ) // Load from existing file. { wxString tmp; if( useScreen != NULL ) { tmp.Printf( _( "A file named <%s> already exists in the current schematic hierarchy." ), GetChars( newFullFilename ) ); } else { tmp.Printf( _( "A file named <%s> already exists." ), GetChars( newFullFilename ) ); } msg += tmp; msg += _("\n\nDo you want to replace the sheet with the contents of this file?" ); if( !IsOK( this, msg ) ) return false; if( loadFromFile ) aSheet->SetScreen( NULL ); } else // Save to new file name. { if( aSheet->GetScreenCount() > 1 ) { msg += _( "This sheet uses shared data in a complex hierarchy.\n\n" ); msg += _( "Do you wish to convert it to a simple hierarchical sheet?" ); if( !IsOK( NULL, msg ) ) return false; } renameFile = true; } } aSheet->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); m_canvas->SetIgnoreMouseEvents( true ); if( isUndoable ) SaveCopyInUndoList( aSheet, UR_CHANGED ); if( renameFile ) { aSheet->GetScreen()->SetFileName( newFullFilename ); SaveEEFile( aSheet->GetScreen() ); // If the the associated screen is shared by more than one sheet, remove the // screen and reload the file to a new screen. Failure to do this will trash // the screen reference counting in complex hierarchies. if( aSheet->GetScreenCount() > 1 ) { aSheet->SetScreen( NULL ); loadFromFile = true; } } } aSheet->SetFileName( newFullFilename ); if( useScreen ) aSheet->SetScreen( useScreen ); else if( loadFromFile ) aSheet->Load( this ); aSheet->SetFileNameSize( ReturnValueFromString( g_UserUnit, dlg.GetFileNameTextSize() ) ); aSheet->SetName( dlg.GetSheetName() ); aSheet->SetSheetNameSize( ReturnValueFromString( g_UserUnit, dlg.GetSheetNameTextSize() ) ); if( aSheet->GetName().IsEmpty() ) aSheet->SetName( wxString::Format( wxT( "Sheet%8.8lX" ), aSheet->GetTimeStamp() ) ); m_canvas->MoveCursorToCrossHair(); m_canvas->SetIgnoreMouseEvents( false ); aSheet->Draw( m_canvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); OnModify(); return true; }
/* Updates the different parameters for the component being edited */ void DIALOG_LIB_EDIT_TEXT::OnOkClick( wxCommandEvent& event ) { wxString Line; Line = m_TextValue->GetValue(); m_parent->m_textOrientation = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; wxString msg = m_TextSize->GetValue(); m_parent->m_textSize = ReturnValueFromString( g_UserUnit, msg ); m_parent->m_drawSpecificConvert = m_CommonConvert->GetValue() ? false : true; m_parent->m_drawSpecificUnit = m_CommonUnit->GetValue() ? false : true; if( m_graphicText ) { if( ! Line.IsEmpty() ) m_graphicText->SetText( Line ); else m_graphicText->SetText( wxT( "[null]" ) ); m_graphicText->m_Size.x = m_graphicText->m_Size.y = m_parent->m_textSize; m_graphicText->m_Orient = m_parent->m_textOrientation; if( m_parent->m_drawSpecificUnit ) m_graphicText->SetUnit( m_parent->GetUnit() ); else m_graphicText->SetUnit( 0 ); if( m_parent->m_drawSpecificConvert ) m_graphicText->SetConvert( m_parent->GetConvert() ); else m_graphicText->SetConvert( 0 ); if( ( m_TextShapeOpt->GetSelection() & 1 ) != 0 ) m_graphicText->m_Italic = true; else m_graphicText->m_Italic = false; if( ( m_TextShapeOpt->GetSelection() & 2 ) != 0 ) m_graphicText->m_Bold = true; else m_graphicText->m_Bold = false; switch( m_TextHJustificationOpt->GetSelection() ) { case 0: m_graphicText->m_HJustify = GR_TEXT_HJUSTIFY_LEFT; break; case 1: m_graphicText->m_HJustify = GR_TEXT_HJUSTIFY_CENTER; break; case 2: m_graphicText->m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; break; } switch( m_TextVJustificationOpt->GetSelection() ) { case 0: m_graphicText->m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; break; case 1: m_graphicText->m_VJustify = GR_TEXT_VJUSTIFY_CENTER; break; case 2: m_graphicText->m_VJustify = GR_TEXT_VJUSTIFY_TOP; break; } } if( m_parent->GetDrawItem() ) m_parent->SetMsgPanel( m_parent->GetDrawItem() ); EndModal(wxID_OK); }
bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportableSetupOnly ) { switch( m_PadInZoneOpt->GetSelection() ) { case 3: // Pads are not covered m_settings.SetPadConnection( PAD_NOT_IN_ZONE ); break; case 2: // Use thermal relief for THT pads m_settings.SetPadConnection( THT_THERMAL ); break; case 1: // Use thermal relief for pads m_settings.SetPadConnection( THERMAL_PAD ); break; case 0: // pads are covered by copper m_settings.SetPadConnection( PAD_IN_ZONE ); break; } switch( m_OutlineAppearanceCtrl->GetSelection() ) { case 0: m_settings.m_Zone_HatchingStyle = CPolyLine::NO_HATCH; break; case 1: m_settings.m_Zone_HatchingStyle = CPolyLine::DIAGONAL_EDGE; break; case 2: m_settings.m_Zone_HatchingStyle = CPolyLine::DIAGONAL_FULL; break; } m_settings.m_ArcToSegmentsCount = m_ArcApproximationOpt->GetSelection() == 1 ? ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF : ARC_APPROX_SEGMENTS_COUNT_LOW_DEF; if( m_Config ) { m_Config->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY, (long) m_settings.m_Zone_HatchingStyle ); wxString filter = m_DoNotShowNetNameFilter->GetValue(); m_Config->Write( ZONE_NET_FILTER_STRING_KEY, filter ); } m_netNameShowFilter = m_ShowNetNameFilter->GetValue(); m_settings.m_FillMode = (m_FillModeCtrl->GetSelection() == 0) ? 0 : 1; wxString txtvalue = m_ZoneClearanceCtrl->GetValue(); m_settings.m_ZoneClearance = ReturnValueFromString( g_UserUnit, txtvalue ); // Test if this is a reasonable value for this parameter // A too large value can hang Pcbnew #define CLEARANCE_MAX_VALUE ZONE_CLEARANCE_MAX_VALUE_MIL*IU_PER_MILS if( m_settings.m_ZoneClearance > CLEARANCE_MAX_VALUE ) { wxString msg; msg.Printf( _( "Clearance must be smaller than %f\" / %f mm." ), ZONE_CLEARANCE_MAX_VALUE_MIL / 1000.0, ZONE_CLEARANCE_MAX_VALUE_MIL * 0.0254 ); DisplayError( this, msg ); return false; } txtvalue = m_ZoneMinThicknessCtrl->GetValue(); m_settings.m_ZoneMinThickness = ReturnValueFromString( g_UserUnit, txtvalue ); if( m_settings.m_ZoneMinThickness < (ZONE_THICKNESS_MIN_VALUE_MIL*IU_PER_MILS) ) { wxString msg; msg.Printf( _( "Minimum width must be larger than %f\" / %f mm." ), ZONE_THICKNESS_MIN_VALUE_MIL / 1000.0, ZONE_THICKNESS_MIN_VALUE_MIL * 0.0254 ); DisplayError( this, msg ); return false; } m_settings.SetCornerSmoothingType( m_cornerSmoothingChoice->GetSelection() ); txtvalue = m_cornerSmoothingCtrl->GetValue(); m_settings.SetCornerRadius( ReturnValueFromString( g_UserUnit, txtvalue ) ); m_settings.m_ZonePriority = m_PriorityLevelCtrl->GetValue(); if( m_OrientEdgesOpt->GetSelection() == 0 ) m_settings.m_Zone_45_Only = false; else m_settings.m_Zone_45_Only = true; m_settings.m_ThermalReliefGap = ReturnValueFromTextCtrl( *m_AntipadSizeValue ); m_settings.m_ThermalReliefCopperBridge = ReturnValueFromTextCtrl( *m_CopperWidthValue ); if( m_Config ) { ConfigBaseWriteDouble( m_Config, ZONE_CLEARANCE_WIDTH_STRING_KEY, (double) m_settings.m_ZoneClearance / IU_PER_MILS ); ConfigBaseWriteDouble( m_Config, ZONE_MIN_THICKNESS_WIDTH_STRING_KEY, (double) m_settings.m_ZoneMinThickness / IU_PER_MILS ); ConfigBaseWriteDouble( m_Config, ZONE_THERMAL_RELIEF_GAP_STRING_KEY, (double) m_settings.m_ThermalReliefGap / IU_PER_MILS ); ConfigBaseWriteDouble( m_Config, ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY, (double) m_settings.m_ThermalReliefCopperBridge / IU_PER_MILS ); } if( m_settings.m_ThermalReliefCopperBridge <= m_settings.m_ZoneMinThickness ) { DisplayError( this, _( "Thermal relief spoke width is smaller than the minimum width." ) ); return false; } // If we use only exportable to others zones parameters, exit here: if( aUseExportableSetupOnly ) return true; // Get the layer selection for this zone int ii = m_LayerSelectionCtrl->GetFirstSelected(); if( ii < 0 && aPromptForErrors ) { DisplayError( this, _( "No layer selected." ) ); return false; } m_settings.m_CurrentZone_Layer = m_LayerId[ii]; // Get the net name selection for this zone ii = m_ListNetNameSelection->GetSelection(); if( ii < 0 && aPromptForErrors ) { DisplayError( this, _( "No net selected." ) ); return false; } if( ii == 0 ) // the not connected option was selected: this is not a good practice: warn: { if( !IsOK( this, _( "You have chosen the \"not connected\" option. This will create insulated copper islands. Are you sure ?" ) ) ) return false; } wxString net_name = m_ListNetNameSelection->GetString( ii ); m_settings.m_NetcodeSelection = 0; // Search net_code for this net, if a net was selected if( m_ListNetNameSelection->GetSelection() > 0 ) { NETINFO_ITEM* net = m_Parent->GetBoard()->FindNet( net_name ); if( net ) m_settings.m_NetcodeSelection = net->GetNet(); } return true; }
void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) { if( m_drawItem == NULL || m_drawItem->Type() != LIB_PIN_T ) return; STATUS_FLAGS item_flags = m_drawItem->GetFlags(); // save flags to restore them after editing LIB_PIN* pin = (LIB_PIN*) m_drawItem; DIALOG_LIB_EDIT_PIN dlg( this, pin ); wxString units = GetUnitsLabel( g_UserUnit ); dlg.SetOrientationList( LIB_PIN::GetOrientationNames(), LIB_PIN::GetOrientationSymbols() ); dlg.SetOrientation( LIB_PIN::GetOrientationCodeIndex( pin->GetOrientation() ) ); dlg.SetStyleList( LIB_PIN::GetStyleNames(), LIB_PIN::GetStyleSymbols() ); dlg.SetStyle( LIB_PIN::GetStyleCodeIndex( pin->GetShape() ) ); dlg.SetElectricalTypeList( LIB_PIN::GetElectricalTypeNames(), LIB_PIN::GetElectricalTypeSymbols() ); dlg.SetElectricalType( pin->GetType() ); dlg.SetName( pin->GetName() ); dlg.SetNameTextSize( ReturnStringFromValue( g_UserUnit, pin->GetNameTextSize() ) ); dlg.SetNameTextSizeUnits( units ); dlg.SetPadName( pin->GetNumberString() ); dlg.SetPadNameTextSize( ReturnStringFromValue( g_UserUnit, pin->GetNumberTextSize() ) ); dlg.SetPadNameTextSizeUnits( units ); dlg.SetLength( ReturnStringFromValue( g_UserUnit, pin->GetLength() ) ); dlg.SetLengthUnits( units ); dlg.SetAddToAllParts( pin->GetUnit() == 0 ); dlg.SetAddToAllBodyStyles( pin->GetConvert() == 0 ); dlg.SetVisible( pin->IsVisible() ); /* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier * versions for the flex grid sizer in wxGTK that prevents the last * column from being sized correctly. It doesn't cause any problems * on win32 so it doesn't need to wrapped in ugly #ifdef __WXGTK__ * #endif. */ dlg.Layout(); dlg.Fit(); dlg.SetMinSize( dlg.GetSize() ); // dlg.SetLastSizeAndPosition(); // done in DIALOG_SHIM::Show() if( dlg.ShowModal() == wxID_CANCEL ) { if( pin->IsNew() ) { pin->SetFlags( IS_CANCELLED ); m_canvas->EndMouseCapture(); } return; } // Save the pin properties to use for the next new pin. LastPinNameSize = ReturnValueFromString( g_UserUnit, dlg.GetNameTextSize() ); LastPinNumSize = ReturnValueFromString( g_UserUnit, dlg.GetPadNameTextSize() ); LastPinOrient = LIB_PIN::GetOrientationCode( dlg.GetOrientation() ); LastPinLength = ReturnValueFromString( g_UserUnit, dlg.GetLength() ); LastPinShape = LIB_PIN::GetStyleCode( dlg.GetStyle() ); LastPinType = dlg.GetElectricalType(); LastPinCommonConvert = dlg.GetAddToAllBodyStyles(); LastPinCommonUnit = dlg.GetAddToAllParts(); LastPinVisible = dlg.GetVisible(); pin->EnableEditMode( true, m_editPinsPerPartOrConvert ); pin->SetName( dlg.GetName() ); pin->SetNameTextSize( LastPinNameSize ); pin->SetNumber( dlg.GetPadName() ); pin->SetNumberTextSize( LastPinNumSize ); pin->SetOrientation( LastPinOrient ); pin->SetLength( LastPinLength ); pin->SetType( LastPinType ); pin->SetShape( LastPinShape ); pin->SetConversion( ( LastPinCommonConvert ) ? 0 : m_convert ); pin->SetPartNumber( ( LastPinCommonUnit ) ? 0 : m_unit ); pin->SetVisible( LastPinVisible ); if( pin->IsModified() || pin->IsNew() ) { if( !pin->InEditMode() ) SaveCopyInUndoList( pin->GetParent() ); OnModify( ); MSG_PANEL_ITEMS items; pin->GetMsgPanelInfo( items ); SetMsgPanel( items ); m_canvas->Refresh(); } pin->EnableEditMode( false, m_editPinsPerPartOrConvert ); // Restore pin flags, that can be changed by the dialog editor pin->ClearFlags(); pin->SetFlags( item_flags ); }