15 #include "msdevstudio/MSconfig.h"
40 using std::runtime_error;
43 using namespace hippodraw;
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 ) );
void clear()
Removes all items from the CanvasWindow.
void removeDisplay(PlotterBase *plotter)
Removes the plotter and its view from the canvas.
void selectDisplay(QtDisplay *display)
Select a specific display.
hippodraw::CanvasWindow class interface.
static bool hasPendingEvents()
Returns true if the application object has pending events.
A singleton class that is the interface between GUI and the displays.
double high() const
Returns the maximum of the range object.
Qt Displays wraps a derived class of Cut1DPlotter.
void addText(QtDisplay *display, const std::string &text)
Add a BoxTextRep.
double getHeight() const
A shortcut to get size.height.
A transform that transforms coordinates from one coordinate system to another.
A Proxy for the CanvasView class.
hippodraw::QtCut class interface
This class implements additional FigureEditor functionality particular to QtView objects.
virtual void transform(double &x, double &y) const =0
Transform the coordinates on the X and Y axes.
bool m_has_gui
Set to true if this canvas as associated GUI CanvasWindow.
static FunctionController * instance()
Returns the pointer to the singleton instance.
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.
static void lock()
Obtains a lock on the application's mutex.
PlotterBase * selectedPlotter()
Returns the selected plotter.
void saveAs(const std::string &filename)
Saves the document to the specified file.
hippodraw::FunctionController class interface
A singleton class is the interface between an application and the list of FunctionRep objects contain...
int getHeight(QtDisplay *display) const
Returns the view's height for the display.
void setHeight(QtDisplay *, double h)
Sets the height of the view for the display.
NTuple * getPickTable() const
Gets the pick table the selected plotter.
hippodraw::CanvasView class interface
void addTextDisplay(PlotterBase *plotter, const std::string &type)
Adds a textual display to the canvas of type type.
CanvasWindow * m_canvas
The actual canvas window in the application thread.
void close()
Closes the canvas window.
double getWidth() const
A shortcut to get size.width.
void swapOrientation()
Swaps the orientation from portrait to landscape and vice verse.
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 saveSelectedImages(const std::string &filename)
Save the selected images as an image file.
void addTextRep(QtDisplay *display, const std::string &type)
Adds a textual data representation to display or type type.
const std::vector< QtDisplay * > & getDisplays() const
Returns all displays on the canvas.
hippodraw::NTuple class interface.
The base class for the PlotterBase hierarchy.
void setY(QtDisplay *display, double value)
Sets the view's Y coordinate for the display.
PlotterBase * getPlotter() const
Returns the plotter used by this view.
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.
PyArray_TYPES type(numeric::array arr)
CanvasViewProxy * m_canvas_proxy
The proxy for the CanvasView object.
virtual void setActivePlot(int index, bool redraw)
Sets the active plot.
hippodraw::BinaryTransform class interface
hippodraw::PyApp class interface.
void saveAs(const std::string &filename) const
Saves all the QtView canvas item to a XML file.
A PlotterBase derived class that serves a base class for cut plotters.
void check() const
Checks if the CanvasWindow has been closed and throws a runtime_error if it has been.
void setX(QtDisplay *display, double value)
Sets the view's X coordinate for the display.
intp size(numeric::array arr)
const std::vector< const ViewBase * > & views()
Returns the list of ViewBase objects on the canvas.
void setSelected(QtView *view)
Select a specific view in the window.
void addDisplay(QtDisplay *display_wrap)
Adds the display to the canvas.
hippodraw::CanvasViewProxy class interface.
Class representing a rectangle.
hippodraw::QtView class interface
FactoryException class interface.
The class of derived from ViewBase and QCanvasRectangle for drawing on a QCanvas. ...
void saveAsImage(QtDisplay *display, const std::string &filename)
Save the display as an image file.
static DisplayController * instance()
Returns the pointer to the singleton instance.
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.
PlotterBase * display()
Returns the wrapped display object.
A DataSource class implemented with std::vector<double> to store the column data. ...
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...
The abstract base class for views.
void removeDisplay(QtDisplay *display)
Remove a display.
void setPlotMatrix(unsigned int columns, unsigned int rows)
Sets the number for columns and rows of plots on each page.
Qt Displays wraps a derived class of PlotterBase.
int getWidth(QtDisplay *display) const
Returns the view's width for the display.
void selectAllDisplays(bool flag=true)
Select or un-select all the displays on the canvas.
double getX() const
A shortcut to get origin.X.
A transform that transforms coordinates from one 2D coordinate system to another. ...
hippodraw::Range class interface
std::vector< QtDisplay * > m_displays
Pointers to QtDisplay objects on the current canvas.
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 fileSaveSelectedImages()
Saves the selected ViewBase object as an image file.
double low() const
Returns the minimum of the range object.
PyCanvas()
The default constructor.
const std::vector< double > & mouseEventData()
Retrieve a vector (x, y, z) points from the next mouse event.
Expresses a range of values.
Cut1DPlotter class interface.
An exception class that is thrown when the factory fails to find the request class by its name...
QtDisplay * getDisplay()
Returns the selected display on the canvas.
NTuple * getSelPickTable()
Gets the PickTable of selected display as a NTuple.
QtView * findSelectedView(QtDisplay *display)
Return the QtView associated with the given QtDisplay.
A concrete window class that contains the canvas and responds to menu item and tool bar events from t...
DisplayController class interface declaration.
int getX(QtDisplay *display) const
Returns the view's X coordinate for the display.
void show()
Displays the canvas window on the screen.
hippodraw::PyCanvas class interface.
double getY() const
A shortcut to get origin.Y.
QtCut * getCut()
Returns a QtCut object or null pointer if its not a QtCut object.
void print(const std::string &filename)
Prints the canvas to a PostScript file.