Fixed cursors
This commit is contained in:
parent
65a0327e85
commit
b25781814d
|
@ -3604,3 +3604,28 @@ void mpFXY::SetScale ( mpScaleBase *scaleX, mpScaleBase *scaleY )
|
|||
m_scaleY->ExtendDataRange(GetMinY(), GetMaxY());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double mpFXY::s2x(double plotCoordX) const
|
||||
{
|
||||
return m_scaleX->TransformFromPlot( plotCoordX );
|
||||
}
|
||||
|
||||
|
||||
double mpFXY::s2y(double plotCoordY) const
|
||||
{
|
||||
return m_scaleY->TransformFromPlot( plotCoordY );
|
||||
}
|
||||
|
||||
|
||||
double mpFXY::x2s(double x) const
|
||||
{
|
||||
return m_scaleX->TransformToPlot( x );
|
||||
}
|
||||
|
||||
|
||||
double mpFXY::y2s(double y) const
|
||||
{
|
||||
return m_scaleY->TransformToPlot( y );
|
||||
}
|
||||
|
||||
|
|
|
@ -678,8 +678,8 @@ void SIM_PLOT_FRAME::onCursorUpdate( wxCommandEvent& event )
|
|||
{
|
||||
const wxRealPoint coords = cursor->GetCoords();
|
||||
long idx = m_cursors->InsertItem( SIGNAL_COL, trace.first );
|
||||
m_cursors->SetItem( idx, X_COL, wxString::Format( "%f", coords.x ) );
|
||||
m_cursors->SetItem( idx, Y_COL, wxString::Format( "%f", coords.y ) );
|
||||
m_cursors->SetItem( idx, X_COL, SPICE_VALUE( coords.x ).ToSpiceString() );
|
||||
m_cursors->SetItem( idx, Y_COL, SPICE_VALUE( coords.y ).ToSpiceString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,7 +196,6 @@ public:
|
|||
return formatSI ( m_labeledTicks[n], wxT("A"), 3, AbsVisibleMaxValue() );
|
||||
}
|
||||
};
|
||||
|
||||
void CURSOR::Plot( wxDC& aDC, mpWindow& aWindow )
|
||||
{
|
||||
if( !m_window )
|
||||
|
@ -213,7 +212,7 @@ void CURSOR::Plot( wxDC& aDC, mpWindow& aWindow )
|
|||
|
||||
if( m_updateRequired )
|
||||
{
|
||||
m_coords.x = aWindow.p2x( m_dim.x );
|
||||
m_coords.x = m_trace->s2x( aWindow.p2x( m_dim.x ) );
|
||||
|
||||
// Find the closest point coordinates
|
||||
auto maxXIt = std::upper_bound( dataX.begin(), dataX.end(), m_coords.x );
|
||||
|
@ -239,6 +238,7 @@ void CURSOR::Plot( wxDC& aDC, mpWindow& aWindow )
|
|||
const double leftY = dataY[minIdx];
|
||||
const double rightY = dataY[maxIdx];
|
||||
|
||||
// Linear interpolation
|
||||
m_coords.y = leftY + ( rightY - leftY ) / ( rightX - leftX ) * ( m_coords.x - leftX );
|
||||
m_updateRequired = false;
|
||||
|
||||
|
@ -254,15 +254,34 @@ void CURSOR::Plot( wxDC& aDC, mpWindow& aWindow )
|
|||
const int horLen = aWindow.GetScrX();
|
||||
const int verLen = aWindow.GetScrY();
|
||||
|
||||
const wxPoint cursorPos( aWindow.x2p( m_coords.x ), aWindow.y2p( m_coords.y ) );
|
||||
|
||||
aDC.SetPen( wxPen( *wxBLACK, 1, m_continuous ? wxSOLID : wxLONG_DASH ) );
|
||||
|
||||
const wxPoint cursorPos( aWindow.x2p( m_trace->x2s( m_coords.x ) ),
|
||||
aWindow.y2p( m_trace->y2s( m_coords.y ) ) );
|
||||
aDC.SetPen( wxPen( *wxWHITE, 1, m_continuous ? wxSOLID : wxLONG_DASH ) );
|
||||
aDC.DrawLine( -horLen, cursorPos.y, horLen, cursorPos.y );
|
||||
aDC.DrawLine( cursorPos.x, -verLen, cursorPos.x, verLen );
|
||||
}
|
||||
|
||||
|
||||
bool CURSOR::Inside( wxPoint& aPoint )
|
||||
{
|
||||
if( !m_window )
|
||||
return false;
|
||||
|
||||
return ( std::abs( aPoint.x - m_window->x2p( m_trace->x2s( m_coords.x ) ) ) <= DRAG_MARGIN )
|
||||
&& ( std::abs( aPoint.y - m_window->y2p( m_trace->y2s( m_coords.y ) ) ) <= DRAG_MARGIN );
|
||||
}
|
||||
|
||||
|
||||
void CURSOR::UpdateReference()
|
||||
{
|
||||
if( !m_window )
|
||||
return;
|
||||
|
||||
m_reference.x = m_window->x2p( m_trace->x2s( m_coords.x ) );
|
||||
m_reference.y = m_window->y2p( m_trace->y2s( m_coords.y ) );
|
||||
}
|
||||
|
||||
|
||||
SIM_PLOT_PANEL::SIM_PLOT_PANEL( SIM_TYPE aType, wxWindow* parent, wxWindowID id, const wxPoint& pos,
|
||||
const wxSize& size, long style, const wxString& name )
|
||||
: mpWindow( parent, id, pos, size, style ), m_colorIdx( 0 ),
|
||||
|
|
|
@ -37,7 +37,7 @@ class CURSOR : public mpInfoLayer
|
|||
public:
|
||||
CURSOR( const TRACE* aTrace )
|
||||
: mpInfoLayer( wxRect( 0, 0, DRAG_MARGIN, DRAG_MARGIN ), wxTRANSPARENT_BRUSH ),
|
||||
m_trace( aTrace ), m_updateRequired( false ), m_coords( 0.0, 0.0 ), m_window( nullptr )
|
||||
m_trace( aTrace ), m_updateRequired( true ), m_coords( 0.0, 0.0 ), m_window( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -48,14 +48,7 @@ public:
|
|||
m_updateRequired = true;
|
||||
}
|
||||
|
||||
bool Inside( wxPoint& aPoint )
|
||||
{
|
||||
if( !m_window )
|
||||
return false;
|
||||
|
||||
return ( std::abs( aPoint.x - m_window->x2p( m_coords.x ) ) <= DRAG_MARGIN )
|
||||
&& ( std::abs( aPoint.y - m_window->y2p( m_coords.y ) ) <= DRAG_MARGIN );
|
||||
}
|
||||
bool Inside( wxPoint& aPoint ) override;
|
||||
|
||||
void Move( wxPoint aDelta ) override
|
||||
{
|
||||
|
@ -63,14 +56,7 @@ public:
|
|||
mpInfoLayer::Move( aDelta );
|
||||
}
|
||||
|
||||
void UpdateReference()
|
||||
{
|
||||
if( !m_window )
|
||||
return;
|
||||
|
||||
m_reference.x = m_window->x2p( m_coords.x );
|
||||
m_reference.y = m_window->y2p( m_coords.y );
|
||||
}
|
||||
void UpdateReference();
|
||||
|
||||
const wxRealPoint& GetCoords() const
|
||||
{
|
||||
|
|
|
@ -583,7 +583,6 @@ class WXDLLIMPEXP_MATHPLOT mpFY : public mpLayer
|
|||
Optionally implement a constructor and pass a name (label) and a label alignment
|
||||
to the constructor mpFXY::mpFXY. If the layer name is empty, no label will be plotted.
|
||||
*/
|
||||
class mpScaleBase;
|
||||
|
||||
class WXDLLIMPEXP_MATHPLOT mpFXY : public mpLayer
|
||||
{
|
||||
|
@ -611,8 +610,13 @@ class WXDLLIMPEXP_MATHPLOT mpFXY : public mpLayer
|
|||
*/
|
||||
virtual void Plot(wxDC & dc, mpWindow & w);
|
||||
|
||||
virtual void SetScale ( mpScaleBase *scaleX, mpScaleBase *scaleY );
|
||||
virtual void SetScale(mpScaleBase *scaleX, mpScaleBase *scaleY);
|
||||
|
||||
double s2x(double plotCoordX) const;
|
||||
double s2y(double plotCoordY) const;
|
||||
|
||||
double x2s(double x) const;
|
||||
double y2s(double y) const;
|
||||
|
||||
protected:
|
||||
int m_flags; //!< Holds label alignment
|
||||
|
|
Loading…
Reference in New Issue