22 #include "TRootEmbeddedCanvas.h"
34 using std::stringstream;
40 QGGraph(), fStyleScatterPlot(new TGraph())
44 SetBit(kCanDelete, kFALSE);
50 QGGraph(scatterPlot), fStyleScatterPlot(new TGraph())
54 SetBit(kCanDelete, kFALSE);
77 vector<Color_t> standardColors;
78 standardColors.push_back(kRed - 3);
79 standardColors.push_back(kBlue + 1);
80 standardColors.push_back(kGreen + 2);
81 standardColors.push_back(kMagenta + 2);
82 standardColors.push_back(kCyan + 3);
85 map<Color_t, int> colorCount;
87 for ( list<QGScatterPlot*>::const_iterator plotIter
91 Color_t otherColor = (*plotIter)->GetMarkerColor();
92 vector<Color_t>::iterator colorIter
93 = find( standardColors.begin(), standardColors.end(), otherColor );
94 if ( colorIter != standardColors.end() ) {
95 ++colorCount[*colorIter];
100 Color_t leastUsedColor = standardColors.front();
101 int leastUsedNumber = colorCount[leastUsedColor];
102 for ( vector<Color_t>::const_iterator colorIter = standardColors.begin();
103 colorIter != standardColors.end();
105 if (colorCount[*colorIter] < leastUsedNumber) {
106 leastUsedColor = *colorIter;
107 leastUsedNumber = colorCount[*colorIter];
112 SetMarkerColor(leastUsedColor);
134 GetXaxis()->SetTitle(xAxisLabel.c_str());
135 GetYaxis()->SetTitle(yAxisLabel.c_str());
136 GetYaxis()->SetTitleOffset(1.35);
138 bool drawSuperimpose =
false;
142 drawSuperimpose =
true;
146 if (drawSuperimpose) {
183 TH1F *supportHistogram =
new TH1F();
184 supportHistogram->SetBit(kCanDelete, kTRUE);
185 supportHistogram->SetStats(kFALSE);
186 supportHistogram->SetBins(1, 0, 5);
187 supportHistogram->GetYaxis()->SetRangeUser(0, 20);
188 supportHistogram->Draw(
"AH");
221 cout <<
"Cannot generate the scatter plot because there is no file open" << endl;
227 cout <<
"Enter an x-axis variable for the scatter plot" << endl;
229 cout <<
"Enter a y-axis variable for the scatter plot" << endl;
231 chain->SetEstimate(chain->GetEntries());
233 chain->Draw(drawArgument.c_str(),
fCutsString.c_str(),
"goff");
234 Long64_t
N = chain->GetSelectedRows();
246 SetXVariable(scatterPlotEditWindow->GetScatterPlotParametersFrame()->GetXVariable());
247 SetYVariable(scatterPlotEditWindow->GetScatterPlotParametersFrame()->GetYVariable());
248 SetXUnits(scatterPlotEditWindow->GetScatterPlotParametersFrame()->GetXUnits());
249 SetYUnits(scatterPlotEditWindow->GetScatterPlotParametersFrame()->GetYUnits());
250 SetSuperimpose(scatterPlotEditWindow->GetScatterPlotParametersFrame()->IsSuperimposeSet());
252 cout <<
"QGScatterPlot::GetParametersFromEditWindow() Warning: dynamic_cast<QGScatterPlotEditWindow*> failed" << endl;
273 string oldName = TGraph::GetName();
274 string newName = name;
275 if (newName != oldName) {
279 TGraph::SetName(name);
290 TString valueTString(value);
292 if (valueTString.IsFloat()) {
293 SetMarkerColor(valueTString.Atoi());
297 if (valueTString.IsFloat()) {
298 SetMarkerSize(valueTString.Atof());
302 if (valueTString.IsFloat()) {
303 SetMarkerStyle(valueTString.Atoi());
void RemoveFromDrawnPlots(QGPlot *plot)
Remove pointer to a plot from the list of drawn plots.
void AddToDrawnPlots(QGPlot *plot)
Add pointer to a plot to the list of drawn plots.
QGPlotFrame * GetPlotFrame()
Get pointer to the plot frame.
QGFileHandler * GetFileHandler() const
Get pointer to file handler.
void ClearDrawnPlots()
Clears the collection of drawn plots.
std::list< QGPlot * > & GetDrawnPlots()
Get collection of drawn plots.
bool IsFileOpen()
Check whether a file is open.
QChain * GetQChain()
Get a pointer to the chian.
Base class for scatter plots and pulses.
virtual void Reset()
Reset the graph to an empty state.
virtual void SetPoints(Int_t n, const Double_t *x, const Double_t *y)
Set the points of the graph.
QGPlotStyleFrame * GetPlotStyleFrame()
Get pointer to the plot style frame.
virtual void SetPlot(QGPlot *plot)=0
Set plot, pure virtual function must be overriden by derived classes.
TRootEmbeddedCanvas * GetEmbeddedCanvas()
Get pointer to canvas.
TRootEmbeddedCanvas * GetEmbeddedCanvas()
Get pointer to embedded canvas.
virtual void SetSuperimpose(bool flag=false)
Set whether the plot should be superimposed.
virtual std::string GeneratePlotName(const std::string &baseName) const
Generate a name for the plot.
virtual const std::string & GetYUnits() const
Get y-axis units.
virtual bool IsNameInUse(const std::string &name) const
Check whether string is the name of any plot.
std::string fXVariable
X-axis variable.
QGPlotEditWindow * fPlotEditWindow
Pointer to plot edit window.
virtual const std::string & GetXUnits() const
Get x-axis units.
virtual void SetProperty(const std::string &key, const std::string &value)
Set property (used for opening a session)
std::string fCutsString
Cuts in a single string.
virtual void SetXVariable(const std::string &x)
Set X-axis variable.
virtual void SetYVariable(const std::string &y)
Set Y-axis variable.
std::string fYVariable
Y-axis variable.
virtual const std::string & GetXVariable() const
Get x-axis variable.
virtual const std::string & GetYVariable() const
Get y-axis variable.
bool fSuperimpose
Indicates whether plot should be superimposed on existing plot.
QGCanvasWindow * fCanvasWindow
Canvas window to which plot is associated.
virtual void SetXUnits(const std::string &units)
Set X-axis units.
virtual void SetYUnits(const std::string &units)
Set Y-axis units.
Class for scatter plot edit window.
Class for GUI scatter plots.
void DisplayEditWindow()
Display edit window.
void Display()
Display scatter plot.
void SetName(const char *name=0)
Set name of the scatter plot.
void SetProperty(const std::string &key, const std::string &value)
Set property (used for opening a session)
void Generate(QChain *chain=0)
Generate the scatter plot.
void Duplicate()
Duplicate the scatter plot.
void GetParametersFromEditWindow()
Get parameters from edit window.
void AutoSetStyle()
Automatically set the scatter plot style.
QGScatterPlot()
Default constructor.
void Erase()
Erase the scatter plot.
TGraph * fStyleScatterPlot
Mini-scatter plot to show style of this scatter plot.
void MakeStylePlot()
Make style plot.
static std::list< QGScatterPlot * > fScatterPlots
Collection of pointers to all QGScatterPlots.
void DrawStyleScatterPlot()
Draw a mini-scatter plot showing the style of the scatter plot.
virtual ~QGScatterPlot()
Destructor.