Simulator, plot panel: fix incorrect calculation of the vertical size of the traces when resizing the simulator frame

This commit is contained in:
jean-pierre charras 2016-11-28 15:37:00 +01:00
parent c225af747f
commit 5d7d210f28
1 changed files with 27 additions and 30 deletions

View File

@ -72,9 +72,9 @@ mpLayer::mpLayer() : m_type( mpLAYER_UNDEF )
{ {
SetPen( (wxPen&) *wxBLACK_PEN ); SetPen( (wxPen&) *wxBLACK_PEN );
SetFont( (wxFont&) *wxNORMAL_FONT ); SetFont( (wxFont&) *wxNORMAL_FONT );
m_continuous = FALSE; // Default m_continuous = false; // Default
m_showName = TRUE; // Default m_showName = true; // Default
m_drawOutsideMargins = FALSE; m_drawOutsideMargins = false;
m_visible = true; m_visible = true;
} }
@ -692,7 +692,7 @@ void mpFXY::Plot( wxDC& dc, mpWindow& w )
int n = 0; int n = 0;
// Old code // Old code
wxCoord x0 = 0, c0 = 0; wxCoord x0 = 0, c0 = 0;
bool first = TRUE; bool first = true;
while( GetNextXY( x, y ) ) while( GetNextXY( x, y ) )
{ {
@ -714,7 +714,7 @@ void mpFXY::Plot( wxDC& dc, mpWindow& w )
if( first ) if( first )
{ {
first = FALSE; first = false;
x0 = x1; c0 = c1; x0 = x1; c0 = c1;
} }
@ -1737,15 +1737,15 @@ mpWindow::mpWindow( wxWindow* parent,
m_maxX = m_maxY = 0; m_maxX = m_maxY = 0;
m_last_lx = m_last_ly = 0; m_last_lx = m_last_ly = 0;
m_buff_bmp = NULL; m_buff_bmp = NULL;
m_enableDoubleBuffer = FALSE; m_enableDoubleBuffer = false;
m_enableMouseNavigation = TRUE; m_enableMouseNavigation = true;
m_enableLimitedView = FALSE; m_enableLimitedView = false;
m_movingInfoLayer = NULL; m_movingInfoLayer = NULL;
// Set margins to 0 // Set margins to 0
m_marginTop = 0; m_marginRight = 0; m_marginBottom = 0; m_marginLeft = 0; m_marginTop = 0; m_marginRight = 0; m_marginBottom = 0; m_marginLeft = 0;
m_lockaspect = FALSE; m_lockaspect = false;
m_popmenu.Append( mpID_CENTER, _( "Center" ), _( "Center plot view to this position" ) ); m_popmenu.Append( mpID_CENTER, _( "Center" ), _( "Center plot view to this position" ) );
m_popmenu.Append( mpID_FIT, _( "Fit on Screen" ), _( "Set plot view to show all items" ) ); m_popmenu.Append( mpID_FIT, _( "Fit on Screen" ), _( "Set plot view to show all items" ) );
@ -1996,13 +1996,14 @@ void mpWindow::Fit()
// JL // JL
void mpWindow::Fit( double xMin, void mpWindow::Fit( double xMin, double xMax, double yMin, double yMax,
double xMax, wxCoord* printSizeX, wxCoord* printSizeY )
double yMin,
double yMax,
wxCoord* printSizeX,
wxCoord* printSizeY )
{ {
// Save desired borders:
m_desiredXmin = xMin; m_desiredXmax = xMax;
m_desiredYmin = yMin; m_desiredYmax = yMax;
// Give a small margin to plot area
double xExtra = fabs( xMax - xMin ) * 0.00; double xExtra = fabs( xMax - xMin ) * 0.00;
double yExtra = fabs( yMax - yMin ) * 0.03; double yExtra = fabs( yMax - yMin ) * 0.03;
@ -2011,10 +2012,6 @@ void mpWindow::Fit( double xMin,
yMin -= yExtra; yMin -= yExtra;
yMax += yExtra; yMax += yExtra;
// Save desired borders:
m_desiredXmin = xMin; m_desiredXmax = xMax;
m_desiredYmin = yMin; m_desiredYmax = yMax;
if( printSizeX!=NULL && printSizeY!=NULL ) if( printSizeX!=NULL && printSizeY!=NULL )
{ {
// Printer: // Printer:
@ -2693,7 +2690,7 @@ void mpWindow::SetMPScrollbars( bool status )
bool mpWindow::UpdateBBox() bool mpWindow::UpdateBBox()
{ {
bool first = TRUE; bool first = true;
m_minX = 0.0; m_minX = 0.0;
@ -2713,7 +2710,7 @@ bool mpWindow::UpdateBBox()
{ {
if( first ) if( first )
{ {
first = FALSE; first = false;
m_minX = f->GetMinX(); m_maxX = f->GetMaxX(); m_minX = f->GetMinX(); m_maxX = f->GetMaxX();
m_minY = f->GetMinY(); m_maxY = f->GetMaxY(); m_minY = f->GetMinY(); m_maxY = f->GetMaxY();
} }
@ -2743,7 +2740,7 @@ bool mpWindow::UpdateBBox()
"[mpWindow::UpdateBBox] Bounding box: Xmin = %f, Xmax = %f, Ymin = %f, YMax = %f" ), m_minX, m_maxX, m_minY, "[mpWindow::UpdateBBox] Bounding box: Xmin = %f, Xmax = %f, Ymin = %f, YMax = %f" ), m_minX, m_maxX, m_minY,
m_maxY ); m_maxY );
#endif // MATHPLOT_DO_LOGGING #endif // MATHPLOT_DO_LOGGING
return first == FALSE; return first == false;
} }
@ -2765,12 +2762,12 @@ bool mpWindow::UpdateBBox()
// px = (int)((m_posX - m_minX)*m_scaleX); // px = (int)((m_posX - m_minX)*m_scaleX);
// py = (int)((m_maxY - m_posY)*m_scaleY); // py = (int)((m_maxY - m_posY)*m_scaleY);
// SetScrollbars( 1, 1, sx - m_scrX, sy - m_scrY, px, py, TRUE); // SetScrollbars( 1, 1, sx - m_scrX, sy - m_scrY, px, py, true);
// } // }
// Working code // Working code
// UpdateBBox(); // UpdateBBox();
// Refresh( FALSE ); // Refresh( false );
// end working code // end working code
// Old version // Old version
@ -2789,7 +2786,7 @@ bool mpWindow::UpdateBBox()
* // J.L.Blanco, Aug 2007: Formula fixed: * // J.L.Blanco, Aug 2007: Formula fixed:
* const int py = (int)((m_maxY - GetPosY()) * GetScaleY() - (cy>>1)); * const int py = (int)((m_maxY - GetPosY()) * GetScaleY() - (cy>>1));
* *
* SetScrollbars( 1, 1, sx, sy, px, py, TRUE); * SetScrollbars( 1, 1, sx, sy, px, py, true);
* *
* #ifdef MATHPLOT_DO_LOGGING * #ifdef MATHPLOT_DO_LOGGING
* wxLogMessage( "[mpWindow::UpdateAll] Size:%ix%i ScrollBars:%i,%i",sx,sy,px,py); * wxLogMessage( "[mpWindow::UpdateAll] Size:%ix%i ScrollBars:%i,%i",sx,sy,px,py);
@ -2797,7 +2794,7 @@ bool mpWindow::UpdateBBox()
* } * }
* *
* FitInside(); * FitInside();
* Refresh( FALSE ); * Refresh( false );
*/ */
// } // }
@ -2844,7 +2841,7 @@ void mpWindow::UpdateAll()
} }
} }
Refresh( FALSE ); Refresh( false );
} }
@ -3331,7 +3328,7 @@ void mpFXYVector::Rewind()
bool mpFXYVector::GetNextXY( double& x, double& y ) bool mpFXYVector::GetNextXY( double& x, double& y )
{ {
if( m_index>=m_xs.size() ) if( m_index>=m_xs.size() )
return FALSE; return false;
else else
{ {
x = m_xs[m_index]; x = m_xs[m_index];
@ -3643,7 +3640,7 @@ void mpMovableObject::Plot( wxDC& dc, mpWindow& w )
else else
{ {
wxCoord cx0 = 0, cy0 = 0; wxCoord cx0 = 0, cy0 = 0;
bool first = TRUE; bool first = true;
while( itX!=m_trans_shape_xs.end() ) while( itX!=m_trans_shape_xs.end() )
{ {
@ -3652,7 +3649,7 @@ void mpMovableObject::Plot( wxDC& dc, mpWindow& w )
if( first ) if( first )
{ {
first = FALSE; first = false;
cx0 = cx; cy0 = cy; cx0 = cx; cy0 = cy;
} }