15 #include "msdevstudio/MSconfig.h"
40 using std::runtime_error;
76 string what (
"Can not use this method as there is no window\n"
77 " associated with the canvas." );
78 throw std::runtime_error ( what );
129 vector < PlotterBase * > plotters;
132 for (
unsigned int i = 0; i <
size; i++ ) {
135 plotters.push_back ( plotter );
169 const std::vector< const ViewBase * > & views =
m_canvas->
views();
170 std::vector< const ViewBase * > :: const_iterator viewIt = views.begin();
171 while ( viewIt != views.end() ) {
188 if ( plotter != 0 ) {
191 if ( cut_plotter != 0 ) {
192 qtcut =
new QtCut ( cut_plotter );
203 m_canvas -> setAllSelected ( flag );
211 if ( selectedView ) {
219 print (
const std::string & filename )
234 std::string::size_type i = filename.find_last_of(
'.' );
235 if ( i == std::string::npos ) {
237 what (
"PyCanvas::saveAsImage: filename suffix missing." );
239 throw runtime_error( what );
243 if ( selectedView ) {
244 std::string file = filename;
255 std::string::size_type i = filename.find_last_of(
'.' );
256 if ( i == std::string::npos ) {
258 what (
"PyCanvas::saveSelectedImages: filename suffix missing." );
260 throw runtime_error( what );
271 return m_canvas -> getViewFor ( myPlotter );
290 if ( type ==
"Function Parameters" ||
291 type ==
"Chi-squared" ) {
293 if ( controller -> hasFunction ( plotter, 0 ) ) {
294 m_canvas -> addFuncDisplay ( plotter, type );
298 plotter -> setActivePlot ( 0,
false );
299 const std::string null (
"");
300 m_canvas -> addTextDisplay ( plotter, type, null );
301 plotter -> setActivePlot ( -1,
true );
313 const std::vector < std::string > &
319 return controller -> getTextTypes ();
323 const std::string &text )
343 double xrel,
double yrel )
358 plotter -> update ();
363 double xabs,
double yabs )
382 double xmax = rx.
high();
383 double xmin = rx.
low();
384 double ymax = ry.
high();
385 double ymin = ry.
low();
388 double xref = (xabs-xmin)/(xmax-xmin);
389 double yref = 1.-(yabs-ymin)/(ymax-ymin);
390 QRect rect = view->boundingRect();
397 plotter -> update ();
444 const PlotterBase * plotter = display -> display ();
447 height = view -> height ();
458 const PlotterBase * plotter = display -> display ();
461 width = view -> width ();
473 const PlotterBase * plotter = display -> display ();
476 Rect rect = view -> getDrawRect ();
477 view -> setDrawRect ( rect.
getX(), rect.
getY(),
489 const PlotterBase * plotter = display -> display ();
492 Rect rect = view -> getDrawRect ();
493 view -> setDrawRect ( rect.
getX(), rect.
getY(),
506 const PlotterBase * plotter = display -> display ();
509 x = static_cast <
int > ( view -> x () );
520 const PlotterBase * plotter = display -> display ();
523 y = static_cast <
int > ( view -> y () );
534 const PlotterBase * plotter = display -> display ();
537 view ->
setX ( static_cast < int > ( value ) );
548 const PlotterBase * plotter = display -> display ();
551 view ->
setY ( static_cast < int > ( value ) );
static DisplayController * instance()
Returns the pointer to the singleton instance.
void removeDisplay(PlotterBase *plotter)
Removes the plotter and its view from the canvas.
PlotterBase * display()
Returns the wrapped display object.
double getY() const
A shortcut to get origin.Y.
The base class for the PlotterBase hierarchy.
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 addTextRep(QtDisplay *display, const std::string &type)
Adds a textual data representation to display or type type.
void removeDisplay(QtDisplay *display)
Remove a display.
void setY(QtDisplay *display, double value)
Sets the view's Y coordinate for the display.
void setPlotMatrix(unsigned int columns, unsigned int rows)
Sets the number for columns and rows of plots on each page.
int getWidth(QtDisplay *display) const
Returns the view's width for the display.
const std::vector< double > & mouseEventData()
Retrieve a vector (x, y, z) points from the next mouse event.
void selectAllDisplays(bool flag=true)
Select or un-select all the displays on the canvas.
hippodraw::CanvasWindow class interface.
std::vector< QtDisplay * > m_displays
Pointers to QtDisplay objects on the current canvas.
FactoryException class interface.
static void lock()
Obtains a lock on the application's mutex.
hippodraw::BinaryTransform class interface
hippodraw::PyApp class interface.
void setX(QtDisplay *display, double value)
Sets the view's X coordinate for the display.
A singleton class that is the interface between GUI and the displays.
The class of derived from ViewBase and QCanvasRectangle for drawing on a QCanvas. ...
QtDisplay * getDisplay()
Returns the selected display on the canvas.
PlotterBase * getPlotter() const
Returns the plotter used by this view.
QtView * findSelectedView(QtDisplay *display)
Return the QtView associated with the given QtDisplay.
void saveAsImage(QtDisplay *display, const std::string &filename)
Save the display as an image file.
hippodraw::QtCut class interface
double getX() const
A shortcut to get origin.X.
void setWidth(QtDisplay *, double w)
Sets the width of the view for the display.
const std::vector< std::string > & getTextRepTypes() const
Returns the types of textual data representations available.
void saveAs(const std::string &filename)
Saves the document to the specified file.
int getX(QtDisplay *display) const
Returns the view's X coordinate for the display.
double getWidth() const
A shortcut to get size.width.
void show()
Displays the canvas window on the screen.
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...
QtCut * getCut()
Returns a QtCut object or null pointer if its not a QtCut object.
PlotterBase * selectedPlotter()
Returns the selected plotter.
A Proxy for the CanvasView class.
A transform that transforms coordinates from one coordinate system to another.
static void unlock()
Releases the lock on the application's mutex.
virtual TransformBase * getTransform() const
Returns the transform object used by the plotter.
NTuple * getPickTable(QtDisplay *)
Gets the PickTable for the display.
virtual void setActivePlot(int index, bool redraw)
Sets the active plot.
A singleton class is the interface between an application and the list of FunctionRep objects contain...
A DataSource class implemented with std::vector to store the column data. ...
double low() const
Returns the minimum of the range object.
hippodraw::Range class interface
DisplayController class interface declaration.
PyCanvas()
The default constructor.
intp size(numeric::array arr)
std::pair< double, double > addTextDisplayAt(PlotterBase *plotter, const std::string &type, const std::string &text, double xrel, double yrel)
Adds a text display at the relative position (xrel, yrel) in the selected item's coordinates.
void addTextDisplay(PlotterBase *plotter, const std::string &type)
Adds a textual display to the canvas of type type.
A concrete window class that contains the canvas and responds to menu item and tool bar events from t...
A transform that transforms coordinates from one 2D coordinate system to another. ...
hippodraw::NTuple class interface.
Cut1DPlotter class interface.
void saveAs(const std::string &filename)
Saves the document to the specified file.
NTuple * getSelPickTable()
Gets the PickTable of selected display as a NTuple.
PyArray_TYPES type(numeric::array arr)
bool m_has_gui
Set to true if this canvas as associated GUI CanvasWindow.
static FunctionController * instance()
Returns the pointer to the singleton instance.
void setSelected(QtView *view)
Select a specific view in the window.
NTuple * getPickTable() const
Gets the pick table the selected plotter.
void print(const std::string &filename)
Prints the canvas to a PostScript file.
hippodraw::PyCanvas class interface.
An exception class that is thrown when the factory fails to find the request class by its name...
void clear()
Removes all items from the CanvasWindow.
virtual void transform(double &x, double &y) const =0
Transform the coordinates on the X and Y axes.
A PlotterBase derived class that serves a base class for cut plotters.
void selectDisplay(QtDisplay *display)
Select a specific display.
virtual void fileSaveSelectedImages()
Saves the selected ViewBase object as an image file.
Qt Displays wraps a derived class of Cut1DPlotter.
const std::vector< const ViewBase * > & views()
Returns the list of ViewBase objects on the canvas.
hippodraw::CanvasViewProxy class interface.
void setHeight(QtDisplay *, double h)
Sets the height of the view for the display.
hippodraw::QtView class interface
hippodraw::CanvasView class interface
double high() const
Returns the maximum of the range object.
void saveAs(const std::string &filename) const
Saves all the QtView canvas item to a XML file.
CanvasWindow * m_canvas
The actual canvas window in the application thread.
void close()
Closes the canvas window.
void addText(QtDisplay *display, const std::string &text)
Add a BoxTextRep.
double getHeight() const
A shortcut to get size.height.
Class representing a rectangle.
void swapOrientation()
Swaps the orientation from portrait to landscape and vice verse.
hippodraw::FunctionController class interface
void saveSelectedImages(const std::string &filename)
Save the selected images as an image file.
const std::vector< QtDisplay * > & getDisplays() const
Returns all displays on the canvas.
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.
CanvasViewProxy * m_canvas_proxy
The proxy for the CanvasView object.
Qt Displays wraps a derived class of PlotterBase.
void check() const
Checks if the CanvasWindow has been closed and throws a runtime_error if it has been.
This class implements additional FigureEditor functionality particular to QtView objects.
int getHeight(QtDisplay *display) const
Returns the view's height for the display.
Expresses a range of values.
void addDisplay(QtDisplay *display_wrap)
Adds the display to the canvas.
static bool hasPendingEvents()
Returns true if the application object has pending events.
The abstract base class for views.