QtDisplay.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
2 
14 #ifndef _QtDisplay_H_
15 #define _QtDisplay_H_
16 
17 #include "axes/AxesType.h"
18 
19 #include <vector>
20 #include <map>
21 
22 namespace boost {
23  namespace python {
24  class list;
25  class tuple;
26  }
27 }
28 
29 namespace hippodraw {
30 
31 class DataRep;
32 class Observer;
33 class PyFunctionRep;
34 class PyDataRep;
35 class PyDataSource;
36 class PyFunctionRep;
37 class PlotterBase;
38 #ifndef BOOST_DEFECT
39 class FunctionBase;
40 #endif
41 class RepBase;
42 class DataSource;
43 class NTuple;
44 class PyNTuple;
45 class QtRootNTuple;
46 
71 class QtDisplay
72 {
73 
74 private:
75 
78  mutable std::vector< PyDataRep * > m_pyDataReps;
79 
81  std::map<std::string, std::pair <double, double> > m_ranges;
82 
84  std::map<std::string, double > m_binWidths;
85 
90  void createDisplay ( const std::string & type,
91  const DataSource & nt,
92  const std::vector < std::string > & bindings );
93 
94 protected:
95 
98 
100  QtDisplay ();
101 
102 public:
103 
106  QtDisplay ( const std::string & type );
107 
111 
115  QtDisplay ( const std::string & type,
116  const DataSource & nt,
117  const std::vector< std::string > & bindings );
118 
123  QtDisplay ( const std::string & type,
124  const PyDataSource & nt,
125  const std::vector< std::string > & bindings );
126 
131  QtDisplay ( const std::string & type,
132  const QtRootNTuple & nt,
133  const std::vector< std::string > & bindings );
134 
138  QtDisplay ( const std::string & type,
139  const QtRootNTuple & nt,
140  const std::vector< std::string > & bindings,
141  boost::python::list indices );
142 
146  QtDisplay ( const std::string & type,
148  const std::vector < std::string > & bindings );
149 
153  QtDisplay ( const std::string & type,
155  const std::vector < std::string > & bindings );
156 
158  QtDisplay (PlotterBase * plotter);
159 
160  ~QtDisplay();
161 
163  PlotterBase * display();
164 
174  void addDataRep ( const std::string & type,
175  const DataSource * ntuple,
176  const std::vector < std::string > & bindings );
177 
181  void addDataRepStacked ( const std::string & type,
182  const DataSource * ntuple,
183  const std::vector < std::string > & bindings );
184 
186  void addDataRep ( PyDataRep * pyRep );
187 
189  void addDataRep ( PyFunctionRep * pyFuncRep );
190 
191 #ifndef BOOST_DEFECT
192 
193  void addFunction ( FunctionBase * function );
194 #endif
195 
197  PyDataRep * getDataRep ();
198 
200  const std::vector<PyDataRep *> &getDataReps () const;
201 
204  void setTitle ( const std::string & title );
205 
207  const std::string &getTitle() const;
208 
211  void setLabel ( const std::string & axis, const std::string & label );
212 
214  const std::string & getLabel( const std::string &axis) const;
215 
217  void setNumberOfBins ( const std::string & axis, unsigned int number );
218 
220  double getBinWidth ( const std::string & axis ) const;
221 
223  void setBinWidth ( const std::string & axis, double width,
224  bool save=false );
225 
228  void setBinWidth ( const std::string & axis, double width );
229 
231  void setOffset ( const std::string & axis, double offset );
232 
234  void setRange ( const std::string & axis, double low, double high,
235  bool save=false );
236 
239  void setRange ( const std::string & axis, double low, double high );
240 
242  std::vector<double> getRange ( const std::string & axis );
243 
248  int saveView ();
249 
251  void setView ( int index );
252 
258  int nextView ( bool stepForward = true );
259 
261  int numViews ();
262 
264  void deleteView( int index );
265 
267  int currentView ();
268 
270  void setAutoRanging ( const std::string & axis, bool flag );
271 
274  void setLog ( const std::string & axis, int flag );
275 
277  int getLog ( const std::string & axis );
278 
280  void setTransform ( const std::string & name );
281 
284  void setPointRep ( RepBase * rep );
285 
287  void setContourLevels ( const std::vector<double> &levels );
288 
291  void setAspectRatio ( double ratio );
292 
295  void reset();
296 
298  void addValues ( const std::vector < double > & v );
299 
302  PyNTuple * createNTuple () const;
303 
305  double numberOfEntries () const;
306 
309  void resize();
310 
316  int plotterId() const;
317 
319  void setColorMap ( const std::string & name );
320 
326  void update ();
327 
330  void addObserver ( hippodraw::Observer * observer );
331 
334  void setTicks ( const std::string & axis,
335  const std::vector < double > & values,
336  const std::vector < std::string > & labels );
337 
340  void setAutoTicks ( const std::string & axis, bool yes );
341 
343  void unlock();
344 
349  void applyCut ( QtDisplay * cut );
350 
356  void applyCuts ( const std::vector < QtDisplay * > & cuts );
357 
358 
361  PyDataSource * createDataArray() const;
362 
363 };
364 
365 } // namespace hippodraw
366 
367 #endif // _QtDisplay_H_
int saveView()
Save the current set of plot ranges which define a &quot;view&quot; for this plot.
Definition: QtDisplay.cxx:850
void setTitle(const std::string &title)
Sets the title of the display.
Definition: QtDisplay.cxx:911
void setPointRep(RepBase *rep)
Sets the PointRep for the display.
Definition: QtDisplay.cxx:924
PyNTuple * createNTuple() const
Creates and returns an PyNTuple representing the display.
Definition: QtDisplay.cxx:1147
const std::string & getTitle() const
Returns the title of the display.
Definition: QtDisplay.cxx:918
void setOffset(const std::string &axis, double offset)
Sets the offset of the bins on the specified axis.
Definition: QtDisplay.cxx:1033
int currentView()
Return the current view index.
Definition: QtDisplay.cxx:907
int nextView(bool stepForward=true)
Cycle through each set of plot ranges, thereby changing the view with each call.
Definition: QtDisplay.cxx:878
void unlock()
Unlock the QApplication in case of exception.
Definition: QtDisplay.cxx:1062
void update()
Updates the display.
Definition: QtDisplay.cxx:1251
const std::vector< PyDataRep * > & getDataReps() const
Returns a vector of all DataReps in the plotter.
Definition: QtDisplay.cxx:1113
void createDisplay(const std::string &type, const DataSource &nt, const std::vector< std::string > &bindings)
Create a QtDisplay.
Definition: QtDisplay.cxx:448
A wrapper class for Python tuple objects.
Definition: python.dir:45
void setColorMap(const std::string &name)
Set the color map by name.
Definition: QtDisplay.cxx:1228
int getLog(const std::string &axis)
Return 1 if the specified axis is logarithmically scaled.
Definition: QtDisplay.cxx:1077
void applyCuts(const std::vector< QtDisplay * > &cuts)
Applies a cuts to the wrapped PlotterBase.
Definition: QtDisplay.cxx:1325
void setTransform(const std::string &name)
Sets the Transform.
Definition: QtDisplay.cxx:1045
void reset()
Resets all bins.
Definition: QtDisplay.cxx:993
void setAutoRanging(const std::string &axis, bool flag)
Sets the auto ranging flag on specified axis.
Definition: QtDisplay.cxx:1087
int numViews()
Return the number of stored views.
Definition: QtDisplay.cxx:892
std::map< std::string, double > m_binWidths
The saved X and Y bin widths to be used with the resize() method.
Definition: QtDisplay.h:84
void setAspectRatio(double ratio)
Sets the aspect ratio.
Definition: QtDisplay.cxx:1129
return rep
Definition: Inspector.cxx:3843
void applyCut(QtDisplay *cut)
Applies a cut to the wrapped PlotterBase.
Definition: QtDisplay.cxx:1310
return yes
Definition: CanvasView.cxx:883
QtDisplay()
A default constructor for derived classes.
Definition: QtDisplay.cxx:607
void setBinWidth(const std::string &axis, double width, bool save=false)
Sets the bin width on the specified axis.
Definition: QtDisplay.cxx:1000
A wrapper for RootNTuple, so that when RootNTuple is used in Qt based application, the application object can be locked and unlocked before calling any ROOT functions.
Definition: QtRootNTuple.h:37
void setAutoTicks(const std::string &axis, bool yes)
Sets the ticks to be automatic or manual.
Definition: QtDisplay.cxx:1280
The base class for the PlotterBase hierarchy.
Definition: PlotterBase.h:55
void addFunction(FunctionBase *function)
Adds a Function (as a FunctionBase object)
Definition: QtDisplay.cxx:781
int plotterId() const
Return the Id to the plotter object.
Definition: QtDisplay.cxx:1219
void setContourLevels(const std::vector< double > &levels)
Set the contour levels if a ContourPointRep.
Definition: QtDisplay.cxx:938
PyArray_TYPES type(numeric::array arr)
Definition: num_util.cpp:249
PyDataSource * createDataArray() const
Creates a data array wrapper for the contents of the display.
Definition: QtDisplay.cxx:1289
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: QtDisplay.cxx:1269
PlotterBase * m_plotter
The contained PlotterBase object.
Definition: QtDisplay.h:97
ViewBase * v
Definition: PlotTable.cxx:104
void addObserver(hippodraw::Observer *observer)
Adds an observer to PlotterBase object.
Definition: QtDisplay.cxx:1262
void setRange(const std::string &axis, double low, double high, bool save=false)
Sets the Range on the specified axis.
Definition: QtDisplay.cxx:801
void setView(int index)
Set the view by index.
Definition: QtDisplay.cxx:866
This class is the public interface to a DataSource object that the user sees as the DataArray object ...
Definition: PyDataSource.h:43
The namespace for axes.
Part of an implementation of the Observable Observer pattern based on the example implementation in t...
Definition: Observer.h:34
PlotterBase * display()
Returns the wrapped display object.
Definition: QtDisplay.cxx:724
const std::string & getLabel(const std::string &axis) const
Returns the label on the specified axis.
Definition: QtDisplay.cxx:972
This class is the public Python interface wrap for the FunctionRep class.
Definition: PyFunctionRep.h:41
A function that can be added to a DataRep and used in a fitter.
Definition: FunctionBase.h:90
void setLabel(const std::string &axis, const std::string &label)
Sets the label on the corresponding axis.
Definition: QtDisplay.cxx:959
Qt Displays wraps a derived class of PlotterBase.
Definition: QtDisplay.h:71
double numberOfEntries() const
Return the number of entries in the display.
Definition: QtDisplay.cxx:1164
void setNumberOfBins(const std::string &axis, unsigned int number)
Sets the number of bins.
Definition: QtDisplay.cxx:984
std::vector< double > getRange(const std::string &axis)
Get the Range of the specified axis.
Definition: QtDisplay.cxx:829
return index
Definition: PickTable.cxx:182
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.
Definition: QtDisplay.cxx:745
void resize()
Restore the X and Y dimensions of the display to their saved values.
Definition: QtDisplay.cxx:1172
A wrapper for NTuple, so that when NTuple is used in Qt based application, the application object can...
Definition: PyNTuple.h:28
void addValues(const std::vector< double > &v)
Adds the values to the display.
Definition: QtDisplay.cxx:1138
std::map< std::string, std::pair< double, double > > m_ranges
The saved X and Y ranges to be used with the resize() method.
Definition: QtDisplay.h:81
std::vector< PyDataRep * > m_pyDataReps
A vector to store the PyDataRep pointers to be returned by reference via the getDataReps() method...
Definition: QtDisplay.h:78
void deleteView(int index)
Delete a view by index.
Definition: QtDisplay.cxx:896
A wrapper class for Python list objects.
Definition: python.dir:41
void addDataRep(const std::string &type, const DataSource *ntuple, const std::vector< std::string > &bindings)
Creates and adds a DataRep to the display.
Definition: QtDisplay.cxx:731
void setLog(const std::string &axis, int flag)
Sets the specified axis to Logarithmic binning (if applicable ) and display.
Definition: QtDisplay.cxx:1066
double getBinWidth(const std::string &axis) const
Returns the bin width on the specified axis.
Definition: QtDisplay.cxx:1019
The base class for the point representation hierarchy.
Definition: RepBase.h:45
PyDataRep * getDataRep()
Returns the selected DataRep in the plotter.
Definition: QtDisplay.cxx:1097
This class is the public interface the what the user sees as the DataRep object from Python...
Definition: PyDataRep.h:37
Base class for DataSource.
Definition: DataSource.h:55

Generated for HippoDraw Class Library by doxygen