wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
BewavedDolphin Class Reference

Waveform editor main window for creating and analyzing digital signal sequences. More...

#include <BeWavedDolphin.h>

Inheritance diagram for BewavedDolphin:
[legend]

Classes

struct  Signal
 A labelled waveform signal: a row label and its per-column 0/1 values. More...
struct  WaveformSnapshot
 A read-only snapshot of the computed waveform, for automation/export consumers. More...

Public Member Functions

QAction * actionCombinational () const
 Returns the combinational action (for tour button spotlighting).
 BewavedDolphin (Scene *scene, const bool askConnection=true, DolphinHost *host=nullptr, QWidget *parent=nullptr)
 Constructs the waveform editor.
void createWaveform ()
 Initializes a blank waveform from the current scene's I/O elements.
void createWaveform (const QString &fileName)
 Initializes the waveform from fileName if it matches the current circuit.
bool exportToPng (const QString &filename)
 Exports the waveform scene to a PNG image file.
int inputRow (const QString &label) const
 Returns the input row index whose element label equals label, or -1 (MCP access).
QToolBar * mainToolBar () const
 Returns the main toolbar (for tour target resolution).
void prepare (const QString &fileName={})
 Prepares the waveform from fileName (or blank if empty).
void print ()
 Prints the waveform table to the system printer.
void run ()
 Runs the simulation for all input combinations and fills output rows.
void saveToTxt (QTextStream &stream)
 Exports the waveform data as plain text to stream.
void setCellValue (const int row, const int col, const int value)
 Sets a single cell value in the waveform table.
void setExerciseOverlay (ExerciseOverlay *overlay)
void setLength (const int simLength, const bool runSimulation=false)
 Sets the number of time-step columns.
void show ()
 Shows the window and loads the initial waveform.
QTableView * signalTableView () const
 Returns the waveform table view (for tour target resolution).
WaveformSnapshot snapshot (int duration) const
 Returns the input/output signals over the first duration columns (MCP access).
void triggerCombinational ()
 Triggers the combinational input-pattern generator (for tour automation).
 ~BewavedDolphin () override

Protected Member Functions

void closeEvent (QCloseEvent *event) override
bool eventFilter (QObject *watched, QEvent *event) override
void resizeEvent (QResizeEvent *event) override

Friends

class TestBewavedDolphinGui

Detailed Description

Waveform editor main window for creating and analyzing digital signal sequences.

BewavedDolphin displays a table where rows represent circuit I/O signals and columns represent simulation time steps. Users can set input values and then run the associated wiRedPanda circuit to observe output responses. The waveform can be saved to a .dolphin file, printed, or exported to PDF/PNG.

A subset of methods is also accessible via the MCP server for automated testing.

Definition at line 42 of file BeWavedDolphin.h.

Constructor & Destructor Documentation

◆ BewavedDolphin()

BewavedDolphin::BewavedDolphin ( Scene * scene,
const bool askConnection = true,
DolphinHost * host = nullptr,
QWidget * parent = nullptr )
explicit

Constructs the waveform editor.

Parameters
sceneCircuit scene whose I/O elements will be mapped to signals.
askConnectionIf true, closing prompts to save unsaved changes (checkSave()).
hostHost application providing the circuit file context (a MainWindow in the app; a stub in tests). May be nullptr.
parentWidget to parent this window to, so its Qt::WindowModal setting (see the constructor body) actually blocks it — separate from host since tests pass a non-QWidget stub host. May be nullptr.

Definition at line 41 of file BeWavedDolphin.cpp.

References Settings::dolphinGeometry(), and Settings::labelsUnderIcons().

◆ ~BewavedDolphin()

BewavedDolphin::~BewavedDolphin ( )
override

Definition at line 116 of file BeWavedDolphin.cpp.

References Settings::setDolphinGeometry().

Member Function Documentation

◆ actionCombinational()

QAction * BewavedDolphin::actionCombinational ( ) const

Returns the combinational action (for tour button spotlighting).

Definition at line 373 of file BeWavedDolphin.cpp.

◆ closeEvent()

void BewavedDolphin::closeEvent ( QCloseEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 343 of file BeWavedDolphin.cpp.

◆ createWaveform() [1/2]

void BewavedDolphin::createWaveform ( )

Initializes a blank waveform from the current scene's I/O elements.

Definition at line 155 of file BeWavedDolphin.cpp.

References prepare().

Referenced by ExportController::exportToWaveFormFile(), and ExportController::exportToWaveFormTerminal().

◆ createWaveform() [2/2]

void BewavedDolphin::createWaveform ( const QString & fileName)

Initializes the waveform from fileName if it matches the current circuit.

Parameters
fileNamePath to an existing .dolphin file.

Definition at line 121 of file BeWavedDolphin.cpp.

References prepare(), qCDebug, and run().

◆ eventFilter()

bool BewavedDolphin::eventFilter ( QObject * watched,
QEvent * event )
overrideprotected
Reimplemented from base class. Intercepts the mouse wheel on the table viewport to zoom the columns.

Definition at line 311 of file BeWavedDolphin.cpp.

◆ exportToPng()

bool BewavedDolphin::exportToPng ( const QString & filename)

Exports the waveform scene to a PNG image file.

Parameters
filenameOutput file path.
Returns
true on success.

Definition at line 517 of file BeWavedDolphin.cpp.

References DolphinExporter::exportToPng().

◆ inputRow()

int BewavedDolphin::inputRow ( const QString & label) const

Returns the input row index whose element label equals label, or -1 (MCP access).

Definition at line 413 of file BeWavedDolphin.cpp.

◆ mainToolBar()

QToolBar * BewavedDolphin::mainToolBar ( ) const

Returns the main toolbar (for tour target resolution).

Definition at line 368 of file BeWavedDolphin.cpp.

◆ prepare()

void BewavedDolphin::prepare ( const QString & fileName = {})

Prepares the waveform from fileName (or blank if empty).

Parameters
fileNameOptional .dolphin file to load.

Definition at line 170 of file BeWavedDolphin.cpp.

References DolphinModelBuilder::collect(), and qCDebug.

Referenced by createWaveform(), and createWaveform().

◆ print()

void BewavedDolphin::print ( )

Prints the waveform table to the system printer.

Definition at line 459 of file BeWavedDolphin.cpp.

References DolphinExporter::csvText().

Referenced by ExportController::exportToWaveFormFile(), and ExportController::exportToWaveFormTerminal().

◆ resizeEvent()

void BewavedDolphin::resizeEvent ( QResizeEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 355 of file BeWavedDolphin.cpp.

◆ run()

void BewavedDolphin::run ( )

Runs the simulation for all input combinations and fills output rows.

Definition at line 278 of file BeWavedDolphin.cpp.

References qCDebug, and WaveformSimulator::restoreInputs().

Referenced by createWaveform(), and setLength().

◆ saveToTxt()

void BewavedDolphin::saveToTxt ( QTextStream & stream)

Exports the waveform data as plain text to stream.

Parameters
streamDestination text stream.

Definition at line 469 of file BeWavedDolphin.cpp.

References DolphinEdits::combinational(), SignalModel::kMaxColumns, PANDACEPTION, WaveformSimulator::restoreInputs(), SignalModel::setValue(), SignalModel::value(), and DolphinExporter::writeTruthTableText().

◆ setCellValue()

void BewavedDolphin::setCellValue ( const int row,
const int col,
const int value )

Sets a single cell value in the waveform table.

Parameters
rowSignal row index.
colTime-step column index.
valueLogical value (0 or 1).

Definition at line 406 of file BeWavedDolphin.cpp.

◆ setExerciseOverlay()

void BewavedDolphin::setExerciseOverlay ( ExerciseOverlay * overlay)

Registers overlay so it is repositioned whenever the window is resized. Pass nullptr to detach. Does not take ownership.

Definition at line 363 of file BeWavedDolphin.cpp.

◆ setLength()

void BewavedDolphin::setLength ( const int simLength,
const bool runSimulation = false )

Sets the number of time-step columns.

Parameters
simLengthNumber of columns.
runSimulationIf true, immediately re-runs the simulation.

Definition at line 667 of file BeWavedDolphin.cpp.

References DolphinEdits::growInputColumns(), qCDebug, and run().

◆ show()

void BewavedDolphin::show ( )

Shows the window and loads the initial waveform.

Definition at line 453 of file BeWavedDolphin.cpp.

◆ signalTableView()

QTableView * BewavedDolphin::signalTableView ( ) const
inline

Returns the waveform table view (for tour target resolution).

Definition at line 141 of file BeWavedDolphin.h.

◆ snapshot()

BewavedDolphin::WaveformSnapshot BewavedDolphin::snapshot ( int duration) const

Returns the input/output signals over the first duration columns (MCP access).

Definition at line 424 of file BeWavedDolphin.cpp.

References BewavedDolphin::WaveformSnapshot::inputs, BewavedDolphin::Signal::label, BewavedDolphin::WaveformSnapshot::outputs, and BewavedDolphin::Signal::values.

◆ triggerCombinational()

void BewavedDolphin::triggerCombinational ( )

Triggers the combinational input-pattern generator (for tour automation).

Definition at line 378 of file BeWavedDolphin.cpp.

◆ TestBewavedDolphinGui

friend class TestBewavedDolphinGui
friend

Definition at line 45 of file BeWavedDolphin.h.

References TestBewavedDolphinGui.

Referenced by TestBewavedDolphinGui.


The documentation for this class was generated from the following files: