PyCanvas Class Reference

#include <PyCanvas.h>

Collaboration diagram for PyCanvas:

Collaboration graph
CanvasViewProxyQObjectCanvasViewCanvasWindowPlotTableFigureEditorQStringInspectorXmlControllerViewBaseXMLHiNTupleXMLDataRepXMLTupleCutXMLQtFileDialogQCanvasRectangleXmlElementXmlDocumentViewFactoryQFileDialogQWidgetCanvasWindowBaseQMainWindowQActionGroupQMenuBarQPopupMenuQPixmapPlotTableBaseQActionQToolBar
[legend]
List of all members.

Detailed Description

This class is the public interface the what the user sees as the canvas object from Python.

Requests:
Be able to retrieve, from Python, information on active displays on the canvas such as a display identifier, axis labels, etc ...
Requests:
@@ Add interface to re-tile.
Requests:
@@ Get a Display by its plotter id.
Author:
James Chiang <jchiang@slac.stanford.edu>

Paul F. Kunz <Paul_Kunz@slac.stanford.edu>

Definition at line 43 of file PyCanvas.h.

Public Member Functions

void addDisplay (QtDisplay *display_wrap)
 Adds the display to the canvas.
void addText (QtDisplay *display, const std::string &text)
 Add a BoxTextRep.
void addTextAt (QtDisplay *display, const std::string &text, double xrel, double yrel)
 Add a BoxTextRep at a specific location in the selected display item's canvas coordinate system.
void addTextAtAbs (QtDisplay *display, const std::string &text, double xabs, double yabs)
 Add a BoxTextRep at a specific location in the selected display item's canvas coordinate system.
void addTextRep (QtDisplay *display, const std::string &type)
 Adds a textual data representation to display or type type.
void clear ()
 Removes all items from the CanvasWindow.
void close ()
 Closes the canvas window.
QtCutgetCut ()
 Returns a QtCut object or null pointer if its not a QtCut object.
QtDisplaygetDisplay ()
 Returns the selected display on the canvas.
const std::vector< QtDisplay * > & getDisplays () const
 Returns all displays on the canvas.
int getHeight (QtDisplay *display) const
 Returns the view's height for the display.
NTuplegetPickTable (QtDisplay *)
 Gets the PickTable for the display.
NTuplegetSelPickTable ()
 Gets the PickTable of selected display as a NTuple.
const std::vector< std::string > & getTextRepTypes () const
 Returns the types of textual data representations available.
int getWidth (QtDisplay *display) const
 Returns the view's width for the display.
int getX (QtDisplay *display) const
 Returns the view's X coordinate for the display.
int getY (QtDisplay *display) const
 Returns the view's Y coordinate for the display.
const std::vector< double > & mouseData ()
 Retrieve a tuple of (x, y, z) points from the next mouse event.
void print (const std::string &filename)
 Prints the canvas to a PostScript file.
 PyCanvas ()
 The default constructor.
 PyCanvas (CanvasWindow *)
 A constructor taking as argument the real canvas used by this object.
void removeDisplay (QtDisplay *display)
 Remove a display.
void saveAs (const std::string &filename)
 Saves the document to the specified file.
void saveAsImage (QtDisplay *display, const std::string &filename)
 Save the display as an image file.
void saveSelectedImages (const std::string &filename)
 Save the selected images as an image file.
void selectAllDisplays (bool flag=true)
 Select or un-select all the displays on the canvas.
void selectDisplay (QtDisplay *display)
 Select a specific display.
void setHeight (QtDisplay *, double h)
 Sets the height of the view for the display.
void setPlotMatrix (unsigned int columns, unsigned int rows)
 Sets the number for columns and rows of plots on each page.
void setWidth (QtDisplay *, double w)
 Sets the width of the view for the display.
void setX (QtDisplay *display, double value)
 Sets the view's X coordinate for the display.
void setY (QtDisplay *display, double value)
 Sets the view's Y coordinate for the display.
void show ()
 Displays the canvas window on the screen.
void swapOrientation ()
 Swaps the orientation from portrait to landscape and vice verse.

Private Member Functions

void check () const
 Checks if the CanvasWindow has been closed and throws a runtime_error if it has been.
QtViewfindSelectedView (QtDisplay *display)
 Return the QtView associated with the given QtDisplay.

Private Attributes

CanvasWindowm_canvas
 The actual canvas window in the application thread.
CanvasViewProxym_canvas_proxy
 The proxy for the CanvasView object.
std::vector< QtDisplay * > m_displays
 Pointers to QtDisplay objects on the current canvas.
bool m_has_gui
 Set to true if this canvas as associated GUI CanvasWindow.


Constructor & Destructor Documentation

PyCanvas ( CanvasWindow  ) 

A constructor taking as argument the real canvas used by this object.

Definition at line 45 of file PyCanvas.cxx.

References PyCanvas::m_canvas, and PyCanvas::m_canvas_proxy.

PyCanvas (  ) 

The default constructor.

Definition at line 57 of file PyCanvas.cxx.

References PyApp::lock(), PyCanvas::m_canvas, PyCanvas::m_canvas_proxy, and PyApp::unlock().


Member Function Documentation

void addDisplay ( QtDisplay display_wrap  ) 

Adds the display to the canvas.

Bug:
@ why is variable yes ignored?

Definition at line 106 of file PyCanvas.cxx.

References PyCanvas::check(), QtDisplay::display(), PyApp::hasPendingEvents(), PyCanvas::m_canvas_proxy, PyCanvas::m_displays, and PyCanvas::m_has_gui.

Referenced by hippodraw::Python::export_Canvas().

void addText ( QtDisplay display,
const std::string &  text 
)

Add a BoxTextRep.

Definition at line 322 of file PyCanvas.cxx.

References CanvasWindow::addTextDisplay(), PyCanvas::check(), QtDisplay::display(), PyApp::lock(), PyCanvas::m_canvas, PlotterBase::setActivePlot(), and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

void addTextAt ( QtDisplay display,
const std::string &  text,
double  xrel,
double  yrel 
)

Add a BoxTextRep at a specific location in the selected display item's canvas coordinate system.

Definition at line 342 of file PyCanvas.cxx.

References CanvasWindow::addTextDisplayAt(), PyCanvas::check(), QtDisplay::display(), PyApp::lock(), PyCanvas::m_canvas, PlotterBase::setActivePlot(), and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

void addTextAtAbs ( QtDisplay display,
const std::string &  text,
double  xabs,
double  yabs 
)

Add a BoxTextRep at a specific location in the selected display item's canvas coordinate system.

Definition at line 362 of file PyCanvas.cxx.

References CanvasWindow::addTextDisplayAt(), PyCanvas::check(), QtDisplay::display(), PlotterBase::getTransform(), Range::high(), PyApp::lock(), Range::low(), PyCanvas::m_canvas, PlotterBase::setActivePlot(), BinaryTransform::transform(), PyApp::unlock(), hippodraw::Axes::X, and hippodraw::Axes::Y.

Referenced by hippodraw::Python::export_Canvas().

void addTextRep ( QtDisplay display,
const std::string &  type 
)

Adds a textual data representation to display or type type.

Definition at line 283 of file PyCanvas.cxx.

References PyCanvas::check(), FunctionController::instance(), PyApp::lock(), PyCanvas::m_canvas, and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

void check (  )  const [private]

Checks if the CanvasWindow has been closed and throws a runtime_error if it has been.

Definition at line 73 of file PyCanvas.cxx.

References PyCanvas::m_canvas.

Referenced by PyCanvas::addDisplay(), PyCanvas::addText(), PyCanvas::addTextAt(), PyCanvas::addTextAtAbs(), PyCanvas::addTextRep(), PyCanvas::clear(), PyCanvas::findSelectedView(), PyCanvas::getCut(), PyCanvas::getDisplay(), PyCanvas::getDisplays(), PyCanvas::getHeight(), PyCanvas::getPickTable(), PyCanvas::getSelPickTable(), PyCanvas::getTextRepTypes(), PyCanvas::getWidth(), PyCanvas::getX(), PyCanvas::getY(), PyCanvas::mouseData(), PyCanvas::print(), PyCanvas::removeDisplay(), PyCanvas::saveAs(), PyCanvas::saveSelectedImages(), PyCanvas::selectAllDisplays(), PyCanvas::selectDisplay(), PyCanvas::setHeight(), PyCanvas::setPlotMatrix(), PyCanvas::setWidth(), PyCanvas::setX(), PyCanvas::setY(), PyCanvas::show(), and PyCanvas::swapOrientation().

void clear (  ) 

Removes all items from the CanvasWindow.

Bug:
Even thou clear() passes, it is possible that the window has already been closed, like when the application has terminated.

Definition at line 443 of file PyCanvas.cxx.

References PyCanvas::check(), and PyCanvas::m_canvas_proxy.

Referenced by hippodraw::Python::export_Canvas().

void close (  ) 

Closes the canvas window.

Definition at line 94 of file PyCanvas.cxx.

References PyApp::lock(), PyCanvas::m_canvas, and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

QtView * findSelectedView ( QtDisplay display  )  [private]

Return the QtView associated with the given QtDisplay.

Definition at line 266 of file PyCanvas.cxx.

References PyCanvas::check(), QtDisplay::display(), and PyCanvas::m_canvas.

Referenced by PyCanvas::saveAsImage(), and PyCanvas::selectDisplay().

QtCut * getCut (  ) 

Returns a QtCut object or null pointer if its not a QtCut object.

Definition at line 182 of file PyCanvas.cxx.

References PyCanvas::check(), PyCanvas::m_canvas, and CanvasWindow::selectedPlotter().

Referenced by hippodraw::Python::export_Canvas().

QtDisplay * getDisplay (  ) 

Returns the selected display on the canvas.

If none or more than one display is selected, this routine returns a null pointer

Definition at line 142 of file PyCanvas.cxx.

References PyCanvas::check(), PyApp::lock(), PyCanvas::m_canvas, CanvasWindow::selectedPlotter(), and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

const std::vector< QtDisplay * > & getDisplays (  )  const

Returns all displays on the canvas.

Definition at line 160 of file PyCanvas.cxx.

References PyCanvas::check(), PyApp::lock(), PyCanvas::m_canvas, PyCanvas::m_displays, PyApp::unlock(), and CanvasWindow::views().

Referenced by hippodraw::Python::export_Canvas().

int getHeight ( QtDisplay display  )  const

Returns the view's height for the display.

Definition at line 452 of file PyCanvas.cxx.

References PyCanvas::check(), and PyCanvas::m_canvas.

Referenced by hippodraw::Python::export_Canvas().

NTuple * getPickTable ( QtDisplay  ) 

Gets the PickTable for the display.

Definition at line 581 of file PyCanvas.cxx.

References PyCanvas::check(), QtDisplay::display(), CanvasWindow::getPickTable(), PyApp::lock(), PyCanvas::m_canvas, and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

NTuple * getSelPickTable (  ) 

Gets the PickTable of selected display as a NTuple.

Definition at line 570 of file PyCanvas.cxx.

References PyCanvas::check(), CanvasWindow::getPickTable(), PyApp::lock(), PyCanvas::m_canvas, and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

const std::vector< std::string > & getTextRepTypes (  )  const

Returns the types of textual data representations available.

Definition at line 314 of file PyCanvas.cxx.

References PyCanvas::check(), and DisplayController::instance().

Referenced by hippodraw::Python::export_Canvas().

int getWidth ( QtDisplay display  )  const

Returns the view's width for the display.

Definition at line 466 of file PyCanvas.cxx.

References PyCanvas::check(), and PyCanvas::m_canvas.

Referenced by hippodraw::Python::export_Canvas().

int getX ( QtDisplay display  )  const

Returns the view's X coordinate for the display.

Definition at line 514 of file PyCanvas.cxx.

References PyCanvas::check(), and PyCanvas::m_canvas.

Referenced by hippodraw::Python::export_Canvas().

int getY ( QtDisplay display  )  const

Returns the view's Y coordinate for the display.

Definition at line 528 of file PyCanvas.cxx.

References PyCanvas::check(), and PyCanvas::m_canvas.

Referenced by hippodraw::Python::export_Canvas().

const std::vector< double > & mouseData (  ) 

Retrieve a tuple of (x, y, z) points from the next mouse event.

Definition at line 413 of file PyCanvas.cxx.

References PyCanvas::check(), PyCanvas::m_canvas, and CanvasWindow::mouseEventData().

Referenced by hippodraw::Python::export_Canvas().

void print ( const std::string &  filename  ) 

Prints the canvas to a PostScript file.

Definition at line 219 of file PyCanvas.cxx.

References PyCanvas::check(), PyApp::lock(), PyCanvas::m_canvas, and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

void removeDisplay ( QtDisplay display  ) 

Remove a display.

Definition at line 274 of file PyCanvas.cxx.

References PyCanvas::check(), QtDisplay::display(), PyCanvas::m_canvas, and CanvasWindow::removeDisplay().

Referenced by hippodraw::Python::export_Canvas().

void saveAs ( const std::string &  filename  ) 

Saves the document to the specified file.

Definition at line 120 of file PyCanvas.cxx.

References PyCanvas::check(), PyApp::lock(), PyCanvas::m_canvas, PyCanvas::m_displays, PyCanvas::m_has_gui, CanvasView::saveAs(), CanvasWindow::saveAs(), num_util::size(), and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

void saveAsImage ( QtDisplay display,
const std::string &  filename 
)

Save the display as an image file.

Definition at line 230 of file PyCanvas.cxx.

References PyCanvas::findSelectedView(), ViewBase::getPlotter(), PyCanvas::m_canvas_proxy, and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

void saveSelectedImages ( const std::string &  filename  ) 

Save the selected images as an image file.

Definition at line 250 of file PyCanvas.cxx.

References PyCanvas::check(), CanvasWindow::fileSaveSelectedImages(), PyApp::lock(), PyCanvas::m_canvas, and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

void selectAllDisplays ( bool  flag = true  ) 

Select or un-select all the displays on the canvas.

Definition at line 199 of file PyCanvas.cxx.

References PyCanvas::check(), PyApp::lock(), PyCanvas::m_canvas, and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

void selectDisplay ( QtDisplay display  ) 

Select a specific display.

Definition at line 207 of file PyCanvas.cxx.

References PyCanvas::check(), PyCanvas::findSelectedView(), PyApp::lock(), PyCanvas::m_canvas, CanvasWindow::setSelected(), and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

void setHeight ( QtDisplay ,
double  h 
)

Sets the height of the view for the display.

Definition at line 481 of file PyCanvas.cxx.

References PyCanvas::check(), Rect::getWidth(), Rect::getX(), Rect::getY(), PyApp::lock(), PyCanvas::m_canvas, and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

void setPlotMatrix ( unsigned int  columns,
unsigned int  rows 
)

Sets the number for columns and rows of plots on each page.

Definition at line 421 of file PyCanvas.cxx.

References PyCanvas::check(), PyApp::lock(), PyCanvas::m_canvas, and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

void setWidth ( QtDisplay ,
double  w 
)

Sets the width of the view for the display.

Definition at line 497 of file PyCanvas.cxx.

References PyCanvas::check(), Rect::getHeight(), Rect::getX(), Rect::getY(), PyApp::lock(), PyCanvas::m_canvas, and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

void setX ( QtDisplay display,
double  value 
)

Sets the view's X coordinate for the display.

Definition at line 542 of file PyCanvas.cxx.

References PyCanvas::check(), PyApp::lock(), PyCanvas::m_canvas, and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

void setY ( QtDisplay display,
double  value 
)

Sets the view's Y coordinate for the display.

Definition at line 556 of file PyCanvas.cxx.

References PyCanvas::check(), PyApp::lock(), PyCanvas::m_canvas, and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

void show (  ) 

Displays the canvas window on the screen.

Definition at line 84 of file PyCanvas.cxx.

References PyCanvas::check(), PyApp::lock(), PyCanvas::m_canvas, and PyApp::unlock().

Referenced by hippodraw::Python::export_Canvas().

void swapOrientation (  ) 

Swaps the orientation from portrait to landscape and vice verse.

Definition at line 432 of file PyCanvas.cxx.

References PyCanvas::check(), and PyCanvas::m_canvas_proxy.

Referenced by hippodraw::Python::export_Canvas().


Member Data Documentation

CanvasWindow* m_canvas [private]

The actual canvas window in the application thread.

Deprecated:
Should use the CanvasViewProxy instead.

Definition at line 51 of file PyCanvas.h.

Referenced by PyCanvas::addText(), PyCanvas::addTextAt(), PyCanvas::addTextAtAbs(), PyCanvas::addTextRep(), PyCanvas::check(), PyCanvas::close(), PyCanvas::findSelectedView(), PyCanvas::getCut(), PyCanvas::getDisplay(), PyCanvas::getDisplays(), PyCanvas::getHeight(), PyCanvas::getPickTable(), PyCanvas::getSelPickTable(), PyCanvas::getWidth(), PyCanvas::getX(), PyCanvas::getY(), PyCanvas::mouseData(), PyCanvas::print(), PyCanvas::PyCanvas(), PyCanvas::removeDisplay(), PyCanvas::saveAs(), PyCanvas::saveSelectedImages(), PyCanvas::selectAllDisplays(), PyCanvas::selectDisplay(), PyCanvas::setHeight(), PyCanvas::setPlotMatrix(), PyCanvas::setWidth(), PyCanvas::setX(), PyCanvas::setY(), and PyCanvas::show().

CanvasViewProxy* m_canvas_proxy [private]

The proxy for the CanvasView object.

All messages to the CanvasView should go through the proxy so that it is thread safe.

Definition at line 57 of file PyCanvas.h.

Referenced by PyCanvas::addDisplay(), PyCanvas::clear(), PyCanvas::PyCanvas(), PyCanvas::saveAsImage(), and PyCanvas::swapOrientation().

std::vector<QtDisplay *> m_displays [mutable, private]

Pointers to QtDisplay objects on the current canvas.

Definition at line 64 of file PyCanvas.h.

Referenced by PyCanvas::addDisplay(), PyCanvas::getDisplays(), and PyCanvas::saveAs().

bool m_has_gui [private]

Set to true if this canvas as associated GUI CanvasWindow.

Definition at line 61 of file PyCanvas.h.

Referenced by PyCanvas::addDisplay(), and PyCanvas::saveAs().


The documentation for this class was generated from the following files:
Generated for HippoDraw Class Library by doxygen