24#ifndef __SIM_PLOT_PANEL_H
25#define __SIM_PLOT_PANEL_H
90 Move( wxPoint( aX, 0 ) );
100 bool Inside(
const wxPoint& aPoint )
const override;
102 void Move( wxPoint aDelta )
override;
150 void SetName(
const wxString& aName )
override
174 void SetData(
const std::vector<double>& aX,
const std::vector<double>& aY )
override
245 bool HasBBox()
const override {
return false; }
266 TRACE( aName, aType )
273 bool HasBBox()
const override {
return false; }
294 CURSOR( aTrace, aPlotTab ),
305 bool Inside(
const wxPoint& aPoint )
const override;
307 void Move( wxPoint aDelta )
override;
311 void SetCoordX(
double aValue )
override;
365 void SetXRange(
double aPos,
double aDesiredMax,
double aDesiredMin )
367 SetXView( aPos, aDesiredMax, aDesiredMin );
383 return m_axis_y1->GetAxisMinMax( aMin, aMax );
391 return m_axis_y2->GetAxisMinMax( aMin, aMax );
399 return m_axis_y3->GetAxisMinMax( aMin, aMax );
404 void SetY1Scale(
bool aLock,
double aMin,
double aMax );
405 void SetY2Scale(
bool aLock,
double aMin,
double aMax );
406 void SetY3Scale(
bool aLock,
double aMin,
double aMax );
499 m_smithZoom = std::isfinite( aZoom ) ? std::clamp( aZoom, 1.0, 50.0 ) : 1.0;
500 m_smithPan.x = std::isfinite( aPanX ) ? std::clamp( aPanX, -100.0, 100.0 ) : 0.0;
501 m_smithPan.y = std::isfinite( aPanY ) ? std::clamp( aPanY, -100.0, 100.0 ) : 0.0;
504 void SmithZoomAt(
const wxPoint& aPos,
double aFactor );
551 SIM_PLOT_TAB(
const wxString& aSimCommand, wxWindow* parent );
563 return ( aIndex >= 0 && aIndex < (
int)
m_views.size() ) ?
m_views[aIndex] :
nullptr;
610 bool GetY1Scale(
double* aMin,
double* aMax )
const;
611 bool GetY2Scale(
double* aMin,
double* aMax )
const;
612 bool GetY3Scale(
double* aMin,
double* aMax )
const;
613 void SetY1Scale(
bool aLock,
double aMin,
double aMax );
614 void SetY2Scale(
bool aLock,
double aMin,
double aMax );
615 void SetY3Scale(
bool aLock,
double aMin,
double aMax );
649 void SetSmithView(
double aZoom,
double aPanX,
double aPanY );
651 void SmithZoomAt(
const wxPoint& aPos,
double aFactor );
683 void SetTraceData(
TRACE* aTrace, std::vector<double>& aX, std::vector<double>& aY,
int aSweepCount,
684 size_t aSweepSize,
bool aIsMultiRun =
false,
const std::vector<wxString>& aMultiRunLabels = {} );
686 bool DeleteTrace(
const wxString& aVectorName,
int aTraceType );
695 return trace ==
m_traces.end() ? nullptr : trace->second;
708 "mpWindow::MouseWheelAction enum must match SIM_MOUSE_WHEEL_ACTION" );
721 wxString
getTraceId(
const wxString& aVectorName,
int aType )
const
723 return wxString::Format( wxS(
"%s%d" ), aVectorName, aType &
SPT_Y_AXIS_MASK );
The SIMULATOR_FRAME holds the main user-interface for running simulations.
CURSOR(TRACE *aTrace, SIM_PLOT_TAB *aPlotTab)
const wxRealPoint & GetCoords() const
void Move(wxPoint aDelta) override
Moves the layer rectangle of given pixel deltas.
static constexpr int DRAG_MARGIN
bool Inside(const wxPoint &aPoint) const override
Checks whether a point is inside the info box rectangle.
void doSetCoordX(double aValue)
virtual void UpdateForNewData()
bool OnDoubleClick(const wxPoint &aPoint, mpWindow &aWindow) override
virtual void SetCoordX(double aValue)
void UpdateReference() override
Updates the rectangle reference point.
void Plot(wxDC &aDC, mpWindow &aWindow) override
Plot method.
The SIMULATOR_FRAME holds the main user-interface for running simulations.
bool DeleteTrace(const wxString &aVectorName, int aTraceType)
double GetSmithZoom() const
The saved/restored pan and zoom track the default view.
void UpdateSmithReferenceImpedance()
Refresh the grid z0 from the shown Smith traces, on every view.
wxString GetLabelY1() const
mpWindow * GetPlotWin() const
Getter for the default view's math plot window (back-compat for zoom undo/redo, export).
void SetSmithView(double aZoom, double aPanX, double aPanY)
Restore a saved view, values are validated and clamped.
SIM_VIEW * GetView(int aIndex) const
void ShowGrid(bool aEnable)
void SetTraceData(TRACE *aTrace, std::vector< double > &aX, std::vector< double > &aY, int aSweepCount, size_t aSweepSize, bool aIsMultiRun=false, const std::vector< wxString > &aMultiRunLabels={})
void SyncXView(SIM_VIEW *aSource)
Mirror aSource's current X range onto every other view of this tab.
const std::vector< SIM_VIEW * > & GetViews() const
wxString GetUnitsY2() const
void SetY2Scale(bool aLock, double aMin, double aMax)
void SmithZoomAt(const wxPoint &aPos, double aFactor)
TRACE * GetTrace(const wxString &aVecName, int aType) const
std::vector< SMITH_STASHED_CURSOR > m_smithStashedCursors
void SetSmithMode(bool aEnable)
Smith mode is tab-wide: every view of the tab shows a Smith chart while it is on.
wxString GetLabelX() const
wxRealPoint GetSmithPan() const
const std::map< wxString, TRACE * > & GetTraces() const
wxString GetLabelY3() const
void SetY1Scale(bool aLock, double aMin, double aMax)
bool GetDottedSecondary() const
wxPoint GetLegendPosition() const
std::vector< std::pair< wxString, wxString > > m_measurements
void SetY3Scale(bool aLock, double aMin, double aMax)
std::map< wxString, TRACE * > m_traces
bool IsLegendShown() const
SIM_VIEW * GetDefaultView() const
The view new traces default to, and legacy (single-view) settings apply to.
SIM_VIEW * AddView()
Add a new (empty) view, stacked below the existing ones.
std::vector< SMITH_STASHED_TRACE > m_smithStashedTraces
std::vector< std::pair< wxString, wxString > > & Measurements()
wxString GetUnitsForTrace(TRACE *aTrace) const
Get the display units (e.g. "V", "A", "dB") for a given trace's own view.
void UpdateTraceStyle(TRACE *trace)
Update trace line style.
void SetLegendPosition(const wxPoint &aPosition)
TRACE * GetOrAddTrace(const wxString &aVectorName, int aType, SIM_VIEW *aView)
Get (or create, on aView) the TRACE for a signal.
void ResetScales(bool aIncludeX)
Reset scale ranges to fit the current traces, on every view.
void UpdatePlotColors()
Update plot colors.
std::vector< SMITH_STASHED_TRACE > & SmithStashedTraces()
Traces and cursors set aside while in Smith mode, restored when leaving it.
void ShowLegend(bool aEnable)
bool GetY3Scale(double *aMin, double *aMax) const
SIM_PLOT_TAB(const wxString &aSimCommand, wxWindow *parent)
wxString GetLabelY2() const
void EnableCursor(TRACE *aTrace, int aCursorId, const wxString &aSignalName)
Turn on/off the cursor for a particular trace.
int GetViewIndex(SIM_VIEW *aView) const
wxString GetUnitsX() const
void OnLanguageChanged() override
void EnsureThirdYAxisExists()
wxString getTraceId(const wxString &aVectorName, int aType) const
std::vector< SMITH_STASHED_CURSOR > & SmithStashedCursors()
void SetDottedSecondary(bool aEnable)
Draw secondary signal traces (current or phase) with dotted lines.
void ApplyPreferences(const SIM_PREFERENCES &aPrefs) override
wxBoxSizer * m_viewsSizer
mpWindow::MouseWheelActionSet m_mouseWheelActions
bool RemoveView(SIM_VIEW *aView)
Remove a view.
void SmithPanBy(const wxPoint &aDelta)
std::vector< SIM_VIEW * > m_views
wxPoint m_LastLegendPosition
wxColour GetPlotColor(SIM_PLOT_COLORS::COLOR_SET aColorId)
wxString GetUnitsY1() const
std::map< wxString, wxColour > m_sessionTraceColors
static mpWindow::MouseWheelActionSet convertMouseWheelActions(const SIM_MOUSE_WHEEL_ACTION_SET &s)
void DisableCursor(TRACE *aTrace, int aCursorId)
bool GetY2Scale(double *aMin, double *aMax) const
bool GetY1Scale(double *aMin, double *aMax) const
wxString GetUnitsY3() const
A single stacked plot area within a SIM_PLOT_TAB.
wxString GetLabelY2() const
void OnXViewChanged() override
Mirrors this view's X range onto every other view of the same tab.
void updateAxes(int aNewTraceType=SIM_TRACE_TYPE::SPT_UNKNOWN)
Create/Ensure axes are available for plotting.
void SetSmithView(double aZoom, double aPanX, double aPanY)
void SmithZoomAt(const wxPoint &aPos, double aFactor)
bool GetY3Scale(double *aMin, double *aMax) const
void onSmithMenuCommand(wxCommandEvent &aEvent)
wxString GetUnitsForTrace(TRACE *aTrace) const
Get the display units (e.g. "V", "A", "dB") for a given trace plotted on this view.
bool IsSmithChart() const
void UpdateSmithGridColor()
Re-read the Smith grid pen from the tab's color theme.
void SetY2Scale(bool aLock, double aMin, double aMax)
void EnsureThirdYAxisExists()
void SmithPanBy(const wxPoint &aDelta)
void onSmithDClick(wxMouseEvent &aEvent)
wxString GetLabelX() const
void ShowGrid(bool aEnable)
wxPoint m_lastLegendPosition
wxString GetLabelY3() const
wxString GetUnitsY3() const
wxPoint GetLegendPosition() const
void onSmithMagnify(wxMouseEvent &aEvent)
void SetY1Scale(bool aLock, double aMin, double aMax)
const wxRealPoint & GetSmithPan() const
void SetY3Scale(bool aLock, double aMin, double aMax)
void onSmithMiddleDown(wxMouseEvent &aEvent)
void onSmithRightDown(wxMouseEvent &aEvent)
SIM_VIEW(SIM_PLOT_TAB *aPlotTab, wxWindow *aParent)
void SetLegendPosition(const wxPoint &aPosition)
bool IsLegendShown() const
mpScaleY * GetAxisBySlot(int aSlot) const
Get the Y-axis scale object for a given slot (1, 2 or 3), or nullptr if not created yet.
double GetSmithZoom() const
bool getSmithView(SMITH_VIEW &aView) const
bool GetY2Scale(double *aMin, double *aMax) const
SIM_PLOT_TAB * GetPlotTab() const
bool GetY1Scale(double *aMin, double *aMax) const
void onSmithLeftUp(wxMouseEvent &aEvent)
void SetXRange(double aPos, double aDesiredMax, double aDesiredMin)
Directly set this view's X range (used to mirror another view's zoom/pan onto this one).
wxString GetLabelY1() const
void UpdateSmithReferenceImpedance()
Refresh the grid z0 from the Smith traces shown on this view.
void onSmithLeftDown(wxMouseEvent &aEvent)
void ResetScales(bool aIncludeX)
Reset the Y (and, if requested, X) scale ranges to fit this view's own traces.
int GetAxisSlot(TRACE *aTrace) const
Get the Y-axis slot (1, 2 or 3) a trace of this type is plotted on.
void ShowLegend(bool aEnable)
wxString GetUnitsX() const
void onSmithRightUp(wxMouseEvent &aEvent)
void SetSmithChart(bool aEnable)
Show/hide this view's Smith chart overlay.
void UpdateAxisVisibility()
void onSmithMotion(wxMouseEvent &aEvent)
wxString GetUnitsY2() const
wxString GetUnitsY1() const
void onSmithMouseWheel(wxMouseEvent &aEvent)
void prepareDCAxes(int aNewTraceType)
Construct the plot axes for DC simulation plot.
void UpdateReference() override
Updates the rectangle reference point.
void Plot(wxDC &aDC, mpWindow &aWindow) override
Plot method.
bool Inside(const wxPoint &aPoint) const override
Checks whether a point is inside the info box rectangle.
void SetCoordX(double aValue) override
void snapToIndex(int aIndex)
void snapToFrequency(double aFreq)
const wxRealPoint & GetGamma() const
void UpdateForNewData() override
SMITH_CURSOR(SMITH_TRACE *aTrace, SIM_PLOT_TAB *aPlotTab)
void Move(wxPoint aDelta) override
Moves the layer rectangle of given pixel deltas.
Overlay layer drawing the Smith chart grid (constant resistance and reactance circles)
static bool GetChartView(mpWindow &aWindow, double aZoom, const wxRealPoint &aPan, SMITH_VIEW &aView)
Chart placement including pan/zoom.
void Plot(wxDC &aDC, mpWindow &aWindow) override
Plot given view of layer to the given device context.
void SetMixedReferences(bool aMixed)
void SetReferenceImpedance(double aZ0)
Zero when no single reference applies, which labels the grid normalized.
bool HasBBox() const override
Check whether this layer has a bounding box.
Reflection coefficient locus, Re in X and Im in Y, drawn on the Smith chart.
void Plot(wxDC &aDC, mpWindow &aWindow) override
Layer plot handler.
bool HasBBox() const override
Check whether this layer has a bounding box.
void SetReferenceImpedance(double aZ0)
Zero until the response port resolves one, which leaves only normalized values readable.
SMITH_TRACE(const wxString &aName, SIM_TRACE_TYPE aType)
const std::vector< double > & GetFrequencies() const
void SetFrequencies(const std::vector< double > &aFreqs)
std::vector< double > m_frequencies
double GetReferenceImpedance() const
std::vector< wxString > m_multiRunLabels
bool IsYScaleDefault() const
True if this trace's Y-axis scale hasn't been explicitly linked to another view (i....
void SetIsMultiRun(bool aIsMultiRun)
void SetTraceColour(const wxColour &aColour)
void SetName(const wxString &aName) override
Set layer name.
void SetMultiRunLabels(const std::vector< wxString > &aLabels)
std::map< int, CURSOR * > & GetCursors()
SIM_VIEW * GetView() const
The SIM_VIEW this trace is currently plotted on (nullptr if not plotted anywhere).
void SetView(SIM_VIEW *aView)
SIM_TRACE_TYPE GetType() const
std::map< int, CURSOR * > m_cursors
bool HasCursor(int aCursorId)
TRACE(const wxString &aName, SIM_TRACE_TYPE aType)
void SetData(const std::vector< double > &aX, const std::vector< double > &aY) override
Assigns new data set for the trace.
const std::vector< wxString > & GetMultiRunLabels() const
void SetCursor(int aCursorId, CURSOR *aCursor)
SIM_VIEW * GetYScaleView() const
The view whose Y-axis scale this trace's axis should match (defaults to its own view).
void ClearYScaleViewIf(SIM_VIEW *aView)
Clears an explicit Y-scale link if it pointed at a view that no longer exists.
const std::vector< double > & GetDataY() const
wxColour GetTraceColour() const
const std::vector< double > & GetDataX() const
CURSOR * GetCursor(int aCursorId)
void SetYScaleView(SIM_VIEW *aView)
mpFXYVector(const wxString &name=wxEmptyString, int flags=mpALIGN_NE)
std::vector< double > m_ys
std::vector< double > m_xs
The internal copy of the set of data to draw.
virtual void SetData(const std::vector< double > &xs, const std::vector< double > &ys)
Changes the internal data: the set of points to draw.
mpInfoLayer()
Default constructor.
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
void SetContinuity(bool continuity)
Set the 'continuity' property of the layer (true:draws a continuous line, false:draws separate points...
void ShowName(bool show)
Shows or hides the text label with the name of the layer (default is visible).
virtual void SetName(const wxString &name)
Set layer name.
mpLayerType m_type
Define layer type, which is assigned by constructor.
Plot layer implementing a y-scale ruler.
Canvas for plotting mpLayer implementations.
MouseWheelAction
Enumerates the possible mouse wheel actions that can be performed on the plot.
void UpdateAll()
Refresh display.
virtual bool SetXView(double pos, double desiredMax, double desiredMin)
Applies new X view coordinates depending on the settings.
Class is responsible for providing colors for traces on simulation plot.
wxDECLARE_EVENT(EVT_SIM_CURSOR_UPDATE, wxCommandEvent)
SIM_TRACE_TYPE
Possible trace types.
Contains the set of modified mouse wheel actions that can be performed on a simulator plot.
SIM_MOUSE_WHEEL_ACTION vertical_unmodified
SIM_MOUSE_WHEEL_ACTION vertical_with_alt
SIM_MOUSE_WHEEL_ACTION horizontal
SIM_MOUSE_WHEEL_ACTION vertical_with_ctrl
SIM_MOUSE_WHEEL_ACTION vertical_with_shift
Contains preferences pertaining to the simulator.
Cursor recorded when entering Smith mode, so leaving restores it to its original trace.
Trace hidden while the tab is in Smith mode, kept so leaving the mode restores it.
Smith chart placement plus pan/zoom, maps a gamma point to a screen pixel and back.
Contains the set of modified mouse wheel actions that can be performed on the plot.
MouseWheelAction horizontal
MouseWheelAction verticalWithShift
MouseWheelAction verticalWithCtrl
MouseWheelAction verticalWithAlt
MouseWheelAction verticalUnmodified