Plot PS function now properly plots all sheets in a complex hierarchy.
This commit is contained in:
parent
00dadcbbdd
commit
1fd73dff3d
|
@ -57,9 +57,9 @@ void Setg_Plot_PlotOffset( wxPoint offset )
|
|||
}
|
||||
|
||||
|
||||
/*******************************************************/
|
||||
void PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
|
||||
/*******************************************************/
|
||||
/**************************************************************************/
|
||||
void WinEDA_DrawFrame::PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
|
||||
/**************************************************************************/
|
||||
|
||||
/* Plot sheet references
|
||||
* margin is in mils (1/1000 inch)
|
||||
|
@ -400,8 +400,7 @@ void PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
|
|||
break;
|
||||
|
||||
case WS_FULLSHEETNAME:
|
||||
|
||||
// msg += GetScreenDesc();
|
||||
msg += GetScreenDesc();
|
||||
break;
|
||||
|
||||
case WS_COMPANY_NAME:
|
||||
|
|
|
@ -608,7 +608,7 @@ void WinEDA_PlotHPGLFrame::Plot_1_Page_HPGL( const wxString& FullFileName,
|
|||
/* Init : */
|
||||
PrintHeaderHPGL( PlotOutput, g_HPGL_Pen_Descr.m_Pen_Speed, g_HPGL_Pen_Descr.m_Pen_Num );
|
||||
|
||||
PlotWorkSheet( PLOT_FORMAT_HPGL, screen );
|
||||
m_Parent->PlotWorkSheet( PLOT_FORMAT_HPGL, screen );
|
||||
|
||||
DrawList = screen->EEDrawList;
|
||||
while( DrawList ) /* tracage */
|
||||
|
|
|
@ -120,13 +120,14 @@ WinEDA_PlotPSFrame::WinEDA_PlotPSFrame()
|
|||
}
|
||||
|
||||
|
||||
WinEDA_PlotPSFrame::WinEDA_PlotPSFrame( wxWindow* parent,
|
||||
WinEDA_PlotPSFrame::WinEDA_PlotPSFrame( WinEDA_DrawFrame* parent,
|
||||
wxWindowID id,
|
||||
const wxString& caption,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style )
|
||||
{
|
||||
m_Parent = parent;
|
||||
Create( parent, id, caption, pos, size, style );
|
||||
}
|
||||
|
||||
|
@ -149,6 +150,7 @@ bool WinEDA_PlotPSFrame::Create( wxWindow* parent,
|
|||
m_btClose = NULL;
|
||||
m_DefaultLineSizeCtrlSizer = NULL;
|
||||
m_MsgBox = NULL;
|
||||
|
||||
////@end WinEDA_PlotPSFrame member initialisation
|
||||
|
||||
////@begin WinEDA_PlotPSFrame creation
|
||||
|
@ -161,6 +163,7 @@ bool WinEDA_PlotPSFrame::Create( wxWindow* parent,
|
|||
GetSizer()->SetSizeHints( this );
|
||||
}
|
||||
Centre();
|
||||
|
||||
////@end WinEDA_PlotPSFrame creation
|
||||
return true;
|
||||
}
|
||||
|
@ -189,24 +192,34 @@ void WinEDA_PlotPSFrame::CreateControls()
|
|||
m_SizeOptionStrings.Add( _( "Auto" ) );
|
||||
m_SizeOptionStrings.Add( _( "Page Size A4" ) );
|
||||
m_SizeOptionStrings.Add( _( "Page Size A" ) );
|
||||
m_SizeOption = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Plot page size:"), wxDefaultPosition, wxDefaultSize, m_SizeOptionStrings, 1, wxRA_SPECIFY_COLS );
|
||||
m_SizeOption = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _(
|
||||
"Plot page size:" ), wxDefaultPosition, wxDefaultSize,
|
||||
m_SizeOptionStrings, 1,
|
||||
wxRA_SPECIFY_COLS );
|
||||
m_SizeOption->SetSelection( 0 );
|
||||
itemBoxSizer3->Add( m_SizeOption, 0, wxGROW | wxALL, 5 );
|
||||
|
||||
itemBoxSizer3->Add( 5, 5, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
||||
|
||||
wxStaticBox* itemStaticBoxSizer6Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Plot Options:"));
|
||||
wxStaticBoxSizer* itemStaticBoxSizer6 = new wxStaticBoxSizer(itemStaticBoxSizer6Static, wxVERTICAL);
|
||||
wxStaticBox* itemStaticBoxSizer6Static = new wxStaticBox( itemDialog1, wxID_ANY,
|
||||
_( "Plot Options:" ) );
|
||||
wxStaticBoxSizer* itemStaticBoxSizer6 = new wxStaticBoxSizer( itemStaticBoxSizer6Static,
|
||||
wxVERTICAL );
|
||||
itemBoxSizer3->Add( itemStaticBoxSizer6, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
||||
|
||||
wxArrayString m_PlotPSColorOptionStrings;
|
||||
m_PlotPSColorOptionStrings.Add( _( "B/W" ) );
|
||||
m_PlotPSColorOptionStrings.Add( _( "Color" ) );
|
||||
m_PlotPSColorOption = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Plot Color:"), wxDefaultPosition, wxDefaultSize, m_PlotPSColorOptionStrings, 1, wxRA_SPECIFY_COLS );
|
||||
m_PlotPSColorOption = new wxRadioBox( itemDialog1, ID_RADIOBOX, _(
|
||||
"Plot Color:" ), wxDefaultPosition, wxDefaultSize,
|
||||
m_PlotPSColorOptionStrings, 1,
|
||||
wxRA_SPECIFY_COLS );
|
||||
m_PlotPSColorOption->SetSelection( 0 );
|
||||
itemStaticBoxSizer6->Add( m_PlotPSColorOption, 0, wxGROW | wxALL, 5 );
|
||||
|
||||
m_Plot_Sheet_Ref = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Print Sheet Ref"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
||||
m_Plot_Sheet_Ref = new wxCheckBox( itemDialog1, ID_CHECKBOX, _(
|
||||
"Print Sheet Ref" ), wxDefaultPosition, wxDefaultSize,
|
||||
wxCHK_2STATE );
|
||||
m_Plot_Sheet_Ref->SetValue( false );
|
||||
itemStaticBoxSizer6->Add( m_Plot_Sheet_Ref, 0, wxGROW | wxALL, 5 );
|
||||
|
||||
|
@ -215,32 +228,44 @@ void WinEDA_PlotPSFrame::CreateControls()
|
|||
wxBoxSizer* itemBoxSizer10 = new wxBoxSizer( wxVERTICAL );
|
||||
itemBoxSizer3->Add( itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
||||
|
||||
wxButton* itemButton11 = new wxButton( itemDialog1, ID_PLOT_PS_CURRENT_EXECUTE, _("&Plot page"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
wxButton* itemButton11 = new wxButton( itemDialog1, ID_PLOT_PS_CURRENT_EXECUTE,
|
||||
_(
|
||||
"&Plot page" ), wxDefaultPosition, wxDefaultSize,
|
||||
0 );
|
||||
itemButton11->SetDefault();
|
||||
itemButton11->SetForegroundColour( wxColour( 0, 128, 0 ) );
|
||||
itemBoxSizer10->Add( itemButton11, 0, wxGROW | wxALL, 5 );
|
||||
|
||||
wxButton* itemButton12 = new wxButton( itemDialog1, ID_PLOT_PS_ALL_EXECUTE, _("Plot a&ll"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
wxButton* itemButton12 = new wxButton( itemDialog1, ID_PLOT_PS_ALL_EXECUTE, _(
|
||||
"Plot a&ll" ), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
itemButton12->SetForegroundColour( wxColour( 179, 0, 0 ) );
|
||||
itemBoxSizer10->Add( itemButton12, 0, wxGROW | wxALL, 5 );
|
||||
|
||||
m_btClose = new wxButton( itemDialog1, wxID_CANCEL, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_btClose = new wxButton( itemDialog1, wxID_CANCEL, _(
|
||||
"&Close" ), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_btClose->SetForegroundColour( wxColour( 0, 0, 255 ) );
|
||||
itemBoxSizer10->Add( m_btClose, 0, wxGROW | wxALL, 5 );
|
||||
|
||||
m_DefaultLineSizeCtrlSizer = new wxBoxSizer( wxVERTICAL );
|
||||
itemBoxSizer2->Add( m_DefaultLineSizeCtrlSizer, 0, wxGROW | wxALL, 5 );
|
||||
|
||||
wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, wxID_STATIC, _("Messages :"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
itemBoxSizer2->Add(itemStaticText15, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
|
||||
wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, wxID_STATIC, _(
|
||||
"Messages :" ), wxDefaultPosition,
|
||||
wxDefaultSize, 0 );
|
||||
itemBoxSizer2->Add( itemStaticText15,
|
||||
0,
|
||||
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
|
||||
5 );
|
||||
|
||||
m_MsgBox = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(-1, 200), wxTE_MULTILINE );
|
||||
m_MsgBox = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( "" ), wxDefaultPosition,
|
||||
wxSize( -1, 200 ), wxTE_MULTILINE );
|
||||
itemBoxSizer2->Add( m_MsgBox, 0, wxGROW | wxALL | wxFIXED_MINSIZE, 5 );
|
||||
|
||||
// Set validators
|
||||
m_SizeOption->SetValidator( wxGenericValidator( &PS_SizeSelect ) );
|
||||
m_PlotPSColorOption->SetValidator( wxGenericValidator( &g_PlotPSColorOpt ) );
|
||||
m_Plot_Sheet_Ref->SetValidator( wxGenericValidator( &Plot_Sheet_Ref ) );
|
||||
|
||||
////@end WinEDA_PlotPSFrame content construction
|
||||
|
||||
SetFocus(); // make the ESC work
|
||||
|
@ -272,6 +297,7 @@ wxBitmap WinEDA_PlotPSFrame::GetBitmapResource( const wxString& name )
|
|||
////@begin WinEDA_PlotPSFrame bitmap retrieval
|
||||
wxUnusedVar( name );
|
||||
return wxNullBitmap;
|
||||
|
||||
////@end WinEDA_PlotPSFrame bitmap retrieval
|
||||
}
|
||||
|
||||
|
@ -286,6 +312,7 @@ wxIcon WinEDA_PlotPSFrame::GetIconResource( const wxString& name )
|
|||
////@begin WinEDA_PlotPSFrame icon retrieval
|
||||
wxUnusedVar( name );
|
||||
return wxNullIcon;
|
||||
|
||||
////@end WinEDA_PlotPSFrame icon retrieval
|
||||
}
|
||||
|
||||
|
@ -346,24 +373,46 @@ void WinEDA_PlotPSFrame::InitOptVars()
|
|||
void WinEDA_PlotPSFrame::CreatePSFile( int AllPages, int pagesize )
|
||||
/*************************************************************/
|
||||
{
|
||||
WinEDA_SchematicFrame* schframe = (WinEDA_SchematicFrame*) m_Parent;
|
||||
SCH_SCREEN* screen = schframe->GetScreen();
|
||||
SCH_SCREEN* oldscreen = screen;
|
||||
DrawSheetPath* oldsheetpath = schframe->GetSheet();
|
||||
wxString PlotFileName, ShortFileName;
|
||||
BASE_SCREEN* screen;
|
||||
Ki_PageDescr* PlotSheet, * RealSheet;
|
||||
int BBox[4];
|
||||
wxPoint plot_offset;
|
||||
DrawSheetPath* sheetpath;
|
||||
|
||||
g_PlotFormat = PLOT_FORMAT_POST;
|
||||
|
||||
/* Build the screen list */
|
||||
EDA_ScreenList ScreenList;
|
||||
/* When printing all pages, the printed page is not the current page.
|
||||
* In complex hierarchies, we must setup references and others parameters in the printed SCH_SCREEN
|
||||
* because in complex hierarchies a SCH_SCREEN (a schematic drawings)
|
||||
* is shared between many sheets
|
||||
*/
|
||||
EDA_SheetList SheetList( NULL );
|
||||
sheetpath = SheetList.GetFirst();
|
||||
DrawSheetPath list;
|
||||
|
||||
if( AllPages == TRUE )
|
||||
screen = ScreenList.GetFirst();
|
||||
else
|
||||
screen = ActiveScreen;
|
||||
|
||||
for( ; screen != NULL; screen = ScreenList.GetNext() )
|
||||
for( ; ; )
|
||||
{
|
||||
if( AllPages )
|
||||
{
|
||||
if( sheetpath == NULL )
|
||||
break;
|
||||
list.Clear();
|
||||
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
|
||||
{
|
||||
schframe->m_CurrentSheet = &list;
|
||||
schframe->m_CurrentSheet->UpdateAllScreenReferences();
|
||||
schframe->SetSheetNumberAndCount();
|
||||
screen = schframe->m_CurrentSheet->LastScreen();
|
||||
ActiveScreen = screen;
|
||||
}
|
||||
else // Should not happen
|
||||
return;
|
||||
sheetpath = SheetList.GetNext();
|
||||
}
|
||||
PlotSheet = screen->m_CurrentSheetDesc;
|
||||
RealSheet = &g_Sheet_A4;
|
||||
|
||||
|
@ -372,25 +421,37 @@ void WinEDA_PlotPSFrame::CreatePSFile( int AllPages, int pagesize )
|
|||
else if( pagesize == PAGE_SIZE_A )
|
||||
RealSheet = &g_Sheet_A;
|
||||
|
||||
/* Calcul des limites de trace en 1/1000 pouce */
|
||||
/* Calculate plot bouding box in 1/1000 inch */
|
||||
BBox[0] = BBox[1] = g_PlotMargin; // Plot margin in 1/1000 inch
|
||||
BBox[2] = RealSheet->m_Size.x - g_PlotMargin;
|
||||
BBox[3] = RealSheet->m_Size.y - g_PlotMargin;
|
||||
|
||||
/* Calcul des echelles de conversion */
|
||||
g_PlotScaleX = SCALE_PS *
|
||||
(float) (BBox[2] - BBox[0]) /
|
||||
PlotSheet->m_Size.x;
|
||||
|
||||
g_PlotScaleY = SCALE_PS *
|
||||
(float) (BBox[3] - BBox[1]) /
|
||||
PlotSheet->m_Size.y;
|
||||
/* Calculate pcbnew to PS conversion scale */
|
||||
g_PlotScaleX = SCALE_PS * (float) (BBox[2] - BBox[0]) / PlotSheet->m_Size.x;
|
||||
g_PlotScaleY = SCALE_PS * (float) (BBox[3] - BBox[1]) / PlotSheet->m_Size.y;
|
||||
|
||||
plot_offset.x = 0;
|
||||
plot_offset.y = PlotSheet->m_Size.y;
|
||||
|
||||
wxSplitPath( screen->m_FileName.GetData(), (wxString*) NULL,
|
||||
/* If a screen is used more than once (complex hierarchy) we create more than once file
|
||||
* with the same basic filename
|
||||
* To avoid that, we use the root filename and and the sheet path
|
||||
* Or, if filename too long, sheet_name + sheet number
|
||||
*/
|
||||
wxSplitPath( g_RootSheet->GetFileName().GetData(), (wxString*) NULL,
|
||||
&ShortFileName, (wxString*) NULL );
|
||||
if ( (ShortFileName.Len() + schframe->m_CurrentSheet->PathHumanReadable().Len() ) < 50 )
|
||||
{
|
||||
ShortFileName += schframe->m_CurrentSheet->PathHumanReadable();
|
||||
ShortFileName.Replace( wxT( "/" ), wxT( "-" ) );
|
||||
ShortFileName.RemoveLast();
|
||||
}
|
||||
else
|
||||
{
|
||||
wxSplitPath( g_RootSheet->GetFileName().GetData(), (wxString*) NULL,
|
||||
&ShortFileName, (wxString*) NULL );
|
||||
ShortFileName << wxT("-") << screen->m_ScreenNumber;
|
||||
}
|
||||
|
||||
wxString dirbuf = wxGetCwd() + STRING_DIR_SEP;
|
||||
|
||||
|
@ -401,17 +462,20 @@ void WinEDA_PlotPSFrame::CreatePSFile( int AllPages, int pagesize )
|
|||
|
||||
PlotOneSheetPS( PlotFileName, screen, RealSheet, BBox, plot_offset );
|
||||
|
||||
screen = screen->Next();
|
||||
|
||||
if( AllPages == FALSE )
|
||||
if( !AllPages )
|
||||
break;
|
||||
}
|
||||
|
||||
ActiveScreen = oldscreen;
|
||||
schframe->m_CurrentSheet = oldsheetpath;
|
||||
schframe->m_CurrentSheet->UpdateAllScreenReferences();
|
||||
schframe->SetSheetNumberAndCount();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************/
|
||||
void WinEDA_PlotPSFrame::PlotOneSheetPS( const wxString& FileName,
|
||||
BASE_SCREEN* screen,
|
||||
SCH_SCREEN* screen,
|
||||
Ki_PageDescr* sheet,
|
||||
int BBox[4],
|
||||
wxPoint plot_offset )
|
||||
|
@ -451,7 +515,7 @@ void WinEDA_PlotPSFrame::PlotOneSheetPS( const wxString& FileName,
|
|||
{
|
||||
if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
|
||||
SetColorMapPS( BLACK );
|
||||
PlotWorkSheet( PLOT_FORMAT_POST, screen );
|
||||
m_Parent->PlotWorkSheet( PLOT_FORMAT_POST, screen );
|
||||
}
|
||||
|
||||
DrawList = screen->EEDrawList;
|
||||
|
@ -569,5 +633,3 @@ void WinEDA_PlotPSFrame::PlotOneSheetPS( const wxString& FileName,
|
|||
|
||||
m_MsgBox->AppendText( wxT( "Ok\n" ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ class WinEDA_PlotPSFrame: public wxDialog
|
|||
public:
|
||||
/// Constructors
|
||||
WinEDA_PlotPSFrame( );
|
||||
WinEDA_PlotPSFrame( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PLOTPSFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PLOTPSFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PLOTPSFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PLOTPSFRAME_SIZE, long style = SYMBOL_WINEDA_PLOTPSFRAME_STYLE );
|
||||
WinEDA_PlotPSFrame( WinEDA_DrawFrame* parent, wxWindowID id = SYMBOL_WINEDA_PLOTPSFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PLOTPSFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PLOTPSFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PLOTPSFRAME_SIZE, long style = SYMBOL_WINEDA_PLOTPSFRAME_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PLOTPSFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PLOTPSFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PLOTPSFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PLOTPSFRAME_SIZE, long style = SYMBOL_WINEDA_PLOTPSFRAME_STYLE );
|
||||
|
@ -106,7 +106,7 @@ public:
|
|||
void InitOptVars();
|
||||
void CreatePSFile(int AllPages, int pagesize);
|
||||
void PlotOneSheetPS(const wxString & FileName,
|
||||
BASE_SCREEN * screen, Ki_PageDescr * sheet, int BBox[4], wxPoint plot_offset);
|
||||
SCH_SCREEN * screen, Ki_PageDescr * sheet, int BBox[4], wxPoint plot_offset);
|
||||
|
||||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
@ -119,6 +119,7 @@ public:
|
|||
wxBoxSizer* m_DefaultLineSizeCtrlSizer;
|
||||
wxTextCtrl* m_MsgBox;
|
||||
////@end WinEDA_PlotPSFrame member variables
|
||||
WinEDA_DrawFrame * m_Parent;
|
||||
WinEDA_ValueCtrl * m_DefaultLineSizeCtrl;
|
||||
};
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ extern int g_Plot_PlotOrientOptions, g_Plot_PenState;
|
|||
void SetPlotScale( double aXScale, double aYScale ); // Set the plot scale for the current plotting)
|
||||
void Setg_Plot_PlotOffset( wxPoint offset ); // Set the plot offset for the current plotting)
|
||||
void InitPlotParametresGERBER( wxPoint offset, double aXScale, double aYScale );
|
||||
void PlotWorkSheet( int format_plot, BASE_SCREEN* screen );
|
||||
// void PlotWorkSheet( int format_plot, BASE_SCREEN* screen ); now a member of WinEDA_DrawFrame
|
||||
void UserToDeviceCoordinate( wxPoint& pos );
|
||||
|
||||
// modifie les coord pos.x et pos.y pour le trace selon l'orientation, l'echelle, les offsets de trace
|
||||
|
|
|
@ -279,6 +279,8 @@ public:
|
|||
void OnActivate( wxActivateEvent& event );
|
||||
void ReDrawPanel();
|
||||
void TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_width );
|
||||
void PlotWorkSheet( int format_plot, BASE_SCREEN* screen );
|
||||
|
||||
/** Function GetXYSheetReferences
|
||||
* Return the X,Y sheet references where the point position is located
|
||||
* @param aScreen = screen to use
|
||||
|
|
Loading…
Reference in New Issue