hpgl_plotter: correct formatting

This commit is contained in:
Alexis Lockwood 2020-12-22 09:59:57 -07:00 committed by Alexis V L
parent f5b7595675
commit 6f228f9dea
3 changed files with 25 additions and 48 deletions

View File

@ -288,18 +288,20 @@ bool HPGL_PLOTTER::EndPlot()
if( fitUserCoords ) if( fitUserCoords )
{ {
BOX2D bbox = m_items.front().bbox; BOX2D bbox = m_items.front().bbox;
for( HPGL_ITEM const& item: m_items ) for( HPGL_ITEM const& item : m_items )
{ {
bbox.Merge( item.bbox ); bbox.Merge( item.bbox );
} }
fprintf( m_outputFile, "SC%.0f,%.0f,%.0f,%.0f;\n", bbox.GetX(), bbox.GetX() + bbox.GetWidth(), fprintf( m_outputFile, "SC%.0f,%.0f,%.0f,%.0f;\n", bbox.GetX(),
bbox.GetY(), bbox.GetY() + bbox.GetHeight() ); bbox.GetX() + bbox.GetWidth(), bbox.GetY(),
bbox.GetY() + bbox.GetHeight() );
} }
else else
{ {
DPOINT pagesize_dev( m_paperSize * m_iuPerDeviceUnit ); DPOINT pagesize_dev( m_paperSize * m_iuPerDeviceUnit );
fprintf( m_outputFile, "SC%.0f,%.0f,%.0f,%.0f;\n", 0., pagesize_dev.x, 0., pagesize_dev.y ); fprintf( m_outputFile, "SC%.0f,%.0f,%.0f,%.0f;\n", 0., pagesize_dev.x, 0.,
pagesize_dev.y );
} }
} }
@ -435,8 +437,7 @@ void HPGL_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_TYPE fill,
m_current_item->lift_before = true; m_current_item->lift_before = true;
m_current_item->pen_returns = true; m_current_item->pen_returns = true;
m_current_item->bbox.Merge( m_current_item->bbox.Merge(
BOX2D( center_dev - radius, VECTOR2D( 2 * radius, 2 * radius ) ) BOX2D( center_dev - radius, VECTOR2D( 2 * radius, 2 * radius ) ) );
);
PenFinish(); PenFinish();
} }
@ -447,8 +448,7 @@ void HPGL_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_TYPE fill,
m_current_item->lift_before = true; m_current_item->lift_before = true;
m_current_item->pen_returns = true; m_current_item->pen_returns = true;
m_current_item->bbox.Merge( m_current_item->bbox.Merge(
BOX2D( center_dev - radius, VECTOR2D( 2 * radius, 2 * radius ) ) BOX2D( center_dev - radius, VECTOR2D( 2 * radius, 2 * radius ) ) );
);
PenFinish(); PenFinish();
} }
} }
@ -630,9 +630,8 @@ void HPGL_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle,
centre_dev.y, angle, chord_degrees ) ); centre_dev.y, angle, chord_degrees ) );
// TODO We could compute the final position and full bounding box instead... // TODO We could compute the final position and full bounding box instead...
m_current_item->bbox.Merge( BOX2D( m_current_item->bbox.Merge(
centre_dev - radius_dev, VECTOR2D( radius_dev * 2, radius_dev * 2 ) BOX2D( centre_dev - radius_dev, VECTOR2D( radius_dev * 2, radius_dev * 2 ) ) );
) );
m_current_item->lift_after = true; m_current_item->lift_after = true;
flushItem(); flushItem();
} }

View File

@ -55,16 +55,10 @@ public:
void SetTargetChordLength( double chord_len ); void SetTargetChordLength( double chord_len );
/// Switch to the user coordinate system /// Switch to the user coordinate system
void SetUserCoords( bool user_coords ) void SetUserCoords( bool user_coords ) { useUserCoords = user_coords; }
{
useUserCoords = user_coords;
}
/// Set whether the user coordinate system is fit to content /// Set whether the user coordinate system is fit to content
void SetUserCoordsFit( bool user_coords_fit ) void SetUserCoordsFit( bool user_coords_fit ) { fitUserCoords = user_coords_fit; }
{
fitUserCoords = user_coords_fit;
}
virtual bool StartPlot() override; virtual bool StartPlot() override;
virtual bool EndPlot() override; virtual bool EndPlot() override;
@ -156,12 +150,7 @@ protected:
struct HPGL_ITEM struct HPGL_ITEM
{ {
HPGL_ITEM() HPGL_ITEM() : lift_before( false ), lift_after( false ), pen_returns( false ), pen( 0 ) {}
: lift_before( false ),
lift_after( false ),
pen_returns( false ),
pen( 0 )
{}
/// Location the pen should start at /// Location the pen should start at
DPOINT loc_start; DPOINT loc_start;

View File

@ -40,7 +40,8 @@ enum PageFormatReq {
PAGE_SIZE_A PAGE_SIZE_A
}; };
enum class HPGL_PLOT_ORIGIN_AND_UNITS { enum class HPGL_PLOT_ORIGIN_AND_UNITS
{
PLOTTER_BOT_LEFT, PLOTTER_BOT_LEFT,
PLOTTER_CENTER, PLOTTER_CENTER,
USER_FIT_PAGE, USER_FIT_PAGE,
@ -119,39 +120,27 @@ private:
wxPoint aPlot0ffset, double aScale, bool aPlotFrameRef ); wxPoint aPlot0ffset, double aScale, bool aPlotFrameRef );
// HPGL // HPGL
HPGL_PLOT_ORIGIN_AND_UNITS GetPlotOriginAndUnits() HPGL_PLOT_ORIGIN_AND_UNITS GetPlotOriginAndUnits()
{ {
switch( m_plotOriginOpt->GetSelection() ) switch( m_plotOriginOpt->GetSelection() )
{ {
case 0: case 0:
default: default: return HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT;
return HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT; case 1: return HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER;
case 1: case 2: return HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE;
return HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER; case 3: return HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT;
case 2:
return HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE;
case 3:
return HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT;
} }
} }
void SetPlotOriginAndUnits( HPGL_PLOT_ORIGIN_AND_UNITS aOriginAndUnits ) void SetPlotOriginAndUnits( HPGL_PLOT_ORIGIN_AND_UNITS aOriginAndUnits )
{ {
switch( aOriginAndUnits ) switch( aOriginAndUnits )
{ {
case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT: case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT:
default: default: m_plotOriginOpt->SetSelection( 0 ); break;
m_plotOriginOpt->SetSelection( 0 ); case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER: m_plotOriginOpt->SetSelection( 1 ); break;
break; case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE: m_plotOriginOpt->SetSelection( 2 ); break;
case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER: case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT: m_plotOriginOpt->SetSelection( 3 ); break;
m_plotOriginOpt->SetSelection( 1 );
break;
case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE:
m_plotOriginOpt->SetSelection( 2 );
break;
case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT:
m_plotOriginOpt->SetSelection( 3 );
break;
} }
} }