You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

170 lines
7.6 KiB

5 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software: you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation, either version 3 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include "dialog_eeschema_page_settings.h"
  20. #include <kiface_base.h>
  21. #include <general.h>
  22. #include <sch_edit_frame.h>
  23. #include <sch_screen.h>
  24. #include <schematic.h>
  25. #include <eeschema_settings.h>
  26. DIALOG_EESCHEMA_PAGE_SETTINGS::DIALOG_EESCHEMA_PAGE_SETTINGS( EDA_DRAW_FRAME* aParent,
  27. VECTOR2I aMaxUserSizeMils ) :
  28. DIALOG_PAGES_SETTINGS( aParent, schIUScale.IU_PER_MILS, aMaxUserSizeMils )
  29. {
  30. }
  31. DIALOG_EESCHEMA_PAGE_SETTINGS::~DIALOG_EESCHEMA_PAGE_SETTINGS()
  32. {
  33. auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
  34. wxCHECK( cfg, /* void */ );
  35. cfg->m_PageSettings.export_paper = m_PaperExport->GetValue();
  36. if ( !m_TextRevision->GetValue().IsEmpty() ) cfg->m_PageSettings.export_revision = m_RevisionExport->GetValue();
  37. if ( !m_TextDate->GetValue().IsEmpty() ) cfg->m_PageSettings.export_date = m_DateExport->GetValue();
  38. if ( !m_TextTitle->GetValue().IsEmpty() ) cfg->m_PageSettings.export_title = m_TitleExport->GetValue();
  39. if ( !m_TextCompany->GetValue().IsEmpty() ) cfg->m_PageSettings.export_company = m_CompanyExport->GetValue();
  40. if ( !m_TextComment1->GetValue().IsEmpty() ) cfg->m_PageSettings.export_comment1 = m_Comment1Export->GetValue();
  41. if ( !m_TextComment2->GetValue().IsEmpty() ) cfg->m_PageSettings.export_comment2 = m_Comment2Export->GetValue();
  42. if ( !m_TextComment3->GetValue().IsEmpty() ) cfg->m_PageSettings.export_comment3 = m_Comment3Export->GetValue();
  43. if ( !m_TextComment4->GetValue().IsEmpty() ) cfg->m_PageSettings.export_comment4 = m_Comment4Export->GetValue();
  44. if ( !m_TextComment5->GetValue().IsEmpty() ) cfg->m_PageSettings.export_comment5 = m_Comment5Export->GetValue();
  45. if ( !m_TextComment6->GetValue().IsEmpty() ) cfg->m_PageSettings.export_comment6 = m_Comment6Export->GetValue();
  46. if ( !m_TextComment7->GetValue().IsEmpty() ) cfg->m_PageSettings.export_comment7 = m_Comment7Export->GetValue();
  47. if ( !m_TextComment8->GetValue().IsEmpty() ) cfg->m_PageSettings.export_comment8 = m_Comment8Export->GetValue();
  48. if ( !m_TextComment9->GetValue().IsEmpty() ) cfg->m_PageSettings.export_comment9 = m_Comment9Export->GetValue();
  49. }
  50. void DIALOG_EESCHEMA_PAGE_SETTINGS::onTransferDataToWindow()
  51. {
  52. wxString msg;
  53. m_TextSheetCount->Show( true );
  54. m_TextSheetNumber->Show( true );
  55. m_PaperExport->Show( true );
  56. m_RevisionExport->Show( true );
  57. m_DateExport->Show( true );
  58. m_TitleExport->Show( true );
  59. m_CompanyExport->Show( true );
  60. m_Comment1Export->Show( true );
  61. m_Comment2Export->Show( true );
  62. m_Comment3Export->Show( true );
  63. m_Comment4Export->Show( true );
  64. m_Comment5Export->Show( true );
  65. m_Comment6Export->Show( true );
  66. m_Comment7Export->Show( true );
  67. m_Comment8Export->Show( true );
  68. m_Comment9Export->Show( true );
  69. // Init display value for schematic sub-sheet number
  70. wxString format = m_TextSheetCount->GetLabel();
  71. msg.Printf( format, m_screen->GetPageCount() );
  72. m_TextSheetCount->SetLabel( msg );
  73. format = m_TextSheetNumber->GetLabel();
  74. msg.Printf( format, m_screen->GetVirtualPageNumber() );
  75. m_TextSheetNumber->SetLabel( msg );
  76. auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
  77. wxCHECK( cfg, /* void */ );
  78. m_PaperExport->SetValue( cfg->m_PageSettings.export_paper );
  79. m_RevisionExport->SetValue( m_TextRevision->GetValue().IsEmpty() ? false : cfg->m_PageSettings.export_revision );
  80. m_DateExport->SetValue( m_TextDate->GetValue().IsEmpty() ? false : cfg->m_PageSettings.export_date );
  81. m_TitleExport->SetValue( m_TextTitle->GetValue().IsEmpty() ? false : cfg->m_PageSettings.export_title );
  82. m_CompanyExport->SetValue( m_TextCompany->GetValue().IsEmpty() ? false : cfg->m_PageSettings.export_company );
  83. m_Comment1Export->SetValue( m_TextComment1->GetValue().IsEmpty() ? false : cfg->m_PageSettings.export_comment1 );
  84. m_Comment2Export->SetValue( m_TextComment2->GetValue().IsEmpty() ? false : cfg->m_PageSettings.export_comment2 );
  85. m_Comment3Export->SetValue( m_TextComment3->GetValue().IsEmpty() ? false : cfg->m_PageSettings.export_comment3 );
  86. m_Comment4Export->SetValue( m_TextComment4->GetValue().IsEmpty() ? false : cfg->m_PageSettings.export_comment4 );
  87. m_Comment5Export->SetValue( m_TextComment5->GetValue().IsEmpty() ? false : cfg->m_PageSettings.export_comment5 );
  88. m_Comment6Export->SetValue( m_TextComment6->GetValue().IsEmpty() ? false : cfg->m_PageSettings.export_comment6 );
  89. m_Comment7Export->SetValue( m_TextComment7->GetValue().IsEmpty() ? false : cfg->m_PageSettings.export_comment7 );
  90. m_Comment8Export->SetValue( m_TextComment8->GetValue().IsEmpty() ? false : cfg->m_PageSettings.export_comment8 );
  91. m_Comment9Export->SetValue( m_TextComment9->GetValue().IsEmpty() ? false : cfg->m_PageSettings.export_comment9 );
  92. }
  93. bool DIALOG_EESCHEMA_PAGE_SETTINGS::onSavePageSettings()
  94. {
  95. wxCHECK_MSG( dynamic_cast<SCH_EDIT_FRAME*>( m_parent ), true,
  96. "DIALOG_PAGES_SETTINGS::OnDateApplyClick frame is not a schematic frame!" );
  97. // Exports settings to other sheets if requested:
  98. SCH_SCREENS ScreenList( dynamic_cast<SCH_EDIT_FRAME*>( m_parent )->Schematic().Root() );
  99. // Update page info and/or title blocks for all screens
  100. for( SCH_SCREEN* screen = ScreenList.GetFirst(); screen; screen = ScreenList.GetNext() )
  101. {
  102. if( screen == m_screen )
  103. continue;
  104. if( m_PaperExport->IsChecked() )
  105. screen->SetPageSettings( m_pageInfo );
  106. TITLE_BLOCK tb2 = screen->GetTitleBlock();
  107. if( m_RevisionExport->IsChecked() )
  108. tb2.SetRevision( m_tb.GetRevision() );
  109. if( m_DateExport->IsChecked() )
  110. tb2.SetDate( m_tb.GetDate() );
  111. if( m_TitleExport->IsChecked() )
  112. tb2.SetTitle( m_tb.GetTitle() );
  113. if( m_CompanyExport->IsChecked() )
  114. tb2.SetCompany( m_tb.GetCompany() );
  115. if( m_Comment1Export->IsChecked() )
  116. tb2.SetComment( 0, m_tb.GetComment( 0 ) );
  117. if( m_Comment2Export->IsChecked() )
  118. tb2.SetComment( 1, m_tb.GetComment( 1 ) );
  119. if( m_Comment3Export->IsChecked() )
  120. tb2.SetComment( 2, m_tb.GetComment( 2 ) );
  121. if( m_Comment4Export->IsChecked() )
  122. tb2.SetComment( 3, m_tb.GetComment( 3 ) );
  123. if( m_Comment5Export->IsChecked() )
  124. tb2.SetComment( 4, m_tb.GetComment( 4 ) );
  125. if( m_Comment6Export->IsChecked() )
  126. tb2.SetComment( 5, m_tb.GetComment( 5 ) );
  127. if( m_Comment7Export->IsChecked() )
  128. tb2.SetComment( 6, m_tb.GetComment( 6 ) );
  129. if( m_Comment8Export->IsChecked() )
  130. tb2.SetComment( 7, m_tb.GetComment( 7 ) );
  131. if( m_Comment9Export->IsChecked() )
  132. tb2.SetComment( 8, m_tb.GetComment( 8 ) );
  133. screen->SetTitleBlock( tb2 );
  134. }
  135. return true;
  136. }