00001
00002
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00021
00030
00031
00032
00033
00034
00035
00036 #include "AIDA/IHistogram1D.h"
00037 #include "AIDA/IHistogram2D.h"
00038 #include "AIDA/ICloud2D.h"
00039 #include "AIDA/IProfile1D.h"
00040 #include "AIDA/IDataPointSet.h"
00041 #include "AIDA_PlotterRegion.h"
00042 #include "AIDA_PlotterStyle.h"
00043 #include "AIDA_Info.h"
00044 #include "AIDA_PlotterLayout.h"
00045 #include "GracePlotter/PlotterRegion.h"
00046
00047
00048 #include <iostream>
00049
00050
00051 namespace Anaphe {
00052 namespace AIDA_Plotter_Grace {
00053
00054
00055
00057
00058
00059
00061
00062 AIDA_PlotterRegion::AIDA_PlotterRegion()
00063 : rep(0),
00064 ownRep(false)
00065 {
00066
00067 }
00068
00069
00070
00071
00072
00073 AIDA_PlotterRegion::AIDA_PlotterRegion(PlotterRegion* x, bool b)
00074 : rep(x),
00075 ownRep(b)
00076 {
00077
00078 }
00079
00080
00081
00082
00083 AIDA_PlotterRegion::~AIDA_PlotterRegion()
00084 {
00085 if (ownRep) delete rep;
00086 }
00087
00088
00089
00090
00092
00093
00094
00096
00097 bool AIDA_PlotterRegion::plot(const AIDA::IBaseHistogram& histogram,
00098 const std::string& options)
00099 {
00100 return plot(histogram, 0, options);
00101 }
00102
00103
00104
00105
00106 bool AIDA_PlotterRegion::plot(const AIDA::IBaseHistogram& histogram,
00107 const AIDA::IPlotterStyle& style,
00108 const std::string& options)
00109 {
00110 return plot(histogram, &style, options);
00111 }
00112
00113
00114
00115
00116 bool AIDA_PlotterRegion::plot(const AIDA::IFunction& function,
00117 const std::string& options)
00118 {
00119 return plot(function, 0, options);
00120 }
00121
00122
00123
00124
00125 bool AIDA_PlotterRegion::plot(const AIDA::IFunction& function,
00126 const AIDA::IPlotterStyle& style,
00127 const std::string& options)
00128 {
00129 return plot(function, &style, options);
00130 }
00131
00132
00133
00134
00135 bool AIDA_PlotterRegion::plot(const AIDA::IDataPointSet& dataPointSet,
00136 const std::string& options)
00137 {
00138 return plot(dataPointSet, 0, options);
00139 }
00140
00141
00142
00143
00144 bool AIDA_PlotterRegion::plot(const AIDA::IDataPointSet& dataPointSet,
00145 const AIDA::IPlotterStyle& style,
00146 const std::string& options)
00147 {
00148 return plot(dataPointSet, &style, options);
00149 }
00150
00151
00152
00153
00154 bool AIDA_PlotterRegion::remove(const AIDA::IBaseHistogram& histogram)
00155 {
00156
00157 return 0;
00158 }
00159
00160
00161
00162
00163 bool AIDA_PlotterRegion::remove(const AIDA::IFunction& function)
00164 {
00165
00166 return 0;
00167 }
00168
00169
00170
00171
00172 bool AIDA_PlotterRegion::remove(const AIDA::IDataPointSet& dataPointSet)
00173 {
00174
00175 return 0;
00176 }
00177
00178
00179
00180
00181 void AIDA_PlotterRegion::clear()
00182 {
00183 if (rep == 0) {
00184 crisis();
00185 return;
00186 }
00187 rep->clear();
00188 }
00189
00190
00191
00192
00193 bool AIDA_PlotterRegion::setParameter(const std::string& parameter,
00194 const std::string& options)
00195 {
00196 if (rep == 0) {
00197 crisis();
00198 return false;
00199 }
00200 return rep->setParameter(parameter, options);
00201 }
00202
00203
00204
00205
00206 std::vector<std::string>
00207 AIDA_PlotterRegion::availableParameterOptions(const std::string& parameter) const
00208 {
00209 if (rep == 0) {
00210 crisis();
00211 return std::vector<std::string>();
00212 }
00213 return rep->availableOptions(parameter);
00214 }
00215
00216
00217
00218
00219 std::vector<std::string> AIDA_PlotterRegion::availableParameters() const
00220 {
00221 if (rep == 0) {
00222 crisis();
00223 return std::vector<std::string>();
00224 }
00225 return rep->availableParameters();
00226 }
00227
00228
00229
00230
00231 std::string AIDA_PlotterRegion::parameterValue(const std::string& param) const
00232 {
00233 if (!rep) {
00234 crisis();
00235 return "";
00236 }
00237 return rep->parameterValue(param);
00238 }
00239
00240
00241
00242
00243 AIDA::IPlotterStyle& AIDA_PlotterRegion::style()
00244 {
00245 static AIDA_PlotterStyle pr;
00246 if (rep == 0) {
00247 crisis();
00248 return pr;
00249 }
00250 Style& realStyle = rep->style();
00251 pr.setRep(realStyle, false);
00252 return pr;
00253 }
00254
00255
00256
00257
00258 bool AIDA_PlotterRegion::setStyle(const AIDA::IPlotterStyle& style)
00259 {
00260 if (rep == 0) {
00261 crisis();
00262 return false;
00263 }
00264 const AIDA_PlotterStyle* pr = dynamic_cast<const AIDA_PlotterStyle*>(&style);
00265 if (pr == 0) return false;
00266 AIDA_PlotterStyle* ncpr = const_cast<AIDA_PlotterStyle*>(pr);
00267 Style* gs = ncpr->theRep();
00268 if (gs == 0) return false;
00269 else {
00270 rep->setStyle(*gs);
00271 return true;
00272 }
00273 }
00274
00275
00276
00277
00278 bool AIDA_PlotterRegion::applyStyle(const AIDA::IPlotterStyle& style)
00279 {
00280
00281 return setStyle(style);
00282 }
00283
00284
00285
00286
00287 void AIDA_PlotterRegion::setTitle(const std::string& title)
00288 {
00289
00290 return;
00291 }
00292
00293
00294
00295
00296 bool AIDA_PlotterRegion::setXLimits(double min, double max)
00297 {
00298 if (rep == 0) {
00299 crisis();
00300 return false;
00301 }
00302 return rep->setXLimits(min, max);
00303 }
00304
00305
00306
00307
00308 bool AIDA_PlotterRegion::setYLimits(double min, double max)
00309 {
00310 if (rep == 0) {
00311 crisis();
00312 return false;
00313 }
00314 return rep->setYLimits(min, max);
00315 }
00316
00317
00318
00319
00320 bool AIDA_PlotterRegion::setZLimits(double min, double max)
00321 {
00322 return false;
00323 }
00324
00325
00326
00327
00328 AIDA::IPlotterLayout& AIDA_PlotterRegion::layout()
00329 {
00330 static AIDA_PlotterLayout pr;
00331 if (rep == 0) {
00332 crisis();
00333 return pr;
00334 }
00335 Layout& realLayout = rep->layout();
00336 pr.setRep(realLayout, false);
00337 return pr;
00338 }
00339
00340
00341
00342
00343 bool AIDA_PlotterRegion::setLayout(const AIDA::IPlotterLayout& layout)
00344 {
00345 if (rep == 0) {
00346 crisis();
00347 return false;
00348 }
00349 const AIDA_PlotterLayout* pr = dynamic_cast<const AIDA_PlotterLayout*>(&layout);
00350 if (pr == 0) return false;
00351 AIDA_PlotterLayout* ncpr = const_cast<AIDA_PlotterLayout*>(pr);
00352 Layout* gl = ncpr->theRep();
00353 if (gl == 0) return false;
00354 else {
00355 return rep->setLayout(*gl);
00356 }
00357 }
00358
00359
00360
00361
00362 AIDA::IInfo& AIDA_PlotterRegion::info()
00363 {
00364 static AIDA_Info pr;
00365 if (rep == 0) {
00366 crisis();
00367 return pr;
00368 }
00369 LegendBox& realInfo = rep->legendBox();
00370 pr.setRep(realInfo, false);
00371 return pr;
00372 }
00373
00374
00375
00376
00377
00378 PlotterRegion* AIDA_PlotterRegion::theRep()
00379 {
00380 return rep;
00381 }
00382
00383
00384
00385 void AIDA_PlotterRegion::setRep(PlotterRegion& newRep, bool own)
00386 {
00387 if (ownRep) delete rep;
00388 rep = &newRep;
00389 ownRep = own;
00390 }
00391
00392
00393
00394
00395
00397
00398
00399
00401
00402 bool AIDA_PlotterRegion::plot(const AIDA::IBaseHistogram& histogram,
00403 const AIDA::IPlotterStyle* style,
00404 const std::string& options)
00405 {
00406 if (rep == 0) {
00407 crisis();
00408 return false;
00409 }
00410
00411
00412 AIDA_PlotterStyle* ncpr = 0;
00413 if (style != 0) {
00414 const AIDA_PlotterStyle* pr = dynamic_cast<const AIDA_PlotterStyle*>(style);
00415 if (pr != 0) ncpr = const_cast<AIDA_PlotterStyle*>(ncpr);
00416 }
00417 Style* realStyle = (ncpr == 0 ? 0 : ncpr->theRep());
00418 const AIDA::IBaseHistogram* bh = &histogram;
00419
00420
00421 const AIDA::IHistogram1D* h1 = dynamic_cast<const AIDA::IHistogram1D*>(bh);
00422 if (h1 != 0) {
00423 if (realStyle == 0) return rep->plot(*h1, options);
00424 else return rep->plot(*h1, *realStyle, options);
00425 }
00426 const AIDA::IHistogram2D* h2 = dynamic_cast<const AIDA::IHistogram2D*>(bh);
00427 if (h2 != 0) {
00428 if (realStyle == 0) return rep->plot(*h2, options);
00429 else return rep->plot(*h2, *realStyle, options);
00430 }
00431 const AIDA::ICloud2D* c2 = dynamic_cast<const AIDA::ICloud2D*>(bh);
00432 if (c2 != 0) {
00433 if (realStyle == 0) return rep->plot(*c2, options);
00434 else return rep->plot(*c2, *realStyle, options);
00435 }
00436 const AIDA::IProfile1D* pr = dynamic_cast<const AIDA::IProfile1D*>(bh);
00437 if (pr != 0) {
00438 if (realStyle == 0) return rep->plot(*pr, options);
00439 else return rep->plot(*pr, *realStyle, options);
00440 }
00441
00442 return false;
00443 }
00444
00445
00446
00447
00448 bool AIDA_PlotterRegion::plot(const AIDA::IFunction& function,
00449 const AIDA::IPlotterStyle* style,
00450 const std::string& options)
00451 {
00452 if (rep == 0) {
00453 crisis();
00454 return false;
00455 }
00456
00457
00458 AIDA_PlotterStyle* ncpr = 0;
00459 if (style != 0) {
00460 const AIDA_PlotterStyle* pr = dynamic_cast<const AIDA_PlotterStyle*>(style);
00461 if (pr != 0) ncpr = const_cast<AIDA_PlotterStyle*>(ncpr);
00462 }
00463 Style* realStyle = (ncpr == 0 ? 0 : ncpr->theRep());
00464
00465 if (realStyle == 0) return rep->plot(function, options);
00466 else return rep->plot(function, *realStyle, options);
00467 }
00468
00469
00470
00471
00472
00473 bool AIDA_PlotterRegion::plot(const AIDA::IDataPointSet& dataPointSet,
00474 const AIDA::IPlotterStyle* style,
00475 const std::string& options)
00476 {
00477 if (rep == 0) {
00478 crisis();
00479 return false;
00480 }
00481
00482
00483 AIDA_PlotterStyle* ncpr = 0;
00484 if (style != 0) {
00485 const AIDA_PlotterStyle* pr = dynamic_cast<const AIDA_PlotterStyle*>(style);
00486 if (pr != 0) ncpr = const_cast<AIDA_PlotterStyle*>(ncpr);
00487 }
00488 Style* realStyle = (ncpr == 0 ? 0 : ncpr->theRep());
00489
00490 if (realStyle == 0) return rep->plot(dataPointSet, options);
00491 else return rep->plot(dataPointSet, *realStyle, options);
00492 }
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503 void AIDA_PlotterRegion::crisis() const
00504 {
00505 std::cout << "*** AIDA_Plotter_Grace SEVERE ERROR: proxy failure in AIDA_PlotterRegion" << std::endl;
00506 }
00507
00508
00509
00510 }
00511 }
00512