ADDED: Sim plot panel: option to plot on a white background or a black background.
This commit is contained in:
parent
ad3c4b37ab
commit
0e51ed32f9
|
@ -138,6 +138,9 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent )
|
|||
// Get the previous size and position of windows:
|
||||
LoadSettings( config() );
|
||||
|
||||
// Prepare the color list to plot traces
|
||||
fillDefaultColorList( GetPlotBgOpt() );
|
||||
|
||||
// Give icons to menuitems
|
||||
setIconsForMenuItems();
|
||||
|
||||
|
@ -228,10 +231,12 @@ SIM_PLOT_FRAME::~SIM_PLOT_FRAME()
|
|||
m_settingsDlg->Destroy();
|
||||
}
|
||||
|
||||
// Keys for config save/read
|
||||
#define PLOT_PANEL_WIDTH_ENTRY "SimPlotPanelWidth"
|
||||
#define PLOT_PANEL_HEIGHT_ENTRY "SimPlotPanelHeight"
|
||||
#define SIGNALS_PANEL_HEIGHT_ENTRY "SimSignalPanelHeight"
|
||||
#define CURSORS_PANEL_HEIGHT_ENTRY "SimCursorsPanelHeight"
|
||||
#define PLOT_WITE_BG "SimPlotWhiteBg"
|
||||
|
||||
void SIM_PLOT_FRAME::SaveSettings( wxConfigBase* aCfg )
|
||||
{
|
||||
|
@ -243,6 +248,7 @@ void SIM_PLOT_FRAME::SaveSettings( wxConfigBase* aCfg )
|
|||
aCfg->Write( PLOT_PANEL_HEIGHT_ENTRY, m_splitterPlotAndConsole->GetSashPosition() );
|
||||
aCfg->Write( SIGNALS_PANEL_HEIGHT_ENTRY, m_splitterSignals->GetSashPosition() );
|
||||
aCfg->Write( CURSORS_PANEL_HEIGHT_ENTRY, m_splitterTuneValues->GetSashPosition() );
|
||||
aCfg->Write( PLOT_WITE_BG, m_plotUseWhiteBg );
|
||||
}
|
||||
|
||||
|
||||
|
@ -257,6 +263,7 @@ void SIM_PLOT_FRAME::LoadSettings( wxConfigBase* aCfg )
|
|||
aCfg->Read( PLOT_PANEL_HEIGHT_ENTRY, &m_splitterPlotAndConsoleSashPosition, -1 );
|
||||
aCfg->Read( SIGNALS_PANEL_HEIGHT_ENTRY, &m_splitterSignalsSashPosition, -1 );
|
||||
aCfg->Read( CURSORS_PANEL_HEIGHT_ENTRY, &m_splitterTuneValuesSashPosition, -1 );
|
||||
aCfg->Read( PLOT_WITE_BG, &m_plotUseWhiteBg, false );
|
||||
}
|
||||
|
||||
|
||||
|
@ -295,6 +302,8 @@ void SIM_PLOT_FRAME::setIconsForMenuItems()
|
|||
{ wxID_ZOOM_FIT, zoom_fit_in_page_xpm},
|
||||
{ ID_MENU_SHOW_GRID, grid_xpm},
|
||||
{ ID_MENU_SHOW_LEGEND, text_xpm},
|
||||
{ ID_MENU_DOTTED, add_dashed_line_xpm},
|
||||
{ ID_MENU_WHITE_BG, swap_layer_xpm},
|
||||
|
||||
{ 0, nullptr } // Sentinel
|
||||
};
|
||||
|
@ -346,6 +355,56 @@ void SIM_PLOT_FRAME::setSubWindowsSashSize()
|
|||
}
|
||||
|
||||
|
||||
wxColor SIM_PLOT_FRAME::GetPlotColor( int aColorId )
|
||||
{
|
||||
// return the wxColor selected in color list or BLACK is not in list
|
||||
if( aColorId >= 0 && aColorId < (int)m_colorList.size() )
|
||||
return m_colorList[aColorId];
|
||||
|
||||
return wxColor( 0, 0, 0 );
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::fillDefaultColorList( bool aWhiteBg )
|
||||
{
|
||||
m_colorList.clear();
|
||||
|
||||
if( aWhiteBg )
|
||||
{
|
||||
m_colorList.emplace_back( 255, 255, 255 ); // Bg color
|
||||
m_colorList.emplace_back( 0, 0, 0 ); // Fg color (texts)
|
||||
m_colorList.emplace_back( 130, 130, 130 ); // Axis color
|
||||
m_colorList.emplace_back( 0, 0, 0 ); // cursors color
|
||||
}
|
||||
else
|
||||
{
|
||||
m_colorList.emplace_back( 0, 0, 0 ); // Bg color
|
||||
m_colorList.emplace_back( 255, 255, 255 ); // Fg color (texts)
|
||||
m_colorList.emplace_back( 130, 130, 130 ); // Axis color
|
||||
m_colorList.emplace_back( 255, 255, 255 ); // cursors color
|
||||
}
|
||||
|
||||
// Add a list of color for traces, starting at index SIM_TRACE_COLOR
|
||||
m_colorList.emplace_back( 0xE4, 0x1A, 0x1C );
|
||||
m_colorList.emplace_back( 0x37, 0x7E, 0xB8 );
|
||||
m_colorList.emplace_back( 0x4D, 0xAF, 0x4A );
|
||||
m_colorList.emplace_back( 0x98, 0x4E, 0xA3 );
|
||||
m_colorList.emplace_back( 0xFF, 0x7F, 0x00 );
|
||||
m_colorList.emplace_back( 0xFF, 0xFF, 0x33 );
|
||||
m_colorList.emplace_back( 0xA6, 0x56, 0x28 );
|
||||
m_colorList.emplace_back( 0xF7, 0x81, 0xBF );
|
||||
m_colorList.emplace_back( 0x66, 0xC2, 0xA5 );
|
||||
m_colorList.emplace_back( 0xFC, 0x8D, 0x62 );
|
||||
m_colorList.emplace_back( 0x8D, 0xA0, 0xCB );
|
||||
m_colorList.emplace_back( 0xE7, 0x8A, 0xC3 );
|
||||
m_colorList.emplace_back( 0xA6, 0xD8, 0x54 );
|
||||
m_colorList.emplace_back( 0xFF, 0xD9, 0x2F );
|
||||
m_colorList.emplace_back( 0xE5, 0xC4, 0x94 );
|
||||
m_colorList.emplace_back( 0xB3, 0xB3, 0xB3 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::StartSimulation()
|
||||
{
|
||||
STRING_FORMATTER formatter;
|
||||
|
@ -393,7 +452,7 @@ bool SIM_PLOT_FRAME::IsSimulationRunning()
|
|||
|
||||
SIM_PLOT_PANEL* SIM_PLOT_FRAME::NewPlotPanel( SIM_TYPE aSimType )
|
||||
{
|
||||
SIM_PLOT_PANEL* plotPanel = new SIM_PLOT_PANEL( aSimType, m_plotNotebook, wxID_ANY );
|
||||
SIM_PLOT_PANEL* plotPanel = new SIM_PLOT_PANEL( aSimType, m_plotNotebook, this, wxID_ANY );
|
||||
|
||||
plotPanel->EnableMouseWheelPan(
|
||||
m_schematicFrame->GetCanvas()->GetViewControls()->IsMousewheelPanEnabled() );
|
||||
|
@ -1101,6 +1160,26 @@ void SIM_PLOT_FRAME::menuShowDottedUpdate( wxUpdateUIEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::menuWhiteBackground( wxCommandEvent& event )
|
||||
{
|
||||
m_plotUseWhiteBg = not m_plotUseWhiteBg;
|
||||
|
||||
// Rebuild the color list to plot traces
|
||||
fillDefaultColorList( GetPlotBgOpt() );
|
||||
|
||||
// Now send changes to all SIM_PLOT_PANEL
|
||||
for( size_t page = 0; page < m_plotNotebook->GetPageCount(); page++ )
|
||||
{
|
||||
wxWindow* curPage = m_plotNotebook->GetPage( page );
|
||||
|
||||
if( curPage == m_welcomePanel )
|
||||
continue;
|
||||
|
||||
static_cast<SIM_PLOT_PANEL*>( curPage )->UpdatePlotColors();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::onPlotClose( wxAuiNotebookEvent& event )
|
||||
{
|
||||
int idx = event.GetSelection();
|
||||
|
|
|
@ -55,6 +55,18 @@ class SIM_PLOT_PANEL;
|
|||
class SIM_THREAD_REPORTER;
|
||||
class TUNER_SLIDER;
|
||||
|
||||
|
||||
// Identifiers (indexes) for color choice in color table
|
||||
enum SIM_COLOR_SET
|
||||
{
|
||||
SIM_BG_COLOR,
|
||||
SIM_FG_COLOR,
|
||||
SIM_AXIS_COLOR,
|
||||
SIM_CURSOR_COLOR,
|
||||
SIM_TRACE_COLOR // First index for trace colors list
|
||||
};
|
||||
|
||||
|
||||
///> Trace descriptor class
|
||||
class TRACE_DESC
|
||||
{
|
||||
|
@ -161,6 +173,23 @@ public:
|
|||
*/
|
||||
const NETLIST_EXPORTER_PSPICE_SIM* GetExporter() const;
|
||||
|
||||
/**
|
||||
* @return the current background option for plotting.
|
||||
* false for drak bg, true for clear bg
|
||||
*/
|
||||
bool GetPlotBgOpt() const { return m_plotUseWhiteBg; }
|
||||
|
||||
/**
|
||||
* @return the wxColor selected in color list.
|
||||
* @param aColorId is the index in color list
|
||||
*/
|
||||
wxColor GetPlotColor( int aColorId );
|
||||
|
||||
/**
|
||||
* @return the count of colors in color list
|
||||
*/
|
||||
int GetPlotColorCount() { return m_colorList.size(); }
|
||||
|
||||
private:
|
||||
void LoadSettings( wxConfigBase* aCfg ) override;
|
||||
void SaveSettings( wxConfigBase* aCfg ) override;
|
||||
|
@ -169,6 +198,12 @@ private:
|
|||
*/
|
||||
void setIconsForMenuItems();
|
||||
|
||||
/** Fills m_colorList by a default set of colors.
|
||||
* @param aWhiteBg = true to use a white (or clear) background
|
||||
* false to use a dark background
|
||||
*/
|
||||
void fillDefaultColorList( bool aWhiteBg );
|
||||
|
||||
/**
|
||||
* @brief Adds a new plot to the current panel.
|
||||
* @param aName is the device/net name.
|
||||
|
@ -259,6 +294,11 @@ private:
|
|||
void menuShowLegendUpdate( wxUpdateUIEvent& event ) override;
|
||||
void menuShowDotted( wxCommandEvent& event ) override;
|
||||
void menuShowDottedUpdate( wxUpdateUIEvent& event ) override;
|
||||
void menuWhiteBackground( wxCommandEvent& event ) override;
|
||||
void menuShowWhiteBackgroundUpdate( wxUpdateUIEvent& event ) override
|
||||
{
|
||||
event.Check( m_plotUseWhiteBg );
|
||||
}
|
||||
|
||||
// Event handlers
|
||||
void onPlotChanged( wxAuiNotebookEvent& event ) override;
|
||||
|
@ -358,6 +398,10 @@ private:
|
|||
int m_splitterPlotAndConsoleSashPosition;
|
||||
int m_splitterSignalsSashPosition;
|
||||
int m_splitterTuneValuesSashPosition;
|
||||
bool m_plotUseWhiteBg;
|
||||
|
||||
///> The color list to draw traces, bg, fg, axis...
|
||||
std::vector<wxColour> m_colorList;
|
||||
};
|
||||
|
||||
// Commands
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// C++ code generated with wxFormBuilder (version Jul 10 2019)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -103,6 +103,10 @@ SIM_PLOT_FRAME_BASE::SIM_PLOT_FRAME_BASE( wxWindow* parent, wxWindowID id, const
|
|||
m_showDotted = new wxMenuItem( m_viewMenu, ID_MENU_DOTTED, wxString( _("Dotted Current/Phase") ) , wxEmptyString, wxITEM_CHECK );
|
||||
m_viewMenu->Append( m_showDotted );
|
||||
|
||||
wxMenuItem* m_showWhiteBackground;
|
||||
m_showWhiteBackground = new wxMenuItem( m_viewMenu, ID_MENU_WHITE_BG, wxString( _("White Background") ) , wxEmptyString, wxITEM_CHECK );
|
||||
m_viewMenu->Append( m_showWhiteBackground );
|
||||
|
||||
m_mainMenu->Append( m_viewMenu, _("View") );
|
||||
|
||||
this->SetMenuBar( m_mainMenu );
|
||||
|
@ -306,6 +310,8 @@ SIM_PLOT_FRAME_BASE::SIM_PLOT_FRAME_BASE( wxWindow* parent, wxWindowID id, const
|
|||
this->Connect( m_showLegend->GetId(), wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SIM_PLOT_FRAME_BASE::menuShowLegendUpdate ) );
|
||||
m_viewMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuShowDotted ), this, m_showDotted->GetId());
|
||||
this->Connect( m_showDotted->GetId(), wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SIM_PLOT_FRAME_BASE::menuShowDottedUpdate ) );
|
||||
m_viewMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuWhiteBackground ), this, m_showWhiteBackground->GetId());
|
||||
this->Connect( m_showWhiteBackground->GetId(), wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SIM_PLOT_FRAME_BASE::menuShowWhiteBackgroundUpdate ) );
|
||||
m_plotNotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotChanged ), NULL, this );
|
||||
m_plotNotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotClose ), NULL, this );
|
||||
m_signals->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( SIM_PLOT_FRAME_BASE::onSignalDblClick ), NULL, this );
|
||||
|
@ -318,6 +324,7 @@ SIM_PLOT_FRAME_BASE::~SIM_PLOT_FRAME_BASE()
|
|||
this->Disconnect( ID_MENU_SHOW_GRID, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SIM_PLOT_FRAME_BASE::menuShowGridUpdate ) );
|
||||
this->Disconnect( ID_MENU_SHOW_LEGEND, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SIM_PLOT_FRAME_BASE::menuShowLegendUpdate ) );
|
||||
this->Disconnect( ID_MENU_DOTTED, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SIM_PLOT_FRAME_BASE::menuShowDottedUpdate ) );
|
||||
this->Disconnect( ID_MENU_WHITE_BG, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SIM_PLOT_FRAME_BASE::menuShowWhiteBackgroundUpdate ) );
|
||||
m_plotNotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotChanged ), NULL, this );
|
||||
m_plotNotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotClose ), NULL, this );
|
||||
m_signals->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( SIM_PLOT_FRAME_BASE::onSignalDblClick ), NULL, this );
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<property name="file">sim_plot_frame_base</property>
|
||||
<property name="first_id">1000</property>
|
||||
<property name="help_provider">none</property>
|
||||
<property name="image_path_wrapper_function_name"></property>
|
||||
<property name="indent_with_spaces"></property>
|
||||
<property name="internationalize">1</property>
|
||||
<property name="name">SpiceWindow</property>
|
||||
|
@ -25,6 +26,7 @@
|
|||
<property name="skip_php_events">1</property>
|
||||
<property name="skip_python_events">1</property>
|
||||
<property name="ui_table">UI</property>
|
||||
<property name="use_array_enum">0</property>
|
||||
<property name="use_enum">0</property>
|
||||
<property name="use_microsoft_bom">0</property>
|
||||
<object class="Frame" expanded="1">
|
||||
|
@ -371,6 +373,21 @@
|
|||
<event name="OnMenuSelection">menuShowDotted</event>
|
||||
<event name="OnUpdateUI">menuShowDottedUpdate</event>
|
||||
</object>
|
||||
<object class="wxMenuItem" expanded="1">
|
||||
<property name="bitmap"></property>
|
||||
<property name="checked">0</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="help"></property>
|
||||
<property name="id">ID_MENU_WHITE_BG</property>
|
||||
<property name="kind">wxITEM_CHECK</property>
|
||||
<property name="label">White Background</property>
|
||||
<property name="name">m_showWhiteBackground</property>
|
||||
<property name="permission">none</property>
|
||||
<property name="shortcut"></property>
|
||||
<property name="unchecked_bitmap"></property>
|
||||
<event name="OnMenuSelection">menuWhiteBackground</event>
|
||||
<event name="OnUpdateUI">menuShowWhiteBackgroundUpdate</event>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// C++ code generated with wxFormBuilder (version Jul 10 2019)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -10,6 +10,8 @@
|
|||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/intl.h>
|
||||
class wxListView;
|
||||
|
||||
#include "kiway_player.h"
|
||||
#include <wx/string.h>
|
||||
#include <wx/bitmap.h>
|
||||
|
@ -43,6 +45,7 @@
|
|||
#define ID_MENU_SHOW_GRID 1008
|
||||
#define ID_MENU_SHOW_LEGEND 1009
|
||||
#define ID_MENU_DOTTED 1010
|
||||
#define ID_MENU_WHITE_BG 1011
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class SIM_PLOT_FRAME_BASE
|
||||
|
@ -108,6 +111,8 @@ class SIM_PLOT_FRAME_BASE : public KIWAY_PLAYER
|
|||
virtual void menuShowLegendUpdate( wxUpdateUIEvent& event ) { event.Skip(); }
|
||||
virtual void menuShowDotted( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void menuShowDottedUpdate( wxUpdateUIEvent& event ) { event.Skip(); }
|
||||
virtual void menuWhiteBackground( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void menuShowWhiteBackgroundUpdate( wxUpdateUIEvent& event ) { event.Skip(); }
|
||||
virtual void onPlotChanged( wxAuiNotebookEvent& event ) { event.Skip(); }
|
||||
virtual void onPlotClose( wxAuiNotebookEvent& event ) { event.Skip(); }
|
||||
virtual void onSignalDblClick( wxMouseEvent& event ) { event.Skip(); }
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
*/
|
||||
|
||||
#include "sim_plot_panel.h"
|
||||
#include "sim_plot_frame.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
@ -331,7 +332,8 @@ void CURSOR::Plot( wxDC& aDC, mpWindow& aWindow )
|
|||
wxCoord topPx = m_drawOutsideMargins ? 0 : aWindow.GetMarginTop();
|
||||
wxCoord bottomPx = m_drawOutsideMargins ? aWindow.GetScrY() : aWindow.GetScrY() - aWindow.GetMarginBottom();
|
||||
|
||||
aDC.SetPen( wxPen( *wxWHITE, 1, m_continuous ? wxPENSTYLE_SOLID : wxPENSTYLE_LONG_DASH ) );
|
||||
aDC.SetPen( wxPen( m_plotPanel->GetPlotColor( SIM_CURSOR_COLOR ), 1,
|
||||
m_continuous ? wxPENSTYLE_SOLID : wxPENSTYLE_LONG_DASH ) );
|
||||
|
||||
if( topPx < cursorPos.y && cursorPos.y < bottomPx )
|
||||
aDC.DrawLine( leftPx, cursorPos.y, rightPx, cursorPos.y );
|
||||
|
@ -361,7 +363,8 @@ void CURSOR::UpdateReference()
|
|||
}
|
||||
|
||||
|
||||
SIM_PLOT_PANEL::SIM_PLOT_PANEL( SIM_TYPE aType, wxWindow* parent, wxWindowID id, const wxPoint& pos,
|
||||
SIM_PLOT_PANEL::SIM_PLOT_PANEL( SIM_TYPE aType, wxWindow* parent, SIM_PLOT_FRAME* aMainFrame,
|
||||
wxWindowID id, const wxPoint& pos,
|
||||
const wxSize& size, long style, const wxString& name )
|
||||
: mpWindow( parent, id, pos, size, style ),
|
||||
m_colorIdx( 0 ),
|
||||
|
@ -369,16 +372,15 @@ SIM_PLOT_PANEL::SIM_PLOT_PANEL( SIM_TYPE aType, wxWindow* parent, wxWindowID id,
|
|||
m_axis_y1( nullptr ),
|
||||
m_axis_y2( nullptr ),
|
||||
m_dotted_cp( false ),
|
||||
m_type( aType )
|
||||
m_type( aType ),
|
||||
m_masterFrame( aMainFrame )
|
||||
{
|
||||
LimitView( true );
|
||||
SetMargins( 50, 80, 50, 80 );
|
||||
|
||||
wxColour grey( 130, 130, 130 );
|
||||
wxColour dark( 10, 10, 10 );
|
||||
SetColourTheme( dark, *wxWHITE, grey );
|
||||
EnableDoubleBuffer( true );
|
||||
UpdateAll();
|
||||
SetColourTheme( GetPlotColor( SIM_BG_COLOR ),
|
||||
GetPlotColor( SIM_FG_COLOR ),
|
||||
GetPlotColor( SIM_AXIS_COLOR ) );
|
||||
|
||||
switch( m_type )
|
||||
{
|
||||
|
@ -434,11 +436,10 @@ SIM_PLOT_PANEL::SIM_PLOT_PANEL( SIM_TYPE aType, wxWindow* parent, wxWindowID id,
|
|||
AddLayer( m_axis_y2 );
|
||||
}
|
||||
|
||||
// a mpInfoLegend displays le name of traces on the left top panel corner:
|
||||
m_legend = new mpInfoLegend( wxRect( 0, 40, 200, 40 ), wxTRANSPARENT_BRUSH );
|
||||
m_legend->SetVisible( false );
|
||||
AddLayer( m_legend );
|
||||
m_topLevel.push_back( m_legend );
|
||||
SetColourTheme( dark, *wxWHITE, grey );
|
||||
|
||||
EnableDoubleBuffer( true );
|
||||
UpdateAll();
|
||||
|
@ -451,6 +452,23 @@ SIM_PLOT_PANEL::~SIM_PLOT_PANEL()
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_PANEL::UpdatePlotColors()
|
||||
{
|
||||
// Update bg and fg colors:
|
||||
SetColourTheme( GetPlotColor( SIM_BG_COLOR ),
|
||||
GetPlotColor( SIM_FG_COLOR ),
|
||||
GetPlotColor( SIM_AXIS_COLOR ) );
|
||||
|
||||
UpdateAll();
|
||||
}
|
||||
|
||||
|
||||
wxColour SIM_PLOT_PANEL::GetPlotColor( int aIndex )
|
||||
{
|
||||
return m_masterFrame->GetPlotColor( aIndex );
|
||||
}
|
||||
|
||||
|
||||
bool SIM_PLOT_PANEL::IsPlottable( SIM_TYPE aSimType )
|
||||
{
|
||||
switch( aSimType )
|
||||
|
@ -608,7 +626,7 @@ void SIM_PLOT_PANEL::EnableCursor( const wxString& aName, bool aEnable )
|
|||
|
||||
if( aEnable )
|
||||
{
|
||||
CURSOR* c = new CURSOR( t );
|
||||
CURSOR* c = new CURSOR( t, this );
|
||||
int plotCenter = GetMarginLeft() + ( GetXScreen() - GetMarginLeft() - GetMarginRight() ) / 2;
|
||||
c->SetX( plotCenter );
|
||||
t->SetCursor( c );
|
||||
|
@ -644,42 +662,31 @@ void SIM_PLOT_PANEL::ResetScales()
|
|||
|
||||
wxColour SIM_PLOT_PANEL::generateColor()
|
||||
{
|
||||
/// @todo have a look at:
|
||||
/// http://stanford.edu/~mwaskom/software/seaborn/tutorial/color_palettes.html
|
||||
/// https://github.com/Gnuplotting/gnuplot-palettes
|
||||
|
||||
// const unsigned long colors[] = { 0x0000ff, 0x00ff00, 0xff0000, 0x00ffff, 0xff00ff, 0xffff000, 0xffffff };
|
||||
|
||||
const unsigned long colors[] = { 0xE41A1C, 0x377EB8, 0x4DAF4A, 0x984EA3, 0xFF7F00, 0xFFFF33, 0xA65628, 0xF781BF,
|
||||
0x66C2A5, 0xFC8D62, 0x8DA0CB, 0xE78AC3, 0xA6D854, 0xFFD92F, 0xE5C494, 0xB3B3B3 };
|
||||
|
||||
//const unsigned long colors[] = { 0xe3cea6, 0xb4781f, 0x8adfb2, 0x2ca033, 0x999afb, 0x1c1ae3, 0x6fbffd, 0x007fff, 0xd6b2ca, 0x9a3d6a };
|
||||
|
||||
// hls
|
||||
//const unsigned long colors[] = { 0x0f1689, 0x0f7289, 0x35890f, 0x0f8945, 0x89260f, 0x890f53, 0x89820f, 0x630f89 };
|
||||
|
||||
// pastels, good for dark background
|
||||
//const unsigned long colors[] = { 0x2fd8fe, 0x628dfa, 0x53d8a6, 0xa5c266, 0xb3b3b3, 0x94c3e4, 0xca9f8d, 0xac680e };
|
||||
|
||||
const unsigned int colorCount = sizeof(colors) / sizeof(unsigned long);
|
||||
const unsigned int colorCount = m_masterFrame->GetPlotColorCount() - SIM_TRACE_COLOR;
|
||||
|
||||
for( int i = 0; i < (int)colorCount - 1; i++ )
|
||||
{
|
||||
const wxColour color = wxColour( colors[i] );
|
||||
const wxColour color = GetPlotColor( i+SIM_TRACE_COLOR );
|
||||
bool hasColor = false;
|
||||
|
||||
for( auto& t : m_traces )
|
||||
{
|
||||
TRACE* trace = t.second;
|
||||
|
||||
if( trace->GetTraceColour() == color )
|
||||
{
|
||||
hasColor = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !hasColor )
|
||||
return color;
|
||||
}
|
||||
return wxColour( colors[m_traces.size() % colorCount] );
|
||||
|
||||
// If all colors are in use, choose a suitable color in list
|
||||
int idx = m_traces.size() % colorCount;
|
||||
return wxColour( GetPlotColor( idx + SIM_TRACE_COLOR ) );
|
||||
}
|
||||
|
||||
wxDEFINE_EVENT( EVT_SIM_CURSOR_UPDATE, wxCommandEvent );
|
||||
|
|
|
@ -31,16 +31,18 @@
|
|||
#include <map>
|
||||
#include "sim_types.h"
|
||||
|
||||
class SIM_PLOT_FRAME;
|
||||
class SIM_PLOT_PANEL;
|
||||
class TRACE;
|
||||
|
||||
///> Cursor attached to a trace to follow its values:
|
||||
class CURSOR : public mpInfoLayer
|
||||
{
|
||||
public:
|
||||
CURSOR( const TRACE* aTrace )
|
||||
CURSOR( const TRACE* aTrace, SIM_PLOT_PANEL* aPlotPanel )
|
||||
: mpInfoLayer( wxRect( 0, 0, DRAG_MARGIN, DRAG_MARGIN ), wxTRANSPARENT_BRUSH ),
|
||||
m_trace( aTrace ), m_updateRequired( true ), m_updateRef( false ),
|
||||
m_coords( 0.0, 0.0 ), m_window( nullptr )
|
||||
m_coords( 0.0, 0.0 ), m_window( nullptr ), m_plotPanel( aPlotPanel )
|
||||
{
|
||||
SetDrawOutsideMargins( false );
|
||||
}
|
||||
|
@ -79,6 +81,7 @@ private:
|
|||
bool m_updateRequired, m_updateRef;
|
||||
wxRealPoint m_coords;
|
||||
mpWindow* m_window;
|
||||
SIM_PLOT_PANEL* m_plotPanel;
|
||||
|
||||
static constexpr int DRAG_MARGIN = 10;
|
||||
};
|
||||
|
@ -163,11 +166,18 @@ protected:
|
|||
class SIM_PLOT_PANEL : public mpWindow
|
||||
{
|
||||
public:
|
||||
SIM_PLOT_PANEL( SIM_TYPE aType, wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
|
||||
SIM_PLOT_PANEL( SIM_TYPE aType, wxWindow* parent, SIM_PLOT_FRAME* aMainFrame,
|
||||
wxWindowID id, const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxPanelNameStr );
|
||||
|
||||
~SIM_PLOT_PANEL();
|
||||
|
||||
///> set the pointer to the sim plot frame
|
||||
void SetMasterFrame( SIM_PLOT_FRAME* aFrame )
|
||||
{
|
||||
m_masterFrame = aFrame;
|
||||
}
|
||||
|
||||
SIM_TYPE GetType() const
|
||||
{
|
||||
return m_type;
|
||||
|
@ -271,8 +281,18 @@ public:
|
|||
///> Update trace line style
|
||||
void UpdateTraceStyle( TRACE* trace );
|
||||
|
||||
/**
|
||||
* A proxy to SIM_PLOT_FRAME::GetPlotColor()
|
||||
* @return the color stored in m_colorList.
|
||||
* @param aIndex is the index in list
|
||||
*/
|
||||
wxColour GetPlotColor( int aIndex );
|
||||
|
||||
///> Update plot colors
|
||||
void UpdatePlotColors();
|
||||
|
||||
private:
|
||||
///> Returns a new color from the palette
|
||||
///> @return a new color from the palette
|
||||
wxColour generateColor();
|
||||
|
||||
// Color index to get a new color from the palette
|
||||
|
@ -291,6 +311,8 @@ private:
|
|||
std::vector<mpLayer*> m_topLevel;
|
||||
|
||||
const SIM_TYPE m_type;
|
||||
|
||||
SIM_PLOT_FRAME* m_masterFrame;
|
||||
};
|
||||
|
||||
wxDECLARE_EVENT( EVT_SIM_CURSOR_UPDATE, wxCommandEvent );
|
||||
|
|
Loading…
Reference in New Issue