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