Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
QtDisplay Class Reference

Qt Displays wraps a derived class of PlotterBase. More...

#include <QtDisplay.h>

Inheritance diagram for QtDisplay:
Inheritance graph
[legend]
Collaboration diagram for QtDisplay:
Collaboration graph
[legend]

Public Member Functions

void addDataRep (const std::string &type, const DataSource *ntuple, const std::vector< std::string > &bindings)
 Creates and adds a DataRep to the display. More...
 
void addDataRep (PyDataRep *pyRep)
 Adds a DataRep created within Python. More...
 
void addDataRep (PyFunctionRep *pyFuncRep)
 Adds a Function (as PyFunctionRep) More...
 
void addDataRepStacked (const std::string &type, const DataSource *ntuple, const std::vector< std::string > &bindings)
 Adds a DataRep to the display by stacking, i.e. More...
 
void addFunction (FunctionBase *function)
 Adds a Function (as a FunctionBase object) More...
 
void addObserver (hippodraw::Observer *observer)
 Adds an observer to PlotterBase object. More...
 
void addValues (const std::vector< double > &v)
 Adds the values to the display. More...
 
void applyCut (QtDisplay *cut)
 Applies a cut to the wrapped PlotterBase. More...
 
void applyCuts (const std::vector< QtDisplay * > &cuts)
 Applies a cuts to the wrapped PlotterBase. More...
 
PyDataSourcecreateDataArray () const
 Creates a data array wrapper for the contents of the display. More...
 
PyNTuplecreateNTuple () const
 Creates and returns an PyNTuple representing the display. More...
 
int currentView ()
 Return the current view index. More...
 
void deleteView (int index)
 Delete a view by index. More...
 
PlotterBasedisplay ()
 Returns the wrapped display object. More...
 
double getBinWidth (const std::string &axis) const
 Returns the bin width on the specified axis. More...
 
PyDataRepgetDataRep ()
 Returns the selected DataRep in the plotter. More...
 
const std::vector< PyDataRep * > & getDataReps () const
 Returns a vector of all DataReps in the plotter. More...
 
const std::string & getLabel (const std::string &axis) const
 Returns the label on the specified axis. More...
 
int getLog (const std::string &axis)
 Return 1 if the specified axis is logarithmically scaled. More...
 
std::vector< double > getRange (const std::string &axis)
 Get the Range of the specified axis. More...
 
const std::string & getTitle () const
 Returns the title of the display. More...
 
int nextView (bool stepForward=true)
 Cycle through each set of plot ranges, thereby changing the view with each call. More...
 
double numberOfEntries () const
 Return the number of entries in the display. More...
 
int numViews ()
 Return the number of stored views. More...
 
int plotterId () const
 Return the Id to the plotter object. More...
 
 QtDisplay (const std::string &type)
 Create a display that has no DataSource bindings. More...
 
 QtDisplay (PyFunctionRep *rep)
 Creates a display for existing DataRep rep. More...
 
 QtDisplay (const std::string &type, const DataSource &nt, const std::vector< std::string > &bindings)
 Create a display using a vector of axis bindings, transparently wrapping the createDisplay private method. More...
 
 QtDisplay (const std::string &type, const PyDataSource &nt, const std::vector< std::string > &bindings)
 Create a display bound to a PyDataSource object using a vector of axis bindings, transparently wrapping the createDisplay private method. More...
 
 QtDisplay (const std::string &type, const QtRootNTuple &nt, const std::vector< std::string > &bindings)
 Create a display bound to RootNTuple using a vector of axis bindings, transparently wrapping the createDisplay private method. More...
 
 QtDisplay (const std::string &type, const QtRootNTuple &nt, const std::vector< std::string > &bindings, boost::python::list indices)
 Create a display bound to RootNTuple using a vector of axis bindings and indexes to array of TLeaf. More...
 
 QtDisplay (const std::string &type, boost::python::tuple, const std::vector< std::string > &bindings)
 Create a display by creating a ListTuple with the list objects contained in the tuple. More...
 
 QtDisplay (const std::string &type, boost::python::list, const std::vector< std::string > &bindings)
 Create a display by creating a ListTuple with the list objects contained in the list. More...
 
 QtDisplay (PlotterBase *plotter)
 Create a display from a pointer to an existing PlotterBase object. More...
 
void reset ()
 Resets all bins. More...
 
void resize ()
 Restore the X and Y dimensions of the display to their saved values. More...
 
int saveView ()
 Save the current set of plot ranges which define a "view" for this plot. More...
 
void setAspectRatio (double ratio)
 Sets the aspect ratio. More...
 
void setAutoRanging (const std::string &axis, bool flag)
 Sets the auto ranging flag on specified axis. More...
 
void setAutoTicks (const std::string &axis, bool yes)
 Sets the ticks to be automatic or manual. More...
 
void setBinWidth (const std::string &axis, double width, bool save=false)
 Sets the bin width on the specified axis. More...
 
void setBinWidth (const std::string &axis, double width)
 Sets the bin width on the specified axis. More...
 
void setColorMap (const std::string &name)
 Set the color map by name. More...
 
void setContourLevels (const std::vector< double > &levels)
 Set the contour levels if a ContourPointRep. More...
 
void setLabel (const std::string &axis, const std::string &label)
 Sets the label on the corresponding axis. More...
 
void setLog (const std::string &axis, int flag)
 Sets the specified axis to Logarithmic binning (if applicable ) and display. More...
 
void setNumberOfBins (const std::string &axis, unsigned int number)
 Sets the number of bins. More...
 
void setOffset (const std::string &axis, double offset)
 Sets the offset of the bins on the specified axis. More...
 
void setPointRep (RepBase *rep)
 Sets the PointRep for the display. More...
 
void setRange (const std::string &axis, double low, double high, bool save=false)
 Sets the Range on the specified axis. More...
 
void setRange (const std::string &axis, double low, double high)
 Sets the Range on the specified axis. More...
 
void setTicks (const std::string &axis, const std::vector< double > &values, const std::vector< std::string > &labels)
 Sets the axis ticks to specified points and values. More...
 
void setTitle (const std::string &title)
 Sets the title of the display. More...
 
void setTransform (const std::string &name)
 Sets the Transform. More...
 
void setView (int index)
 Set the view by index. More...
 
void unlock ()
 Unlock the QApplication in case of exception. More...
 
void update ()
 Updates the display. More...
 
 ~QtDisplay ()
 

Protected Member Functions

 QtDisplay ()
 A default constructor for derived classes. More...
 

Protected Attributes

PlotterBasem_plotter
 The contained PlotterBase object. More...
 

Private Member Functions

void createDisplay (const std::string &type, const DataSource &nt, const std::vector< std::string > &bindings)
 Create a QtDisplay. More...
 

Private Attributes

std::map< std::string, double > m_binWidths
 The saved X and Y bin widths to be used with the resize() method. More...
 
std::vector< PyDataRep * > m_pyDataReps
 A vector to store the PyDataRep pointers to be returned by reference via the getDataReps() method. More...
 
std::map< std::string,
std::pair< double, double > > 
m_ranges
 The saved X and Y ranges to be used with the resize() method. More...
 

Detailed Description

Qt Displays wraps a derived class of PlotterBase.

The purpose of this class is to provide an interface for Python running in a different thread from the application. It locks the QApplication object before forwarding messages to the contained PlotterBase object. It unlocks the QApplication object upon return.

Requests:
@@@ Need to add methods that PyDataRep implements so user doesn't need to know about DataRep objects.
Requests:
@@@ Implement constructor that takes as first argument a DataSource/DataArray and if binding is one element, create Histogram, if two, create ColorPlot.
Requests:
Need to check each method that does a lock to see if an exception could be thrown. If yes, and no try/catch block, then application will hang.
Todo:
Too may try/catch blocks. All exception inherit from std::exception, so why not put one static function to take care of the exceptions and qApp lock/unlock.
Author
James Chiang jchia.nosp@m.ng@s.nosp@m.lac.s.nosp@m.tanf.nosp@m.ord.e.nosp@m.du
Paul F. Kunz Paul_.nosp@m.Kunz.nosp@m.@slac.nosp@m..sta.nosp@m.nford.nosp@m..edu

Definition at line 71 of file QtDisplay.h.

Constructor & Destructor Documentation

QtDisplay ( )
protected

A default constructor for derived classes.

Definition at line 607 of file QtDisplay.cxx.

QtDisplay ( const std::string &  type)

Create a display that has no DataSource bindings.

Definition at line 633 of file QtDisplay.cxx.

References QtDisplay::createDisplay(), DisplayController::instance(), QtDisplay::m_plotter, and PyApp::unlock().

Creates a display for existing DataRep rep.

Definition at line 613 of file QtDisplay.cxx.

References QtDisplay::createDisplay(), DisplayController::instance(), PyApp::lock(), QtDisplay::m_plotter, and PyApp::unlock().

QtDisplay ( const std::string &  type,
const DataSource nt,
const std::vector< std::string > &  bindings 
)

Create a display using a vector of axis bindings, transparently wrapping the createDisplay private method.

Definition at line 653 of file QtDisplay.cxx.

References QtDisplay::createDisplay().

QtDisplay ( const std::string &  type,
const PyDataSource nt,
const std::vector< std::string > &  bindings 
)

Create a display bound to a PyDataSource object using a vector of axis bindings, transparently wrapping the createDisplay private method.

Definition at line 660 of file QtDisplay.cxx.

References QtDisplay::createDisplay(), and PyDataSource::dataSource().

QtDisplay ( const std::string &  type,
const QtRootNTuple nt,
const std::vector< std::string > &  bindings 
)

Create a display bound to RootNTuple using a vector of axis bindings, transparently wrapping the createDisplay private method.

Definition at line 669 of file QtDisplay.cxx.

References QtDisplay::createDisplay().

QtDisplay ( const std::string &  type,
const QtRootNTuple nt,
const std::vector< std::string > &  bindings,
boost::python::list  indices 
)

Create a display bound to RootNTuple using a vector of axis bindings and indexes to array of TLeaf.

Definition at line 677 of file QtDisplay.cxx.

References QtRootNTuple::createBinding(), QtDisplay::createDisplay(), i, num_util::size(), and PyApp::unlock().

QtDisplay ( const std::string &  type,
boost::python::tuple  seq,
const std::vector< std::string > &  bindings 
)

Create a display by creating a ListTuple with the list objects contained in the tuple.

Definition at line 473 of file QtDisplay.cxx.

References i, and num_util::size().

QtDisplay ( const std::string &  type,
boost::python::list  seq,
const std::vector< std::string > &  bindings 
)

Create a display by creating a ListTuple with the list objects contained in the list.

Definition at line 540 of file QtDisplay.cxx.

References i, and num_util::size().

QtDisplay ( PlotterBase plotter)

Create a display from a pointer to an existing PlotterBase object.

Definition at line 717 of file QtDisplay.cxx.

~QtDisplay ( )

Definition at line 719 of file QtDisplay.cxx.

Member Function Documentation

void addDataRep ( const std::string &  type,
const DataSource ntuple,
const std::vector< std::string > &  bindings 
)

Creates and adds a DataRep to the display.

Parameters
typeThe type of DataRep. Will be used to search for the type in the DataRepFactory. If the type doesn't exist, nothing is created. No checks are made that the new DataRep is consistent for viewing with existing ones.
ntupleA pointer to the DataSource to be used.
bindingsThe labels of the columns in the DataSource to be used.
Requests:
@@@ Also need to have removeDataRep in interface.

Definition at line 731 of file QtDisplay.cxx.

References DisplayController::addDataRep(), DisplayController::instance(), PyApp::lock(), QtDisplay::m_plotter, and PyApp::unlock().

void addDataRep ( PyDataRep pyRep)
void addDataRep ( PyFunctionRep pyFuncRep)
void addDataRepStacked ( const std::string &  type,
const DataSource ntuple,
const std::vector< std::string > &  bindings 
)

Adds a DataRep to the display by stacking, i.e.

sharing X axis but not the Y axis.

Definition at line 745 of file QtDisplay.cxx.

References DisplayController::addDataRepStacked(), DisplayController::instance(), PyApp::lock(), QtDisplay::m_plotter, and PyApp::unlock().

void addFunction ( FunctionBase function)
void addObserver ( hippodraw::Observer observer)

Adds an observer to PlotterBase object.

Definition at line 1262 of file QtDisplay.cxx.

References QtDisplay::m_plotter.

void addValues ( const std::vector< double > &  v)

Adds the values to the display.

Definition at line 1138 of file QtDisplay.cxx.

References PyApp::lock(), QtDisplay::m_plotter, and PyApp::unlock().

void applyCut ( QtDisplay cut)

Applies a cut to the wrapped PlotterBase.

If cut is a wrapper for a CutPlotter, then applies the cut to the wrapped PlotterBase object, otherwise an exception is thrown.

Definition at line 1310 of file QtDisplay.cxx.

References QtDisplay::display(), CutController::instance(), PyApp::lock(), and PyApp::unlock().

void applyCuts ( const std::vector< QtDisplay * > &  cuts)

Applies a cuts to the wrapped PlotterBase.

If the cuts are rappers for a CutPlotter, then applies the cuts to the wrapped PlotterBase object. If any of the cuts is not wrapper for a cut, an exception will be thrown.

Definition at line 1325 of file QtDisplay.cxx.

References QtDisplay::display(), i, CutController::instance(), PyApp::lock(), num_util::size(), and PyApp::unlock().

PyDataSource * createDataArray ( ) const

Creates a data array wrapper for the contents of the display.

Definition at line 1289 of file QtDisplay.cxx.

References QtDisplay::createNTuple(), FunctionController::instance(), PyApp::lock(), QtDisplay::m_plotter, and PyApp::unlock().

void createDisplay ( const std::string &  type,
const DataSource nt,
const std::vector< std::string > &  bindings 
)
private

Create a QtDisplay.

The type of QtDisplay will be looked up in the DataRepFactory. It will be connected to the DataSource nt. The bindings is represented by bindings. This is the function that does the work and is called by the constructors.

Requests:
Expose to Python the names of the available displays.

Definition at line 448 of file QtDisplay.cxx.

References DisplayController::createDisplay().

Referenced by QtDisplay::QtDisplay().

PyNTuple * createNTuple ( ) const

Creates and returns an PyNTuple representing the display.

Definition at line 1147 of file QtDisplay.cxx.

References FunctionController::instance(), PyApp::lock(), QtDisplay::m_plotter, and PyApp::unlock().

Referenced by QtDisplay::createDataArray().

int currentView ( )

Return the current view index.

Definition at line 907 of file QtDisplay.cxx.

References PlotterBase::currentView(), and QtDisplay::m_plotter.

void deleteView ( int  index)

Delete a view by index.

Definition at line 896 of file QtDisplay.cxx.

References PlotterBase::deleteView(), PyApp::lock(), QtDisplay::m_plotter, and PyApp::unlock().

PlotterBase * display ( )
double getBinWidth ( const std::string &  axis) const

Returns the bin width on the specified axis.

Definition at line 1019 of file QtDisplay.cxx.

References PlotterBase::getBinWidth(), and QtDisplay::m_plotter.

PyDataRep * getDataRep ( )

Returns the selected DataRep in the plotter.

Definition at line 1097 of file QtDisplay.cxx.

References PlotterBase::activePlotIndex(), PlotterBase::getDataRep(), index, PyApp::lock(), QtDisplay::m_plotter, rep, and PyApp::unlock().

const std::vector< PyDataRep * > & getDataReps ( ) const

Returns a vector of all DataReps in the plotter.

Definition at line 1113 of file QtDisplay.cxx.

References PlotterBase::getDataRep(), PlotterBase::getNumDataReps(), i, PyApp::lock(), QtDisplay::m_plotter, QtDisplay::m_pyDataReps, and PyApp::unlock().

const std::string & getLabel ( const std::string &  axis) const

Returns the label on the specified axis.

Definition at line 972 of file QtDisplay.cxx.

References hippodraw::Axes::convert(), PyApp::lock(), QtDisplay::m_plotter, and PyApp::unlock().

int getLog ( const std::string &  axis)

Return 1 if the specified axis is logarithmically scaled.

Definition at line 1077 of file QtDisplay.cxx.

References DisplayController::getLog(), DisplayController::instance(), and QtDisplay::m_plotter.

std::vector< double > getRange ( const std::string &  axis)
const std::string & getTitle ( ) const

Returns the title of the display.

Definition at line 918 of file QtDisplay.cxx.

References PlotterBase::getTitle(), and QtDisplay::m_plotter.

int nextView ( bool  stepForward = true)

Cycle through each set of plot ranges, thereby changing the view with each call.

Returns
The index of the current view.
Parameters
stepForwardDirection to step through the views.

Definition at line 878 of file QtDisplay.cxx.

References index, PyApp::lock(), QtDisplay::m_plotter, PlotterBase::nextView(), and PyApp::unlock().

double numberOfEntries ( ) const

Return the number of entries in the display.

Definition at line 1164 of file QtDisplay.cxx.

References PlotterBase::activeProjector(), ProjectorBase::getNumberOfEntries(), and QtDisplay::m_plotter.

int numViews ( )

Return the number of stored views.

Definition at line 892 of file QtDisplay.cxx.

References QtDisplay::m_plotter, and PlotterBase::numViews().

int plotterId ( ) const

Return the Id to the plotter object.

Note
If returning an int, then gcc 2.95.3 has internal compiler error coming from Boost.Python.

Definition at line 1219 of file QtDisplay.cxx.

References QtDisplay::m_plotter, and PlotterBase::plotterId().

void reset ( )

Resets all bins.

Definition at line 993 of file QtDisplay.cxx.

References PyApp::lock(), QtDisplay::m_plotter, and PyApp::unlock().

void resize ( )
int saveView ( )

Save the current set of plot ranges which define a "view" for this plot.

Returns
The index of the saved view.

Definition at line 850 of file QtDisplay.cxx.

References QtDisplay::getRange(), QtDisplay::m_plotter, QtDisplay::m_ranges, and PlotterBase::saveView().

void setAspectRatio ( double  ratio)

Sets the aspect ratio.

Definition at line 1129 of file QtDisplay.cxx.

References PyApp::lock(), QtDisplay::m_plotter, PlotterBase::setAspectRatio(), and PyApp::unlock().

void setAutoRanging ( const std::string &  axis,
bool  flag 
)

Sets the auto ranging flag on specified axis.

Definition at line 1087 of file QtDisplay.cxx.

References hippodraw::Axes::convert(), PyApp::lock(), QtDisplay::m_plotter, PlotterBase::setAutoRanging(), num_util::type(), and PyApp::unlock().

void setAutoTicks ( const std::string &  axis,
bool  yes 
)

Sets the ticks to be automatic or manual.

Definition at line 1280 of file QtDisplay.cxx.

References PyApp::lock(), QtDisplay::m_plotter, and PyApp::unlock().

void setBinWidth ( const std::string &  axis,
double  width,
bool  save = false 
)

Sets the bin width on the specified axis.

Definition at line 1000 of file QtDisplay.cxx.

References PyApp::lock(), QtDisplay::m_binWidths, QtDisplay::m_plotter, PlotterBase::setBinWidth(), and PyApp::unlock().

Referenced by QtDisplay::setBinWidth().

void setBinWidth ( const std::string &  axis,
double  width 
)

Sets the bin width on the specified axis.

This version is needed since Boost.Python cannot accommodate default arguments directly.

Definition at line 1026 of file QtDisplay.cxx.

References PyApp::lock(), QtDisplay::setBinWidth(), and PyApp::unlock().

void setColorMap ( const std::string &  name)

Set the color map by name.

Requests:
Expose the BinToColorFactory to Python so user can see the choice of names.

Definition at line 1228 of file QtDisplay.cxx.

References i, BinToColorFactory::instance(), PyApp::lock(), QtDisplay::m_plotter, rep, and PyApp::unlock().

void setContourLevels ( const std::vector< double > &  levels)
void setLabel ( const std::string &  axis,
const std::string &  label 
)

Sets the label on the corresponding axis.

Definition at line 959 of file QtDisplay.cxx.

References hippodraw::Axes::convert(), PyApp::lock(), QtDisplay::m_plotter, PlotterBase::setLabel(), and PyApp::unlock().

void setLog ( const std::string &  axis,
int  flag 
)

Sets the specified axis to Logarithmic binning (if applicable ) and display.

Definition at line 1066 of file QtDisplay.cxx.

References hippodraw::Axes::convert(), DisplayController::instance(), PyApp::lock(), QtDisplay::m_plotter, DisplayController::setLog(), num_util::type(), PyApp::unlock(), and yes.

Referenced by QtDisplay::resize().

void setNumberOfBins ( const std::string &  axis,
unsigned int  number 
)

Sets the number of bins.

Definition at line 984 of file QtDisplay.cxx.

References PyApp::lock(), QtDisplay::m_plotter, PlotterBase::setNumberOfBins(), and PyApp::unlock().

void setOffset ( const std::string &  axis,
double  offset 
)

Sets the offset of the bins on the specified axis.

Definition at line 1033 of file QtDisplay.cxx.

References hippodraw::Axes::convert(), DisplayController::instance(), PyApp::lock(), QtDisplay::m_plotter, DisplayController::setOffset(), num_util::type(), and PyApp::unlock().

void setPointRep ( RepBase rep)

Sets the PointRep for the display.

Definition at line 924 of file QtDisplay.cxx.

References PyApp::lock(), QtDisplay::m_plotter, PlotterBase::setRepresentation(), and PyApp::unlock().

void setRange ( const std::string &  axis,
double  low,
double  high,
bool  save = false 
)

Sets the Range on the specified axis.

Definition at line 801 of file QtDisplay.cxx.

References PyApp::lock(), QtDisplay::m_plotter, QtDisplay::m_ranges, PlotterBase::setRange(), and PyApp::unlock().

Referenced by QtDisplay::setRange().

void setRange ( const std::string &  axis,
double  low,
double  high 
)

Sets the Range on the specified axis.

This version is needed since Boost.Python cannot accommodate default arguments directly.

Definition at line 820 of file QtDisplay.cxx.

References PyApp::lock(), QtDisplay::setRange(), and PyApp::unlock().

void setTicks ( const std::string &  axis,
const std::vector< double > &  values,
const std::vector< std::string > &  labels 
)

Sets the axis ticks to specified points and values.

Definition at line 1269 of file QtDisplay.cxx.

References PyApp::lock(), QtDisplay::m_plotter, and PyApp::unlock().

void setTitle ( const std::string &  title)

Sets the title of the display.

Definition at line 911 of file QtDisplay.cxx.

References PyApp::lock(), QtDisplay::m_plotter, PlotterBase::setTitle(), and PyApp::unlock().

void setTransform ( const std::string &  name)

Sets the Transform.

Requests:
Expose to Python the list of available transforms.

Definition at line 1045 of file QtDisplay.cxx.

References DisplayController::instance(), PyApp::lock(), QtDisplay::m_plotter, DisplayController::setTransform(), and PyApp::unlock().

void setView ( int  index)

Set the view by index.

Definition at line 866 of file QtDisplay.cxx.

References PyApp::lock(), QtDisplay::m_plotter, PlotterBase::setView(), and PyApp::unlock().

void unlock ( )

Unlock the QApplication in case of exception.

Definition at line 1062 of file QtDisplay.cxx.

References PyApp::unlock().

void update ( )

Updates the display.

Bug:
@@ For the script, autontuple.py, this method behaves strangely.

Definition at line 1251 of file QtDisplay.cxx.

References PyApp::lock(), QtDisplay::m_plotter, and PyApp::unlock().

Member Data Documentation

std::map<std::string, double > m_binWidths
private

The saved X and Y bin widths to be used with the resize() method.

Definition at line 84 of file QtDisplay.h.

Referenced by QtDisplay::resize(), and QtDisplay::setBinWidth().

PlotterBase* m_plotter
protected
std::vector< PyDataRep * > m_pyDataReps
mutableprivate

A vector to store the PyDataRep pointers to be returned by reference via the getDataReps() method.

Definition at line 78 of file QtDisplay.h.

Referenced by QtDisplay::getDataReps().

std::map<std::string, std::pair <double, double> > m_ranges
private

The saved X and Y ranges to be used with the resize() method.

Definition at line 81 of file QtDisplay.h.

Referenced by QtDisplay::resize(), QtDisplay::saveView(), and QtDisplay::setRange().


The documentation for this class was generated from the following files:

Generated for HippoDraw Class Library by doxygen