Cadabra
Computer algebra system for field theory problems
Classes | Public Types | Public Member Functions | Public Attributes | Private Attributes | List of all members
cadabra::DataCell Class Reference

Description

DataCells are the basic building blocks for a document.

They represent visual units in the notebook interface. They are stored in a tree inside the client, and can be transmitted over the wire between server and client in JSON format (see the documentation of the cadabra::JSON_serialise and cadabra::JSON_deserialise methods below for details on this representation). The notebook user interface reads these cells and construct corresponding graphical output for them.

The cadabra.display method of the cadabra python library knows how to turn various Python objects into the corresponding JSON representation of a DataCell.

#include <DataCell.hh>

Classes

class  id_t
 Each cell is identified by a serial number 'id' which is used to keep track of it across network calls, and a bool indicating whether the client or the server has created this cell. More...
 

Public Types

enum class  CellType {
  document , python , latex , output ,
  verbatim , latex_view , input_form , image_png ,
  error
}
 Cells are labelled with the data type of its contents, which is stored in a textural representation but may need processing for proper display. More...
 

Public Member Functions

 DataCell (CellType t=CellType::python, const std::string &str="", bool hidden=false)
 Standard constructor, generates a new unique id for this DataCell. More...
 
 DataCell (id_t, CellType t=CellType::python, const std::string &str="", bool hidden=false)
 Initialise a cell with an already determined id (it is the caller's responsibility to ensure that this id does not clash with any other DataCell's id). More...
 
 DataCell (const DataCell &)
 Copy constructor; preserves all information including id. More...
 
id_t id () const
 

Public Attributes

CellType cell_type
 
std::string textbuf
 Textual representation of the cell content. More...
 
bool hidden
 Flag indicating whether this cell should be hidden from view. More...
 
bool sensitive
 
bool ignore_on_import
 Flag indicating whether this cell should be ignored in case the notebook is imported. More...
 
bool running
 Indicator whether this cell is currently being evaluated by the server. More...
 

Private Attributes

id_t serial_number
 

Member Enumeration Documentation

◆ CellType

Cells are labelled with the data type of its contents, which is stored in a textural representation but may need processing for proper display.

Enumerator
document 

head node, only one per document

python 

input : editor cell for code in python

latex 

input : editor cell for code in latex

output 

output: cell showing python stdout, verbatim

verbatim 

output: cell showing other verbatim output

latex_view 

output: cell showing LaTeX text formatted using LaTeX

input_form 

output: cell containing input form of preceding output cell

image_png 

output: cell showing a base64 encoded PNG image

error 

output: cell showing LaTeX text for errors

Constructor & Destructor Documentation

◆ DataCell() [1/3]

DataCell::DataCell ( CellType  t = CellType::python,
const std::string &  str = "",
bool  hidden = false 
)

Standard constructor, generates a new unique id for this DataCell.

◆ DataCell() [2/3]

DataCell::DataCell ( id_t  id_,
CellType  t = CellType::python,
const std::string &  str = "",
bool  hidden = false 
)

Initialise a cell with an already determined id (it is the caller's responsibility to ensure that this id does not clash with any other DataCell's id).

◆ DataCell() [3/3]

DataCell::DataCell ( const DataCell other)

Copy constructor; preserves all information including id.

Member Function Documentation

◆ id()

DataCell::id_t DataCell::id ( ) const

Member Data Documentation

◆ cell_type

CellType cadabra::DataCell::cell_type

◆ hidden

bool cadabra::DataCell::hidden

Flag indicating whether this cell should be hidden from view.

The GUI should have a way to bring the cells back into view, typically by clicking on the output cell corresponding to the input cell.

◆ ignore_on_import

bool cadabra::DataCell::ignore_on_import

Flag indicating whether this cell should be ignored in case the notebook is imported.

Essentially the equivalent of if __name__=="__main__".

◆ running

bool cadabra::DataCell::running

Indicator whether this cell is currently being evaluated by the server.

Currently only has a meaning for cells of type 'python'. This flag is set/reset using the ActionSetRunStatus action.

◆ sensitive

bool cadabra::DataCell::sensitive

◆ serial_number

id_t cadabra::DataCell::serial_number
private

◆ textbuf

std::string cadabra::DataCell::textbuf

Textual representation of the cell content.

For e.g. latex cells it is a bit of a waste to store this representation both in the input and in the output cell. However, this gives us the flexibility to do manipulations on the input (e.g. resolving equation references) before feeding it to LaTeX.


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