Cadabra
Computer algebra system for field theory problems
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
cadabra::NotebookWindow Class Reference

Description

Each notebook has one main window which controls it.

It has a menu bar, a status pane and one or more panels that represent a view on the document.

#include <NotebookWindow.hh>

Inheritance diagram for cadabra::NotebookWindow:
cadabra::DocumentThread cadabra::GUIBase

Classes

class  Prefs
 

Public Member Functions

 NotebookWindow (Cadabra *, bool read_only=false)
 
 ~NotebookWindow ()
 
virtual void add_cell (const DTree &, DTree::iterator, bool) override
 Add a GUI cell corresponding to the document cell at the iterator. More...
 
virtual void remove_cell (const DTree &, DTree::iterator) override
 Remove a single cell. More...
 
virtual void remove_all_cells () override
 Remove all GUI cells from the display (used as a quick way to clear all before loading a new document). More...
 
virtual void update_cell (const DTree &, DTree::iterator) override
 The basic manipulations that a GUI needs to implement are adding, removing and updating (refreshing the display of) a cell. More...
 
virtual void position_cursor (const DTree &, DTree::iterator, int pos) override
 Position the cursor in the current canvas in the widget corresponding to the indicated cell. More...
 
virtual size_t get_cursor_position (const DTree &, DTree::iterator) override
 Retrieve the position of the cursor in the current cell. More...
 
virtual void on_connect () override
 Network status is propagated from the ComputeThread to the. More...
 
virtual void on_disconnect (const std::string &) override
 
virtual void on_network_error () override
 
virtual void on_kernel_runstatus (bool) override
 
virtual void process_data () override
 When the ComputeThread needs to modify the document, it stores an ActionBase object on the stack (see the DocumenThread class) and then wakes up the GUI thread signalling it to process this action. More...
 
bool on_vscroll_changed (Gtk::ScrollType, double)
 
bool on_scroll (GdkEventScroll *)
 
void on_scroll_size_allocate (Gtk::Allocation &)
 
void scroll_current_cell_into_view ()
 
void set_name (const std::string &)
 
void set_title_prefix (const std::string &)
 
void load_file (const std::string &notebook_contents)
 
- Public Member Functions inherited from cadabra::DocumentThread
 DocumentThread (GUIBase *)
 
 DocumentThread (const DocumentThread &)=delete
 It is not possible to copy-construct a DocumentThread as it holds on to resources which are not easily copied (such as GUI elements). More...
 
void set_compute_thread (ComputeThread *)
 Let the notebook know about the ComputeThread so that it can send cells for evaluation. More...
 
void build_visual_representation ()
 Ensure that the gui has an up-to-date representation of the dtree. More...
 
void queue_action (std::shared_ptr< ActionBase >)
 All changes to the document should be made by submitting ActionBase derived objects to the 'queue_action' function, so that an undo stack can be kept. More...
 
void new_document ()
 Setup an empty new document with a single Python input cell. More...
 
void load_from_string (const std::string &)
 Load a new notebook from a JSON string. More...
 
void undo ()
 One undo step. More...
 
bool is_registered () const
 Determine if a user has been registered with the Cadabra log server. More...
 
void set_user_details (const std::string &name, const std::string &email, const std::string &affiliation)
 Set user details which will be sent to the Cadabra log server. More...
 

Public Attributes

TeXEngine engine
 
double scale
 
- Public Attributes inherited from cadabra::DocumentThread
friend ActionBase
 
friend ActionAddCell
 
friend ActionPositionCursor
 
friend ActionRemoveCell
 
friend ActionSplitCell
 
friend ActionSetRunStatus
 
friend ActionInsertText
 
friend ActionEraseText
 

Protected Member Functions

virtual bool on_key_press_event (GdkEventKey *) override
 
virtual bool on_delete_event (GdkEventAny *) override
 
virtual bool on_configure_event (GdkEventConfigure *cfg) override
 
bool handle_outbox_select (GdkEventButton *, DTree::iterator it)
 
void unselect_output_cell ()
 
void on_outbox_copy (Glib::RefPtr< Gtk::Clipboard > refClipboard, DTree::iterator it)
 
- Protected Member Functions inherited from cadabra::DocumentThread
void process_action_queue ()
 Process the action queue. More...
 
bool help_type_and_topic (const std::string &before, const std::string &after, help_t &help_type, std::string &help_topic) const
 

Protected Attributes

DTree::iterator current_cell
 
DTree::iterator selected_cell
 
- Protected Attributes inherited from cadabra::DocumentThread
GUIBasegui
 
ComputeThreadcompute
 
DTree doc
 The actual document tree. More...
 
std::mutex stack_mutex
 The action undo/redo/todo stacks and logic to execute. More...
 
ActionStack undo_stack
 
ActionStack redo_stack
 
std::queue< std::shared_ptr
< ActionBase > > 
pending_actions
 
bool disable_stacks
 
bool registered
 Configuration options read from ~/.config/cadabra.conf. More...
 

Private Member Functions

void update_title ()
 
void set_stop_sensitive (bool)
 
void on_file_new ()
 
void on_file_open ()
 
void on_file_close ()
 
void on_file_save ()
 
void on_file_save_as ()
 
void on_file_export_html ()
 
void on_file_export_html_segment ()
 
void on_file_export_latex ()
 
void on_file_export_python ()
 
void on_file_quit ()
 
bool quit_safeguard (bool quit)
 
void on_edit_undo ()
 
void on_edit_copy ()
 
void on_edit_paste ()
 
void on_edit_insert_above ()
 
void on_edit_insert_below ()
 
void on_edit_delete ()
 
void on_edit_split ()
 
void on_edit_cell_is_latex ()
 
void on_edit_cell_is_python ()
 
void on_view_split ()
 
void on_view_close ()
 
void on_run_cell ()
 
void on_run_runall ()
 
void on_run_runtocursor ()
 
void on_run_stop ()
 
void on_prefs_font_size (int num)
 
void on_help_about ()
 
void on_help () const
 
void on_kernel_restart ()
 
void on_clipboard_get (Gtk::SelectionData &, guint info)
 Clipboard handling. More...
 
void on_clipboard_clear ()
 
std::string save (const std::string &fn) const
 
void process_todo_queue ()
 
void on_crash_window_closed (int)
 
bool cell_got_focus (DTree::iterator, int)
 
bool cell_toggle_visibility (DTree::iterator it, int)
 
bool cell_content_insert (const std::string &, int, DTree::iterator, int)
 
bool cell_content_erase (int, int, DTree::iterator, int)
 
bool cell_content_execute (DTree::iterator, int, bool shift_enter_pressed)
 
bool cell_content_changed (const std::string &content, DTree::iterator it, int canvas_number)
 
void dim_output_cells (DTree::iterator it)
 
bool on_tex_error (const std::string &, DTree::iterator)
 
void setup_css_provider ()
 
void on_text_scaling_factor_changed (const std::string &key)
 
bool idle_handler ()
 

Private Attributes

Cadabracdbapp
 
Glib::Dispatcher dispatcher
 
Glib::RefPtr< Gtk::ActionGroup > actiongroup
 
Glib::RefPtr< Gtk::UIManager > uimanager
 
Gtk::VBox topbox
 
Gtk::HBox supermainbox
 
Gtk::VBox mainbox
 
Gtk::HBox statusbarbox
 
std::vector< NotebookCanvas * > canvasses
 
int current_canvas
 
Gtk::ProgressBar progressbar
 
Gtk::Spinner kernel_spinner
 
bool kernel_spinner_status
 
Gtk::Label status_label
 
Gtk::Label kernel_label
 
std::mutex status_mutex
 
std::string status_string
 
std::string kernel_string
 
std::string name
 
std::string title_prefix
 
bool modified
 
bool read_only
 
Glib::RefPtr< Gtk::Action > action_copy
 
Glib::RefPtr< Gtk::Action > action_paste
 
std::string clipboard_txt
 
std::string clipboard_cdb
 
bool crash_window_hidden
 
Glib::RefPtr< Gtk::CssProvider > css_provider
 
Glib::RefPtr< Gio::Settings > settings
 
int last_configure_width
 
DTree::iterator follow_cell
 
Prefs prefs
 
bool is_configured
 

Additional Inherited Members

- Protected Types inherited from cadabra::DocumentThread
enum  help_t { help_t::algorithm, help_t::property, help_t::latex, help_t::none }
 Help system. More...
 
typedef std::stack
< std::shared_ptr< ActionBase > > 
ActionStack
 

Constructor & Destructor Documentation

NotebookWindow::NotebookWindow ( Cadabra c,
bool  read_only = false 
)
NotebookWindow::~NotebookWindow ( )

Member Function Documentation

void NotebookWindow::add_cell ( const DTree ,
DTree::iterator  ,
bool  visible 
)
overridevirtual

Add a GUI cell corresponding to the document cell at the iterator.

The GUI needs to figure out from the location of this cell in the DTree where to insert the cell in the visual display. If the 'visible' flag is false, hide the cell from view independent of whether its hidden flag is set (this is only used when constructing a document on load time and we do not want to show cells until they have all been added to the document).

Implements cadabra::GUIBase.

bool NotebookWindow::cell_content_changed ( const std::string &  content,
DTree::iterator  it,
int  canvas_number 
)
private
bool NotebookWindow::cell_content_erase ( int  start,
int  end,
DTree::iterator  it,
int  canvas_number 
)
private
bool NotebookWindow::cell_content_execute ( DTree::iterator  it,
int  canvas_number,
bool  shift_enter_pressed 
)
private
bool NotebookWindow::cell_content_insert ( const std::string &  content,
int  pos,
DTree::iterator  it,
int  canvas_number 
)
private
bool NotebookWindow::cell_got_focus ( DTree::iterator  it,
int  canvas_number 
)
private
bool NotebookWindow::cell_toggle_visibility ( DTree::iterator  it,
int  canvas_number 
)
private
void NotebookWindow::dim_output_cells ( DTree::iterator  it)
private
size_t NotebookWindow::get_cursor_position ( const DTree ,
DTree::iterator   
)
overridevirtual

Retrieve the position of the cursor in the current cell.

Implements cadabra::GUIBase.

bool NotebookWindow::handle_outbox_select ( GdkEventButton *  ,
DTree::iterator  it 
)
protected
bool NotebookWindow::idle_handler ( )
private
void NotebookWindow::load_file ( const std::string &  notebook_contents)
void NotebookWindow::on_clipboard_clear ( )
private
void NotebookWindow::on_clipboard_get ( Gtk::SelectionData &  selection_data,
guint  info 
)
private

Clipboard handling.

bool NotebookWindow::on_configure_event ( GdkEventConfigure *  cfg)
overrideprotectedvirtual
void NotebookWindow::on_connect ( )
overridevirtual

Network status is propagated from the ComputeThread to the.

GUI using the following methods. These get called on the compute thread (as opposed to the functions above, which get called on the gui thread).

Implements cadabra::GUIBase.

void NotebookWindow::on_crash_window_closed ( int  )
private
bool NotebookWindow::on_delete_event ( GdkEventAny *  event)
overrideprotectedvirtual
void NotebookWindow::on_disconnect ( const std::string &  reason)
overridevirtual

Implements cadabra::GUIBase.

void NotebookWindow::on_edit_cell_is_latex ( )
private
void NotebookWindow::on_edit_cell_is_python ( )
private
void NotebookWindow::on_edit_copy ( )
private
void NotebookWindow::on_edit_delete ( )
private
void NotebookWindow::on_edit_insert_above ( )
private
void NotebookWindow::on_edit_insert_below ( )
private
void NotebookWindow::on_edit_paste ( )
private
void NotebookWindow::on_edit_split ( )
private
void NotebookWindow::on_edit_undo ( )
private
void NotebookWindow::on_file_close ( )
private
void NotebookWindow::on_file_export_html ( )
private
void NotebookWindow::on_file_export_html_segment ( )
private
void NotebookWindow::on_file_export_latex ( )
private
void NotebookWindow::on_file_export_python ( )
private
void NotebookWindow::on_file_new ( )
private
void NotebookWindow::on_file_open ( )
private
void NotebookWindow::on_file_quit ( )
private
void NotebookWindow::on_file_save ( )
private
void NotebookWindow::on_file_save_as ( )
private
void NotebookWindow::on_help ( ) const
private
void NotebookWindow::on_help_about ( )
private
void NotebookWindow::on_kernel_restart ( )
private
void NotebookWindow::on_kernel_runstatus ( bool  running)
overridevirtual

Implements cadabra::GUIBase.

bool NotebookWindow::on_key_press_event ( GdkEventKey *  event)
overrideprotectedvirtual
void NotebookWindow::on_network_error ( )
overridevirtual

Implements cadabra::GUIBase.

void NotebookWindow::on_outbox_copy ( Glib::RefPtr< Gtk::Clipboard >  refClipboard,
DTree::iterator  it 
)
protected
void NotebookWindow::on_prefs_font_size ( int  num)
private
void NotebookWindow::on_run_cell ( )
private
void NotebookWindow::on_run_runall ( )
private
void NotebookWindow::on_run_runtocursor ( )
private
void NotebookWindow::on_run_stop ( )
private
bool NotebookWindow::on_scroll ( GdkEventScroll *  s)
void NotebookWindow::on_scroll_size_allocate ( Gtk::Allocation &  scroll_alloc)
bool NotebookWindow::on_tex_error ( const std::string &  str,
DTree::iterator  it 
)
private
void NotebookWindow::on_text_scaling_factor_changed ( const std::string &  key)
private
void NotebookWindow::on_view_close ( )
private
void NotebookWindow::on_view_split ( )
private
bool NotebookWindow::on_vscroll_changed ( Gtk::ScrollType  st,
double  v 
)
void NotebookWindow::position_cursor ( const DTree ,
DTree::iterator  ,
int   
)
overridevirtual

Position the cursor in the current canvas in the widget corresponding to the indicated cell.

Implements cadabra::GUIBase.

void NotebookWindow::process_data ( )
overridevirtual

When the ComputeThread needs to modify the document, it stores an ActionBase object on the stack (see the DocumenThread class) and then wakes up the GUI thread signalling it to process this action.

The following member should wake up the GUI thread and make it enter the processing part.

Implements cadabra::GUIBase.

void NotebookWindow::process_todo_queue ( )
private
bool NotebookWindow::quit_safeguard ( bool  quit)
private
void NotebookWindow::remove_all_cells ( )
overridevirtual

Remove all GUI cells from the display (used as a quick way to clear all before loading a new document).

Implements cadabra::GUIBase.

void NotebookWindow::remove_cell ( const DTree ,
DTree::iterator   
)
overridevirtual

Remove a single cell.

Implements cadabra::GUIBase.

std::string NotebookWindow::save ( const std::string &  fn) const
private
void NotebookWindow::scroll_current_cell_into_view ( )
void NotebookWindow::set_name ( const std::string &  n)
void NotebookWindow::set_stop_sensitive ( bool  s)
private
void NotebookWindow::set_title_prefix ( const std::string &  pf)
void cadabra::NotebookWindow::setup_css_provider ( )
private
void NotebookWindow::unselect_output_cell ( )
protected
void NotebookWindow::update_cell ( const DTree ,
DTree::iterator   
)
overridevirtual

The basic manipulations that a GUI needs to implement are adding, removing and updating (refreshing the display of) a cell.

The code in DocumentThread will call these to make the GUI update its display. Called on the document thread.

Implements cadabra::GUIBase.

void NotebookWindow::update_title ( )
private

Member Data Documentation

Glib::RefPtr<Gtk::Action> cadabra::NotebookWindow::action_copy
private
Glib::RefPtr<Gtk::Action> cadabra::NotebookWindow::action_paste
private
Glib::RefPtr<Gtk::ActionGroup> cadabra::NotebookWindow::actiongroup
private
std::vector<NotebookCanvas *> cadabra::NotebookWindow::canvasses
private
Cadabra* cadabra::NotebookWindow::cdbapp
private
std::string cadabra::NotebookWindow::clipboard_cdb
private
std::string cadabra::NotebookWindow::clipboard_txt
private
bool cadabra::NotebookWindow::crash_window_hidden
private
Glib::RefPtr<Gtk::CssProvider> cadabra::NotebookWindow::css_provider
private
int cadabra::NotebookWindow::current_canvas
private
DTree::iterator cadabra::NotebookWindow::current_cell
protected
Glib::Dispatcher cadabra::NotebookWindow::dispatcher
private
TeXEngine cadabra::NotebookWindow::engine
DTree::iterator cadabra::NotebookWindow::follow_cell
private
bool cadabra::NotebookWindow::is_configured
private
Gtk::Label cadabra::NotebookWindow::kernel_label
private
Gtk::Spinner cadabra::NotebookWindow::kernel_spinner
private
bool cadabra::NotebookWindow::kernel_spinner_status
private
std::string cadabra::NotebookWindow::kernel_string
private
int cadabra::NotebookWindow::last_configure_width
private
Gtk::VBox cadabra::NotebookWindow::mainbox
private
bool cadabra::NotebookWindow::modified
private
std::string cadabra::NotebookWindow::name
private
Prefs cadabra::NotebookWindow::prefs
private
Gtk::ProgressBar cadabra::NotebookWindow::progressbar
private
bool cadabra::NotebookWindow::read_only
private
double cadabra::NotebookWindow::scale
DTree::iterator cadabra::NotebookWindow::selected_cell
protected
Glib::RefPtr<Gio::Settings> cadabra::NotebookWindow::settings
private
Gtk::Label cadabra::NotebookWindow::status_label
private
std::mutex cadabra::NotebookWindow::status_mutex
private
std::string cadabra::NotebookWindow::status_string
private
Gtk::HBox cadabra::NotebookWindow::statusbarbox
private
Gtk::HBox cadabra::NotebookWindow::supermainbox
private
std::string cadabra::NotebookWindow::title_prefix
private
Gtk::VBox cadabra::NotebookWindow::topbox
private
Glib::RefPtr<Gtk::UIManager> cadabra::NotebookWindow::uimanager
private

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