Public Member Functions | Private Member Functions | Private Attributes
PyCanvas Class Reference

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

#include <PyCanvas.h>

Collaboration diagram for PyCanvas:
Collaboration graph
[legend]

List of all members.

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 (CanvasWindow *)
 A constructor taking as argument the real canvas used by this object.
 PyCanvas ()
 The default constructor.
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.

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>
@author Paul F. Kunz <Paul_Kunz@slac.stanford.edu>

Definition at line 43 of file PyCanvas.h.


Constructor & Destructor Documentation

PyCanvas ( CanvasWindow window)

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.

Bug:
@@@ Can not use this method from Python, needs to be added so one can run in batch.

Try running batchmode.py

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.

void addText ( QtDisplay display,
const std::string &  text 
)
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().

void addTextAtAbs ( QtDisplay display,
const std::string &  text,
double  xabs,
double  yabs 
)
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().

void check ( ) const [private]
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 431 of file PyCanvas.cxx.

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

void close ( )

Closes the canvas window.

Definition at line 94 of file PyCanvas.cxx.

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

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().

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().

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

Returns all displays on the canvas.

Bug:
@@ The displays do not seem to come out in same order that they were inserted.

Definition at line 160 of file PyCanvas.cxx.

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

int getHeight ( QtDisplay display) const

Returns the view's height for the display.

Definition at line 440 of file PyCanvas.cxx.

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

NTuple * getPickTable ( QtDisplay display)

Gets the PickTable of selected display as a NTuple.

Definition at line 558 of file PyCanvas.cxx.

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

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().

int getWidth ( QtDisplay display) const

Returns the view's width for the display.

Definition at line 454 of file PyCanvas.cxx.

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

int getX ( QtDisplay display) const

Returns the view's X coordinate for the display.

Definition at line 502 of file PyCanvas.cxx.

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

int getY ( QtDisplay display) const

Returns the view's Y coordinate for the display.

Definition at line 516 of file PyCanvas.cxx.

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

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

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

Definition at line 401 of file PyCanvas.cxx.

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

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().

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().

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, CanvasWindow::saveAs(), num_util::size(), and PyApp::unlock().

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

Save the display as an image file.

Todo:
The exception should be thrown from the CanvasView which knows about required suffixes.

Definition at line 230 of file PyCanvas.cxx.

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

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().

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().

void selectDisplay ( QtDisplay display)
void setHeight ( QtDisplay display,
double  h 
)

Sets the height of the view for the display.

Definition at line 469 of file PyCanvas.cxx.

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

void setPlotMatrix ( unsigned int  columns,
unsigned int  rows 
)

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

Definition at line 409 of file PyCanvas.cxx.

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

void setWidth ( QtDisplay display,
double  w 
)

Sets the width of the view for the display.

Definition at line 485 of file PyCanvas.cxx.

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

void setX ( QtDisplay display,
double  value 
)

Sets the view's X coordinate for the display.

Definition at line 530 of file PyCanvas.cxx.

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

void setY ( QtDisplay display,
double  value 
)

Sets the view's Y coordinate for the display.

Definition at line 544 of file PyCanvas.cxx.

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

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().

void swapOrientation ( )

Swaps the orientation from portrait to landscape and vice verse.

Definition at line 420 of file PyCanvas.cxx.

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


Member Data Documentation

CanvasWindow* m_canvas [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