14 #include "msdevstudio/MSconfig.h"
49 using std::logic_error;
50 using std::runtime_error;
52 using namespace hippodraw;
72 vector < string > bindings;
73 bindings.push_back ( label );
88 addCut ( cut_plotter, plotter );
99 if ( cut_plotter == 0 ) {
100 string what (
"Argument was not a cut" );
101 throw runtime_error ( what );
106 unsigned int size = plotter -> getNumDataReps ();
107 for (
unsigned int i = 0;
i <
size;
i++ ) {
108 DataRep * targetrep = plotter -> getDataRep (
i );
109 if ( targetrep -> hasNTupleBindings () ) {
116 if ( targetrep -> hasNTupleBindings() ) {
123 const list < DataRep * > & targets = cp -> getCutTargets ();
124 list < DataRep * > :: const_iterator first = targets.begin();
125 while ( first != targets.end () ) {
134 addCuts (
const std::vector < PlotterBase * > & cut_list,
137 unsigned int size = cut_list.size ();
139 for (
unsigned int i = 0;
i <
size;
i++ ) {
142 if ( cut_plotter != plotter ) {
143 addCut ( cut_plotter, plotter );
153 const vector < TupleCut > & cuts = cut_plotter -> getCuts ();
154 assert ( cuts.empty () == false );
159 assert ( projector );
161 for (
unsigned int i = 0;
i < cuts.size();
i++ ) {
162 projector->
addCut ( &cuts[
i] );
173 const std::vector < std::string > & bindings,
174 const Color & color )
const
176 std::string datarepname, plottername;
177 int ndims = bindings.size();
181 datarepname =
"Histogram";
182 plottername =
"Cut1DPlotter";
184 else if( ndims == 2 )
186 datarepname =
"Color Plot";
187 plottername =
"Cut2DPlotter";
201 plotter -> addDataRep ( rep );
202 plotter -> addTupleCut ( rep );
204 plotter -> setNTuple ( ntuple );
205 plotter -> setAxisBinding ( bindings );
206 plotter -> setCutRangeFull ();
207 plotter -> setCutColor ( color );
217 if ( cut_plotter != 0 ) {
218 DataRep *
rep = plotter -> selectedDataRep ();
221 cut_plotter -> removeFromTarget ( rep );
226 DataRep *
rep = cplotter -> selectedDataRep ();
234 std::vector < CutPlotter * > & cut_list )
237 vector < PlotterBase * >::const_iterator first = plotter_list.begin();
238 while ( first != plotter_list.end() ) {
242 cut_list.push_back ( cutter );
247 const vector < const TupleCut * > &
255 if ( projector == 0 ) {
256 string what (
"CutController::getCutList: ");
257 what +=
"DataRep does not have NTupleProjector.";
258 throw std::logic_error ( what );
267 std::vector < PlotterBase * > & cut_list )
270 int reps = plotter -> getNumDataReps ();
271 for (
int i = 0;
i < reps;
i++ ) {
273 vector < PlotterBase * > cuts;
275 cut_list.insert ( cut_list.end(), cuts.begin(), cuts.end() );
282 std::vector < PlotterBase * > & cut_list )
287 Observable::ObserverList_t::const_iterator first = objects.begin();
289 while ( first != objects.end() ) {
292 if ( plotter != 0 ) {
293 const DataRep *
rep = plotter -> getDataRep ( 0 );
294 if ( rep != datarep ) {
296 cut_list.push_back ( cp );
305 std::vector < PlotterBase * > & web )
308 vector < PlotterBase * > ::const_iterator first = plotters.begin ();
310 while ( first != plotters.end () ) {
321 PlotterList_t::iterator first = find ( web.begin (), web.end(),
323 if ( first == web.end () ) {
324 web.push_back ( plotter );
325 int index = plotter -> activePlotIndex ();
330 DataRep *
rep = plotter -> getDataRep ( index );
331 vector < PlotterBase * > cut_list;
333 if ( cut_list.empty () == false ) {
344 PlotterList_t::iterator first = find ( web.begin(), web.end(),
346 if ( first == web.end () ) {
347 web.push_back ( cutter );
349 const list < DataRep * > & targets = cutter -> getCutTargets ();
350 list < DataRep * > ::const_iterator
it = targets.begin ();
352 while ( it != targets.end () ) {
366 PlotterList_t::const_iterator first = cutters.begin ();
367 while ( first != cutters.end () ) {
380 Observable::ObserverList_t::const_iterator first = objects.begin();
382 while ( first != objects.end () ) {
386 DataRep * plotter_rep = cutter -> getDataRep ( 0 );
387 if ( plotter_rep == datarep ) {
394 if ( xyplotter != 0 ) {
406 std::vector < const TupleCut * > & cut_list )
410 #ifdef ITERATOR_MEMBER_DEFECT
413 vector < const ViewBase * >::const_iterator first = views.begin ();
414 while ( first != views.end() ) {
418 if ( plotter == 0 )
continue;
420 const vector < TupleCut > & cuts = plotter -> getCuts ();
421 for (
unsigned int i = 0;
i < cuts.size();
i++ ) {
422 cut_list.push_back ( &cuts[
i] );
430 const std::vector < const ViewBase * > & views )
432 #ifdef ITERATOR_MEMBER_DEFECT
435 list < ViewBase * > :: const_iterator first = targets.begin ();
436 while( first != targets.end () )
440 int number = plotter -> getNumDataReps ();
442 for(
int i = 0;
i < number;
i++ )
457 const std::vector < const ViewBase * > & views )
463 if ( projector == 0 )
return;
465 const vector < const TupleCut * > & cuts = projector->
getCutList ();
466 if ( cuts.empty() == true )
return;
468 #ifdef ITERATOR_MEMBER_DEFECT
471 vector < const TupleCut * > ::const_iterator first = cuts.begin ();
472 while ( first != cuts.end() ) {
482 const std::vector < const ViewBase * > & views )
484 #ifdef ITERATOR_MEMBER_DEFECT
487 vector < const ViewBase * >::const_iterator first = views.begin();
488 while ( first != views.end() )
494 if ( plotter == 0 )
continue;
496 const vector < TupleCut > & cuts = plotter -> getCuts ();
497 for (
unsigned int i = 0;
i < cuts.size();
i++ ) {
498 if ( &cuts[
i] == cut ) {
505 const vector < PlotterBase * > &
513 std::vector < PlotterBase * >::const_iterator
it = plotters.begin();
515 for ( ; it != plotters.end(); ++
it )
520 if ( cut_plotter != 0 ) {
522 if ( cut_tuple == ntuple ) {
536 m_zoom_pan.push_back ( make_pair( cut_plotter, axis ) );
538 m_zoom_pan.remove ( make_pair( cut_plotter, axis ) );
548 list< pair< PlotterBase *, Axes::Type > >::const_iterator iter;
551 if( iter -> first == cut_plotter && iter -> second == axis )
561 const std::vector < const TupleCut * > & cut_list )
563 acceptArray.clear ();
565 std::size_t
size = source -> rows ();
566 acceptArray.reserve ( size );
568 std::size_t num_cuts = cut_list.size ();
569 for (
unsigned int i = 0;
i <
size;
i++ )
575 for (
unsigned int j = 0; j < num_cuts; j++ )
578 accept = tc -> acceptRow ( source,
i );
582 acceptArray.push_back ( accept );
586 template <
typename T >
604 const string colname = source -> getLabelAt( 0 );
605 const vector < double > & destcol = dest -> getColumn ( colname );
606 const vector < double > & srccol = source -> getColumn ( 0 );
607 const string colname_cut = colname +
"_cut";
608 std::size_t dest_size = dest -> rows ();
609 vector < double > dest_cut ( dest_size, 0. );
610 for ( std::size_t
i = 0;
i < srccol.size ();
i++ ) {
611 const double & value = srccol[
i];
612 vector < double > ::const_iterator first
613 = find ( destcol.begin(), destcol.end(),
615 std::size_t d = distance ( destcol.begin(), first );
618 dest -> addColumn ( colname_cut, dest_cut );
A Plotter class that plots points in 2 dimensions and option a third dimension in color...
Type * create(const std::string &name)
Creates a new object from a prototype named name.
A singleton class that is the interface between GUI and the displays.
static CutController * instance()
Returns the pointer to the singleton instance.
void connectDataRep(DataRep *rep, const std::vector< const ViewBase * > &views)
Connects the DataRep object to its appropriate Cut Plotter.
void linkCutAndRep(CutPlotter *cut_plotter, DataRep *target)
Adds cut (associated with the given cut plotter)to the projector of target rep and registers target a...
void fillTupleCutList(const std::vector< const ViewBase * > &views, std::vector< const TupleCut * > &cut_list)
Fills the cut_map with the TupleCut objects contained the list of views, if any.
void addCutTarget(DataRep *rep)
Adds a DataRep to the list of targets.
CutController()
A default constructor for avoiding creation except by itself or with derived classes.
bool isZoomPan(const PlotterBase *cut_plotter, hippodraw::Axes::Type axis) const
Returns true if plotter is in zoom/pan list.
virtual int activePlotIndex() const
Returns the index of the active plotter.
std::list< Observer * > ObserverList_t
The type of STL container to maintain list of Observer objects.
const std::vector< const TupleCut * > & getCutList(const DataRep *rep) const
Returns a list of TupleCut objects that are used by the DataRep.
hippodraw::DataRep class interface.
hippodraw::Cut2DPlotter class interface
CutPlotter * createCut(const std::string &name, const DataSource *source, const std::vector< std::string > &bindings, const Color &color) const
Creates a new cut plotter.
static PlotterFactory * instance()
Returns the pointer to the singleton instance.
An NTupleProjector is a projector that projects data from an DataSource object.
The class expresses a cut on a DataSource, i.e.
Cut1DPlotter * addCut(PlotterBase *plotter, int index, const std::string &label)
Adds a one dimension cut to the plotter.
DataRep * createDataRep(const std::string &name)
Creates a new DataRep object of class name.
A Color class for creating the color object following the standard RGB color space.
The base class for the PlotterBase hierarchy.
hippodraw::DataSource class interface.
PlotterBase * getPlotter() const
Returns the plotter used by this view.
The base class for data representations.
A PlotterBase derived class that serves a base class for cut plotters.
DataRepController class interface.
static CutController * s_instance
The pointer to the singleton object.
void fillCutWeb(const std::vector< PlotterBase * > &plotters, std::vector< PlotterBase * > &web)
Clears and fills the web with the PlotterBase objects in plotters, each of their CutPlotter objects t...
This Singleton class maintains a list of plotters.
intp size(numeric::array arr)
A singleton class that is the interface between GUI and the DataRep.
std::vector< PlotterBase * > PlotterList_t
The type of standard C++ container used to hold PlotterBase objects.
virtual bool hasNTupleBindings() const
Returns true if the DataRep's projector can bind to DataSource.
const std::vector< const TupleCut * > & getCutList() const
Returns the list of TupleCut objects used by this projector.
static DisplayController * instance()
Returns the pointer to the singleton instance.
Part of an implementation of the Observable Observer pattern based on the example implementation in t...
A Plotter class that plots one-dimensional TupleCut values.
virtual DataRep * getDataRep(int index) const
Returns the specified DataRep or null pointer if it doesn't exits.
The base class for the Projector hierarchy.
static DataRepController * instance()
Returns the pointer to the singleton instance.
The abstract base class for views.
hippodraw::TupleCut class interface
hippodraw::CutController class interface
void addCuts(const std::vector< PlotterBase * > &cut_list, PlotterBase *plotter)
Adds each of the existing cuts in the sequence to the plotter.
bool operator==(const double &x, const dequal< double > &d)
void createIdCut(const DataSource *source, DataSource *destination)
Creates a new column in destination DataSource with elements of value 1.0 if element of source is con...
DataSource * getDataSource(const PlotterBase *plotter)
Returns the Datasource for the plotter's selected DataRep or the DataSource used by all the DataRep o...
void appendToWeb(PlotterBase *plotter, PlotterList_t &web)
Appends to the web the plotter and any cuts targeting the contained active data rep.
void removeCut(PlotterBase *cut_plotter, PlotterBase *plotter)
Removes the cut from the plotter.
virtual void setDirty(bool yes=true)
Sets the dirty flag.
virtual void addCut(const TupleCut *cut)
Adds the cut to the list of cuts.
Cut1DPlotter class interface.
std::vector< PlotterBase * > m_cut_list
A temporary list of selected (cut) PlotterBase objects.
A singleton class that handles the application logic for cuts.
void fillCutList(const std::vector< PlotterBase * > &plotter_list, std::vector< CutPlotter * > &cut_list)
Clears and fills the cut_list with those PlotterBase objects in plotter_list that are CutPlotter obje...
hippodraw::ViewBase class interface
void setZoomPan(PlotterBase *plotter, hippodraw::Axes::Type axis, bool yes)
Sets the zoom/pan status of plotter.
virtual ProjectorBase * getProjector() const
Returns the Projector object controlling the data.
DisplayController class interface declaration.
hippodraw::NTupleProjector class interface
PlotterBase * findPlotter(const DataRep *data_rep)
Finds and returns the PlotterBase object containing the data_rep.
list< QAction * >::iterator it
hippodraw::PlotterBase class interface.
std::list< std::pair< PlotterBase *, Axes::Type > > m_zoom_pan
A list of cutplotter-axis pair that have been placed in zoom/pan mode.
static void fillAcceptedRows(std::vector< bool > &array, const DataSource *source, const std::vector< const TupleCut * > &cuts)
Base class for DataSource.