Commit 6431e9c9 authored by charras's avatar charras

pcbnew, gerbview: print&plot: error message displayed when no layer selected.

parent 6cdf7e83
......@@ -5,6 +5,14 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2009-mar-10 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
++pcbnew:
++gerbview:
print,plot: error message displayed when no layer selected.
2009-Mar-5 UPDATE Vesa Solonen <vesa.solonen@hut.fi>
================================================================================
++pcbnew:
......
......@@ -21,10 +21,6 @@
#include "id.h"
#include "dialog_create_component.h"
/* Routines locales */
/* Variables locales */
/**********************************************/
void WinEDA_LibeditFrame::DisplayLibInfos()
......@@ -47,7 +43,7 @@ void WinEDA_LibeditFrame::DisplayLibInfos()
if( !CurrentAliasName.IsEmpty() )
msg << wxT( " Alias " ) << CurrentAliasName;
}
wxChar UnitLetter[] = wxT( "?ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
static wxChar UnitLetter[] = wxT( "?ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
msg << wxT( " Unit " ) << UnitLetter[CurrentUnit];
if( CurrentConvert > 1 )
......@@ -66,7 +62,7 @@ void WinEDA_LibeditFrame::DisplayLibInfos()
void WinEDA_LibeditFrame::SelectActiveLibrary()
/**************************************************/
/* Routine to Select Current library
/* Function to select the current library (working library)
*/
{
LibraryStruct* Lib;
......@@ -80,10 +76,15 @@ void WinEDA_LibeditFrame::SelectActiveLibrary()
}
/*************************************************/
/* Routine to Load one selected library content. */
/*************************************************/
bool WinEDA_LibeditFrame::LoadOneLibraryPart()
/**
* Function LoadOneLibraryPart()
* load a library component from the current selected library
* Prompt user for component name
* If there is no current selected library,
* prompt user for library name and make the selected library the current lib.
*/
{
int i;
wxString msg;
......@@ -96,9 +97,10 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPart()
return FALSE;
}
if( CurrentLib == NULL )
if( CurrentLib == NULL ) // No current lib, ask user for the library to use
{
SelectActiveLibrary();
if( CurrentLib == NULL )
return FALSE;
}
......@@ -109,13 +111,13 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPart()
g_ScreenLib->ClrModify();
CurrentDrawItem = NULL;
// Effacement ancien composant affich�
// Delete previous library component, if any
if( CurrentLibEntry )
{
SAFE_DELETE( CurrentLibEntry );
}
/* Chargement du composant */
/* Load the new library component */
LibEntry = FindLibPart( CmpName.GetData(), CurrentLib->m_Name, FIND_ALIAS );
if( LibEntry == NULL )
......@@ -199,7 +201,8 @@ int WinEDA_LibeditFrame::LoadOneLibraryPartAux(
/*********************************************************************/
void WinEDA_LibeditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/*********************************************************************/
/* Routine generale d'affichage a l'ecran du "PartLib" en cours d'edition */
/* Function to redraw the current loaded library component
*/
{
if( GetScreen() == NULL )
return;
......@@ -208,9 +211,9 @@ void WinEDA_LibeditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DC->SetBackground( *wxBLACK_BRUSH );
DC->SetBackgroundMode( wxTRANSPARENT );
GRResetPenAndBrush( DC ); // reinit de la brosse et plume courante
GRResetPenAndBrush( DC );
DrawPanel->CursorOff( DC ); // effacement curseur
DrawPanel->CursorOff( DC ); // erase cursor
if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); // effacement affichage lie au curseur
......@@ -225,11 +228,11 @@ void WinEDA_LibeditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DrawLibEntry( DrawPanel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentUnit, CurrentConvert, GR_DEFAULT_DRAWMODE );
DrawPanel->CursorOn( DC ); // reaffichage curseur
DrawPanel->CursorOn( DC ); // redraw cursor
if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); // reaffichage lie au curseur
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
}
GetScreen()->ClrRefreshReq();
......@@ -242,8 +245,8 @@ void WinEDA_LibeditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
void WinEDA_LibeditFrame::SaveActiveLibrary()
/*************************************************/
/* Sauvegarde en fichier la librairie pointee par CurrentLib
* une sauvegarde en .bak de l'ancien fichier est egalement cree
/* Save (on disk) the current library
* if exists the old file is renamed (.bak)
*/
{
wxString Name, msg;
......@@ -576,7 +579,8 @@ void WinEDA_LibeditFrame::DeletePartInLib( LibraryStruct* Library,
Library->m_Name,
FIND_ALIAS );
if( AliasEntry == NULL )
{ // Should not occurs. If happens, this is an error (or bug)
{
// Should not occurs. If happens, this is an error (or bug)
wxString msg;
msg.Printf( wxT( "Warning: Alias <%s> not found" ),
AliasName.GetData() );
......@@ -584,7 +588,8 @@ void WinEDA_LibeditFrame::DeletePartInLib( LibraryStruct* Library,
continue;
}
if( AliasEntry->Type != ALIAS )
{ // Should not occurs. If happens, this is an error (or bug)
{
// Should not occurs. If happens, this is an error (or bug)
wxString msg;
msg.Printf( wxT( "Warning: <%s> is not an Alias" ),
AliasName.GetData() );
......
No preview for this file type
This diff is collapsed.
......@@ -22,9 +22,9 @@ DEBUG = 0
#Define the wxWidget path (if not found in environment variables):
ifndef WXWIN
ifeq ($(DEBUG), 1)
WXWIN=f:/wxMSW-2.8.910-rc2/Debug
WXWIN=d:/wxMSW-2.8.10/Debug
else
WXWIN=f:/wxMSW-2.8.10-rc2/Release
WXWIN=d:/wxMSW-2.8.10/Release
endif
endif
LIBVERSION = 2.8
......
......@@ -54,7 +54,7 @@ class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_base
private:
WinEDA_DrawFrame* m_Parent;
wxConfig* m_Config;
wxCheckBox * m_BoxSelectLayer[32];
wxCheckBox* m_BoxSelectLayer[32];
public:
double m_XScaleAdjust, m_YScaleAdjust;
......@@ -68,9 +68,11 @@ private:
void OnPrintSetup( wxCommandEvent& event );
void OnPrintPreview( wxCommandEvent& event );
void OnPrintButtonClick( wxCommandEvent& event );
void OnButtonCancelClick( wxCommandEvent& event ){ Close(); }
void OnButtonCancelClick( wxCommandEvent& event ) { Close(); }
void SetScale( wxCommandEvent& event );
void SetPenWidth();
public:
bool IsMirrored() { return m_Print_Mirror->IsChecked(); }
bool ExcludeEdges() { return m_Exclude_Edges_Pcb->IsChecked(); }
......@@ -152,16 +154,17 @@ DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( WinEDA_DrawFrame* parent
void DIALOG_PRINT_USING_PRINTER::OnInitDialog( wxInitDialogEvent& event )
/************************************************************************/
{
SetFont(*g_DialogFont);
SetFont( *g_DialogFont );
SetFocus();
int layer_max = NB_LAYERS;
wxString msg;
#ifdef GERBVIEW
layer_max = 32;
m_Exclude_Edges_Pcb->SetValue(true); // no meaning in gerbview
m_Exclude_Edges_Pcb->Show(false);
msg = _("Layers:");
m_Exclude_Edges_Pcb->SetValue( true ); // no meaning in gerbview
m_Exclude_Edges_Pcb->Show( false );
msg = _( "Layers:" );
// Set wxRadioBox title to "Layers:" for copper layers and thechincal layers
// Because in Gerbview , al layers are only graphic layers (layer id has no meaning)
m_CopperLayersBoxSizer->GetStaticBox()->SetLabel( msg );
......@@ -170,11 +173,11 @@ void DIALOG_PRINT_USING_PRINTER::OnInitDialog( wxInitDialogEvent& event )
/* Create layer list */
int mask = 1, ii;
for( ii = 0; ii < layer_max ; ii++, mask <<= 1 )
for( ii = 0; ii < layer_max; ii++, mask <<= 1 )
{
#ifdef GERBVIEW
msg = _("Layer");
msg << wxT(" ") << ii+1;
msg = _( "Layer" );
msg << wxT( " " ) << ii + 1;
#else
msg = ( (WinEDA_PcbFrame*) m_Parent )->GetBoard()->GetLayerName( ii );
#endif
......@@ -205,7 +208,8 @@ void DIALOG_PRINT_USING_PRINTER::OnInitDialog( wxInitDialogEvent& event )
m_Config->Read( OPTKEY_PRINT_SCALE, &s_Scale_Select );
// Test for a reasonnable scale value. Set to 1 if problem
if ( m_XScaleAdjust < MIN_SCALE || m_YScaleAdjust < MIN_SCALE || m_XScaleAdjust > MAX_SCALE || m_YScaleAdjust > MAX_SCALE )
if( m_XScaleAdjust < MIN_SCALE || m_YScaleAdjust < MIN_SCALE || m_XScaleAdjust >
MAX_SCALE || m_YScaleAdjust > MAX_SCALE )
m_XScaleAdjust = m_YScaleAdjust = 1.0;
s_SelectedLayers = 0;
......@@ -242,9 +246,9 @@ void DIALOG_PRINT_USING_PRINTER::OnInitDialog( wxInitDialogEvent& event )
msg.Printf( wxT( "%lf" ), m_YScaleAdjust );
m_FineAdjustYscaleOpt->SetValue( msg );
if (GetSizer())
if( GetSizer() )
{
GetSizer()->SetSizeHints(this);
GetSizer()->SetSizeHints( this );
}
}
......@@ -255,7 +259,8 @@ int DIALOG_PRINT_USING_PRINTER::SetLayerMaskFromListSelection()
{
int page_count;
int layers_count = NB_LAYERS;
if (m_Parent->m_Ident == GERBER_FRAME)
if( m_Parent->m_Ident == GERBER_FRAME )
layers_count = 32;
s_PrintMaskLayer = 0;
......@@ -273,7 +278,6 @@ int DIALOG_PRINT_USING_PRINTER::SetLayerMaskFromListSelection()
}
/********************************************************************/
void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
/********************************************************************/
......@@ -300,7 +304,7 @@ void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
m_Config->Write( OPTKEY_PRINT_SCALE, s_Scale_Select );
wxString layerKey;
int layers_count = NB_LAYERS;
if (m_Parent->m_Ident == GERBER_FRAME)
if( m_Parent->m_Ident == GERBER_FRAME )
layers_count = 32;
for( int layer = 0; layer<layers_count; ++layer )
{
......@@ -348,7 +352,7 @@ void DIALOG_PRINT_USING_PRINTER::SetPenWidth()
}
m_DialogPenWidth->SetValue(
ReturnStringFromValue(g_UnitMetric, s_PrintPenMinWidth, m_Parent->m_InternalUnits ) );
ReturnStringFromValue( g_UnitMetric, s_PrintPenMinWidth, m_Parent->m_InternalUnits ) );
}
......@@ -392,7 +396,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
s_Print_Sheet_Ref = m_Print_Sheet_Ref->GetValue();
// Pass two printout objects: for preview, and possible printing.
wxString title = _("Print Preview");
wxString title = _( "Print Preview" );
wxPrintPreview* preview =
new wxPrintPreview( new EDA_Printout( this, m_Parent, title, s_Print_Sheet_Ref ),
new EDA_Printout( this, m_Parent, title, s_Print_Sheet_Ref ),
......@@ -403,9 +407,18 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
DisplayError( this, wxT( "OnPrintPreview() problem" ) );
return;
}
if( s_OptionPrintPage )
SetLayerMaskFromListSelection();
// If no layer selected, we have no plot. prompt user if it happens
// because he could think there is a bug in pcbnew:
if( s_PrintMaskLayer == 0 )
{
DisplayError( this, _( "No layer selected" ) );
return;
}
// Uses the parent position and size.
// @todo uses last position and size ans store them when exit in m_Config
wxPoint WPos = m_Parent->GetPosition();
......@@ -435,16 +448,24 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
s_Print_Sheet_Ref = m_Print_Sheet_Ref->GetValue();
if( s_OptionPrintPage )
SetLayerMaskFromListSelection();
// If no layer selected, we have no plot. prompt user if it happens
// because he could think there is a bug in pcbnew:
if( s_PrintMaskLayer == 0 )
{
DisplayError( this, _( "No layer selected" ) );
return;
}
SetPenWidth();
wxPrintDialogData printDialogData( *g_PrintData );
wxPrinter printer( &printDialogData );
wxString title = _("Print");
wxString title = _( "Print" );
EDA_Printout printout( this, m_Parent, title, s_Print_Sheet_Ref );
#ifndef __WINDOWS__
......@@ -473,15 +494,14 @@ bool EDA_Printout::OnPrintPage( int page )
msg.Printf( _( "Print page %d" ), page );
m_Parent->Affiche_Message( msg );
int layers_count = NB_LAYERS;
if (m_Parent->m_Ident == GERBER_FRAME)
if( m_Parent->m_Ident == GERBER_FRAME )
layers_count = 32;
if( (m_Parent->m_Ident == PCB_FRAME) || (m_Parent->m_Ident == GERBER_FRAME) )
{
m_PrintFrame->SetLayerMaskFromListSelection();
if( s_OptionPrintPage == 0 )
if( s_OptionPrintPage == 0 ) // compute layer mask from page number
{
// compute layer mask from page number
int ii, jj, mask = 1;
for( ii = 0, jj = 0; ii < layers_count; ii++ )
{
......@@ -494,11 +514,11 @@ bool EDA_Printout::OnPrintPage( int page )
}
mask <<= 1;
}
if( ii == layers_count )
return FALSE;
}
}
if( s_PrintMaskLayer == 0 )
return false;
DrawPage();
return TRUE;
......@@ -588,7 +608,7 @@ void EDA_Printout::DrawPage()
// Gerbview uses a very large sheet (called "World" in gerber language)
// to print a sheet, uses A4 is better
SheetSize = ActiveScreen->m_CurrentSheetDesc->m_Size; // size in 1/1000 inch
if (m_Parent->m_Ident == GERBER_FRAME)
if( m_Parent->m_Ident == GERBER_FRAME )
{
SheetSize = g_Sheet_A4.m_Size; // size in 1/1000 inch
}
......@@ -622,11 +642,12 @@ void EDA_Printout::DrawPage()
scaleY = (double) SheetSize.y / PlotAreaSize.y;
scale = wxMax( scaleX, scaleY ) / userscale; // Use x or y scaling factor, whichever fits on the DC
if ( m_PrintFrame->m_XScaleAdjust > MAX_SCALE || m_PrintFrame->m_YScaleAdjust > MAX_SCALE )
DisplayInfo(NULL, _("Warning: Scale option set to a very large value") );
if( m_PrintFrame->m_XScaleAdjust > MAX_SCALE || m_PrintFrame->m_YScaleAdjust > MAX_SCALE )
DisplayInfo( NULL, _( "Warning: Scale option set to a very large value" ) );
// Test for a reasonnable scale value
if ( m_PrintFrame->m_XScaleAdjust < MIN_SCALE || m_PrintFrame->m_YScaleAdjust < MIN_SCALE )
DisplayInfo(NULL, _("Warning: Scale option set to a very small value") );
if( m_PrintFrame->m_XScaleAdjust < MIN_SCALE || m_PrintFrame->m_YScaleAdjust < MIN_SCALE )
DisplayInfo( NULL, _( "Warning: Scale option set to a very small value" ) );
// ajust the real draw scale
double accurate_Xscale, accurate_Yscale;
......@@ -680,7 +701,7 @@ void EDA_Printout::DrawPage()
// background color can left BLACK only when drawing the full board at once, in color mode
// Switch it to WHITE in others cases
if ( s_Print_Black_and_White || ( ! m_PrintFrame->PrintUsingSinglePage() ) )
if( s_Print_Black_and_White || ( !m_PrintFrame->PrintUsingSinglePage() ) )
g_DrawBgColor = WHITE;
if( m_Print_Sheet_Ref )
......@@ -692,7 +713,8 @@ void EDA_Printout::DrawPage()
}
if( s_PrintMirror )
{ // To plot mirror, we reverse the y axis, and modify the plot y origin
{
// To plot mirror, we reverse the y axis, and modify the plot y origin
double sx, sy;
dc->GetUserScale( &sx, &sy );
......
......@@ -732,6 +732,11 @@ void WinEDA_PlotFrame::Plot( wxCommandEvent& event )
}
}
// If no layer selected, we have no plot. prompt user if it happens
// because he could think there is a bug in pcbnew:
if ( s_SelectedLayers == 0 )
DisplayError( this, _("No layer selected") );
// Close(true);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment