Fix some issues with sheet border color handling.
This commit is contained in:
parent
591428b0d9
commit
c663965498
|
@ -305,6 +305,13 @@ void DIALOG_PLOT_SCHEMATIC::getPlotOptions( int* aDefaultLineWidth )
|
|||
}
|
||||
|
||||
|
||||
COLOR_SETTINGS* DIALOG_PLOT_SCHEMATIC::getColorSettings()
|
||||
{
|
||||
int selection = m_colorTheme->GetSelection();
|
||||
return static_cast<COLOR_SETTINGS*>( m_colorTheme->GetClientData( selection ) );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PLOT_SCHEMATIC::OnPlotCurrent( wxCommandEvent& event )
|
||||
{
|
||||
PlotSchematic( false );
|
||||
|
|
|
@ -80,6 +80,8 @@ private:
|
|||
void setModeColor( bool aColor )
|
||||
{ m_ModeColorOption->SetSelection( aColor ? 0 : 1 ); }
|
||||
|
||||
COLOR_SETTINGS* getColorSettings();
|
||||
|
||||
/**
|
||||
* Set the m_outputDirectoryName variable to the selected directory from directory dialog.
|
||||
*/
|
||||
|
@ -134,6 +136,8 @@ private:
|
|||
|
||||
// SVG
|
||||
void createSVGFile( bool aPlotAll, bool aPlotFrameRef, int aDefaultLineWidth );
|
||||
bool plotOneSheetSVG( const wxString& aFileName, SCH_SCREEN* aScreen, int aDefaultLineWidth,
|
||||
bool aPlotBlackAndWhite, bool aPlotFrameRef );
|
||||
|
||||
/**
|
||||
* Create a file name with an absolute path name
|
||||
|
@ -148,12 +152,4 @@ private:
|
|||
wxFileName createPlotFileName( wxTextCtrl* aOutputDirectoryName,
|
||||
wxString& aPlotFileName,
|
||||
wxString& aExtension, REPORTER* aReporter = NULL );
|
||||
|
||||
public:
|
||||
// This function is static because it is called by libedit
|
||||
// outside a dialog. This is the reason we need aFrame as parameter
|
||||
static bool plotOneSheetSVG( EDA_DRAW_FRAME* aFrame, const wxString& aFileName,
|
||||
SCH_SCREEN* aScreen, int aDefaultLineWidth,
|
||||
bool aPlotBlackAndWhite, bool aPlotFrameRef,
|
||||
bool aPlotBackgroundColor, COLOR_SETTINGS* aColors );
|
||||
};
|
||||
|
|
|
@ -112,13 +112,10 @@ bool DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF( const wxString& aFileName,
|
|||
{
|
||||
DXF_PLOTTER* plotter = new DXF_PLOTTER();
|
||||
|
||||
auto colors = static_cast<COLOR_SETTINGS*>(
|
||||
m_colorTheme->GetClientData( m_colorTheme->GetSelection() ) );
|
||||
|
||||
const PAGE_INFO& pageInfo = aScreen->GetPageSettings();
|
||||
plotter->SetPageSettings( pageInfo );
|
||||
plotter->SetColorMode( getModeColor() );
|
||||
plotter->SetColorSettings( colors );
|
||||
plotter->SetColorSettings( getColorSettings() );
|
||||
// Currently, plot units are in decimil
|
||||
plotter->SetViewport( aPlotOffset, IU_PER_MILS/10, aScale, false );
|
||||
|
||||
|
|
|
@ -60,14 +60,11 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef,
|
|||
else
|
||||
sheetList.push_back( m_parent->GetCurrentSheet() );
|
||||
|
||||
auto colors = static_cast<COLOR_SETTINGS*>(
|
||||
m_colorTheme->GetClientData( m_colorTheme->GetSelection() ) );
|
||||
|
||||
// Allocate the plotter and set the job level parameter
|
||||
PDF_PLOTTER* plotter = new PDF_PLOTTER();
|
||||
plotter->SetDefaultLineWidth( aDefaultLineWidth );
|
||||
plotter->SetColorMode( getModeColor() );
|
||||
plotter->SetColorSettings( colors );
|
||||
plotter->SetColorSettings( getColorSettings() );
|
||||
plotter->SetCreator( wxT( "Eeschema-PDF" ) );
|
||||
plotter->SetTitle( m_parent->GetTitleBlock().GetTitle() );
|
||||
|
||||
|
|
|
@ -138,14 +138,11 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& aFileName,
|
|||
double aScale,
|
||||
bool aPlotFrameRef )
|
||||
{
|
||||
auto colors = static_cast<COLOR_SETTINGS*>(
|
||||
m_colorTheme->GetClientData( m_colorTheme->GetSelection() ) );
|
||||
|
||||
PS_PLOTTER* plotter = new PS_PLOTTER();
|
||||
plotter->SetPageSettings( aPageInfo );
|
||||
plotter->SetDefaultLineWidth( aDefaultLineWidth );
|
||||
plotter->SetColorMode( getModeColor() );
|
||||
plotter->SetColorSettings( colors );
|
||||
plotter->SetColorSettings( getColorSettings() );
|
||||
// Currently, plot units are in decimil
|
||||
plotter->SetViewport( aPlot0ffset, IU_PER_MILS/10, aScale, false );
|
||||
|
||||
|
@ -162,7 +159,7 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& aFileName,
|
|||
|
||||
plotter->StartPlot();
|
||||
|
||||
if( m_plotBackgroundColor )
|
||||
if( m_plotBackgroundColor->GetValue() )
|
||||
{
|
||||
plotter->SetColor( plotter->ColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ) );
|
||||
wxPoint end( plotter->PageSettings().GetWidthIU(),
|
||||
|
|
|
@ -49,9 +49,6 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef,
|
|||
SCH_SHEET_PATH oldsheetpath = m_parent->GetCurrentSheet();
|
||||
SCH_SHEET_LIST sheetList;
|
||||
|
||||
auto colors = static_cast<COLOR_SETTINGS*>(
|
||||
m_colorTheme->GetClientData( m_colorTheme->GetSelection() ) );
|
||||
|
||||
if( aPrintAll )
|
||||
sheetList.BuildSheetList( g_RootSheet );
|
||||
else
|
||||
|
@ -72,10 +69,8 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef,
|
|||
wxFileName plotFileName = createPlotFileName( m_outputDirectoryName,
|
||||
fname, ext, &reporter );
|
||||
|
||||
bool success = plotOneSheetSVG( m_parent, plotFileName.GetFullPath(), screen,
|
||||
aDefaultLineWidth, getModeColor() ? false : true,
|
||||
aPrintFrameRef, m_plotBackgroundColor->GetValue(),
|
||||
colors );
|
||||
bool success = plotOneSheetSVG( plotFileName.GetFullPath(), screen, aDefaultLineWidth,
|
||||
getModeColor() ? false : true, aPrintFrameRef );
|
||||
|
||||
if( !success )
|
||||
{
|
||||
|
@ -103,25 +98,18 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef,
|
|||
}
|
||||
|
||||
|
||||
bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( EDA_DRAW_FRAME* aFrame,
|
||||
const wxString& aFileName,
|
||||
SCH_SCREEN* aScreen,
|
||||
int aDefaultLineWidth,
|
||||
bool aPlotBlackAndWhite,
|
||||
bool aPlotFrameRef,
|
||||
bool aPlotBackgroundColor,
|
||||
COLOR_SETTINGS* aColors )
|
||||
bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( const wxString& aFileName,
|
||||
SCH_SCREEN* aScreen,
|
||||
int aDefaultLineWidth,
|
||||
bool aPlotBlackAndWhite,
|
||||
bool aPlotFrameRef )
|
||||
{
|
||||
SVG_PLOTTER* plotter = new SVG_PLOTTER();
|
||||
|
||||
if( !aColors )
|
||||
aColors = aFrame->GetColorSettings();
|
||||
|
||||
const PAGE_INFO& pageInfo = aScreen->GetPageSettings();
|
||||
plotter->SetPageSettings( pageInfo );
|
||||
plotter->SetDefaultLineWidth( aDefaultLineWidth );
|
||||
plotter->SetColorMode( aPlotBlackAndWhite ? false : true );
|
||||
plotter->SetColorSettings( aColors );
|
||||
plotter->SetColorSettings( getColorSettings() );
|
||||
wxPoint plot_offset;
|
||||
double scale = 1.0;
|
||||
// Currently, plot units are in decimil
|
||||
|
@ -140,7 +128,7 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( EDA_DRAW_FRAME* aFrame,
|
|||
|
||||
plotter->StartPlot();
|
||||
|
||||
if( aPlotBackgroundColor )
|
||||
if( m_plotBackgroundColor->GetValue() )
|
||||
{
|
||||
plotter->SetColor( plotter->ColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ) );
|
||||
wxPoint end( plotter->PageSettings().GetWidthIU(),
|
||||
|
@ -150,9 +138,9 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( EDA_DRAW_FRAME* aFrame,
|
|||
|
||||
if( aPlotFrameRef )
|
||||
{
|
||||
PlotWorkSheet( plotter, &aScreen->Prj(), aFrame->GetTitleBlock(), pageInfo,
|
||||
PlotWorkSheet( plotter, &aScreen->Prj(), m_parent->GetTitleBlock(), pageInfo,
|
||||
aScreen->m_ScreenNumber, aScreen->m_NumberOfScreens,
|
||||
aFrame->GetScreenDesc(), aScreen->GetFileName(),
|
||||
m_parent->GetScreenDesc(), aScreen->GetFileName(),
|
||||
plotter->GetColorMode() ? COLOR4D::UNSPECIFIED : COLOR4D::BLACK );
|
||||
}
|
||||
|
||||
|
|
|
@ -184,35 +184,4 @@ SCH_IO_MGR::SCH_FILE_T SCH_IO_MGR::GuessPluginTypeFromSchPath( const wxString& a
|
|||
}
|
||||
|
||||
|
||||
SCH_SHEET* SCH_IO_MGR::Load( SCH_FILE_T aFileType, const wxString& aFileName, KIWAY* aKiway,
|
||||
SCH_SHEET* aAppendToMe, const PROPERTIES* aProperties )
|
||||
{
|
||||
// release the SCH_PLUGIN even if an exception is thrown.
|
||||
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( FindPlugin( aFileType ) );
|
||||
|
||||
if( (SCH_PLUGIN*) pi ) // test pi->plugin
|
||||
{
|
||||
return pi->Load( aFileName, aKiway, aAppendToMe, aProperties ); // virtual
|
||||
}
|
||||
|
||||
THROW_IO_ERROR( wxString::Format( FMT_NOTFOUND, ShowType( aFileType ).GetData() ) );
|
||||
}
|
||||
|
||||
|
||||
void SCH_IO_MGR::Save( SCH_FILE_T aFileType, const wxString& aFileName,
|
||||
SCH_SCREEN* aSchematic, KIWAY* aKiway, const PROPERTIES* aProperties )
|
||||
{
|
||||
// release the SCH_PLUGIN even if an exception is thrown.
|
||||
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( FindPlugin( aFileType ) );
|
||||
|
||||
if( (SCH_PLUGIN*) pi ) // test pi->plugin
|
||||
{
|
||||
pi->Save( aFileName, aSchematic, aKiway, aProperties ); // virtual
|
||||
return;
|
||||
}
|
||||
|
||||
THROW_IO_ERROR( wxString::Format( FMT_NOTFOUND, ShowType( aFileType ).GetData() ) );
|
||||
}
|
||||
|
||||
|
||||
DECLARE_ENUM_VECTOR( SCH_IO_MGR, SCH_FILE_T )
|
||||
|
|
|
@ -122,58 +122,6 @@ public:
|
|||
* Return a plugin type given a schematic using the file extension of \a aSchematicPath.
|
||||
*/
|
||||
static SCH_FILE_T GuessPluginTypeFromSchPath( const wxString& aSchematicPath );
|
||||
|
||||
/**
|
||||
* Load the requested #SCH_PLUGIN and if found, calls the SCH_PLUGIN->Load(..) function
|
||||
* on it using the arguments passed to this function. After the SCH_PLUGIN->Load()
|
||||
* function returns, the #SCH_PLUGIN is Released() as part of this call.
|
||||
*
|
||||
* @param aFileType is the #SCH_FILE_T of file to load.
|
||||
*
|
||||
* @param aFileName is the name of the file to load.
|
||||
*
|
||||
* @param aKiway is the #KIWAY object used to access the component libraries loaded
|
||||
* by the project.
|
||||
*
|
||||
* @param aAppendToMe is an existing #SCH_SHEET to append to, use NULL if a new
|
||||
* #SCH_SHEET load is wanted.
|
||||
*
|
||||
* @param aProperties is an associative array that allows the caller to pass additional
|
||||
* tuning parameters to the #SCH_PLUGIN.
|
||||
*
|
||||
* @return the loaded schematic which the caller owns. This is never NULL because
|
||||
* exception thrown if an error occurs.
|
||||
*
|
||||
* @throw IO_ERROR if the #SCH_PLUGIN cannot be found, file cannot be found
|
||||
* or file cannot be loaded.
|
||||
*/
|
||||
static SCH_SHEET* Load( SCH_FILE_T aFileType, const wxString& aFileName, KIWAY* aKiway,
|
||||
SCH_SHEET* aAppendToMe = NULL, const PROPERTIES* aProperties = NULL );
|
||||
|
||||
/**
|
||||
* Write either a full aSchematic to a storage file in a format that this
|
||||
* implementation knows about, or it can be used to write a portion of
|
||||
* aSchematic to a special kind of export file.
|
||||
*
|
||||
* @param aFileType is the #SCH_FILE_T of file to save.
|
||||
*
|
||||
* @param aFileName is the name of a file to save to on disk.
|
||||
*
|
||||
* @param aSchematic is the #SCH_SCREEN document (data tree) to save or export to disk.
|
||||
*
|
||||
* @param aKiway is the #KIWAY object used to access the component libraries loaded
|
||||
* by the project.
|
||||
*
|
||||
* @param aProperties is an associative array that can be used to tell the
|
||||
* saver how to save the file, because it can take any number of
|
||||
* additional named tuning arguments that the plugin is known to support.
|
||||
* The caller continues to own this object (plugin may not delete it), and
|
||||
* plugins should expect it to be optionally NULL.
|
||||
*
|
||||
* @throw IO_ERROR if there is a problem saving or exporting.
|
||||
*/
|
||||
static void Save( SCH_FILE_T aFileType, const wxString& aFileName,
|
||||
SCH_SCREEN* aSchematic, KIWAY* aKiway, const PROPERTIES* aProperties = NULL );
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -248,13 +248,17 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr
|
|||
SCH_SHEET* sheet = (SCH_SHEET*) aItem;
|
||||
COLOR4D sheetColor = COLOR4D::UNSPECIFIED;
|
||||
|
||||
if( aLayer == LAYER_SHEET )
|
||||
sheetColor = sheet->GetBorderColor();
|
||||
else if( aLayer == LAYER_SHEET_BACKGROUND )
|
||||
sheetColor = sheet->GetBackgroundColor();
|
||||
// Lazy fixup of legacy sheets with no color specifications
|
||||
if( sheet->GetBorderColor() == COLOR4D::UNSPECIFIED )
|
||||
sheet->SetBorderColor( m_schSettings.GetLayerColor( LAYER_SHEET ) );
|
||||
|
||||
if( sheetColor != COLOR4D::UNSPECIFIED )
|
||||
color = sheetColor;
|
||||
if( sheet->GetBackgroundColor() == COLOR4D::UNSPECIFIED )
|
||||
sheet->SetBackgroundColor( m_schSettings.GetLayerColor( LAYER_SHEET_BACKGROUND ) );
|
||||
|
||||
if( aLayer == LAYER_SHEET )
|
||||
color = sheet->GetBorderColor();
|
||||
else if( aLayer == LAYER_SHEET_BACKGROUND )
|
||||
color = sheet->GetBackgroundColor();
|
||||
}
|
||||
|
||||
if( aItem->IsBrightened() && !aDrawingShadows ) // Selection disambiguation, etc.
|
||||
|
|
|
@ -909,6 +909,11 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter )
|
|||
wxString Text;
|
||||
wxPoint pos;
|
||||
|
||||
COLOR4D borderColor = GetBorderColor();
|
||||
|
||||
if( borderColor == COLOR4D::UNSPECIFIED )
|
||||
borderColor = aPlotter->ColorSettings()->GetColor( LAYER_SHEET );
|
||||
|
||||
aPlotter->SetColor( GetBorderColor() );
|
||||
|
||||
int thickness = GetPenSize();
|
||||
|
|
Loading…
Reference in New Issue