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_Plotter.h"
00037 #include "GracePlotter/Plotter.h"
00038 #include "AIDA_TitleStyle.h"
00039 #include "AIDA_PlotterRegion.h"
00040
00041 #include <iostream>
00042
00043
00044
00045 namespace Anaphe {
00046 namespace AIDA_Plotter_Grace {
00047
00048
00049
00050
00052
00053
00054
00056
00057 AIDA_Plotter::AIDA_Plotter()
00058 : rep (0),
00059 ownRep(false)
00060 {
00061
00062 }
00063
00064
00065
00066
00067 AIDA_Plotter::AIDA_Plotter(Plotter* p, bool own)
00068 : rep (p),
00069 ownRep(own)
00070 {
00071
00072 }
00073
00074
00075
00076
00077 AIDA_Plotter::~AIDA_Plotter()
00078 {
00079 if (ownRep) delete rep;
00080 }
00081
00082
00083
00084
00086
00087
00088
00090
00091 AIDA::IPlotterRegion* AIDA_Plotter::createRegion(double x, double y, double w, double h)
00092 {
00093 if (rep == 0) {
00094 crisis();
00095 return 0;
00096 }
00097 PlotterRegion* newRegion = rep->createRegion(x, y, w, h);
00098 if (newRegion == 0) return 0;
00099 static AIDA_PlotterRegion pr;
00100 pr.setRep(*newRegion, false);
00101 return ≺
00102 }
00103
00104
00105
00106
00107 bool AIDA_Plotter::createRegions(int columns, int rows, int index)
00108 {
00109 if (rep == 0) {
00110 crisis();
00111 return false;
00112 }
00113 return rep->createRegions(columns, rows, index);
00114 }
00115
00116
00117
00118
00119 AIDA::IPlotterRegion& AIDA_Plotter::currentRegion() const
00120 {
00121 static AIDA_PlotterRegion pr;
00122 if (rep == 0) {
00123 crisis();
00124 return pr;
00125 }
00126 PlotterRegion& realRegion = rep->currentRegion();
00127 pr.setRep(realRegion, false);
00128 return pr;
00129 }
00130
00131
00132
00133
00134 int AIDA_Plotter::currentRegionNumber() const
00135 {
00136 if (rep == 0) {
00137 crisis();
00138 return -1;
00139 }
00140 return rep->currentRegionNumber();
00141 }
00142
00143
00144
00145
00146 int AIDA_Plotter::numberOfRegions() const
00147 {
00148 if (rep == 0) {
00149 crisis();
00150 return 0;
00151 }
00152 return rep->numberOfRegions();
00153 }
00154
00155
00156
00157
00158 bool AIDA_Plotter::setCurrentRegionNumber(int index)
00159 {
00160 if (rep == 0) {
00161 crisis();
00162 return false;
00163 }
00164 return rep->setCurrentRegionNumber(index);
00165 }
00166
00167
00168
00169
00170 AIDA::IPlotterRegion& AIDA_Plotter::next()
00171 {
00172 static AIDA_PlotterRegion pr;
00173 if (rep == 0) {
00174 crisis();
00175 return pr;
00176 }
00177 PlotterRegion& realRegion = rep->next();
00178 pr.setRep(realRegion, false);
00179 return pr;
00180 }
00181
00182
00183
00184
00185 AIDA::IPlotterRegion* AIDA_Plotter::region(int index) const
00186 {
00187 if (rep == 0) {
00188 crisis();
00189 return 0;
00190 }
00191 PlotterRegion* realRegion = rep->region(index);
00192 if (realRegion == 0) return 0;
00193 static AIDA_PlotterRegion pr;
00194 pr.setRep(*realRegion, false);
00195 return ≺
00196 }
00197
00198
00199
00200
00201 void AIDA_Plotter::destroyRegions()
00202 {
00203 if (rep == 0) {
00204 crisis();
00205 return;
00206 }
00207 rep->destroyAllRegions();
00208 }
00209
00210
00211
00212
00213 void AIDA_Plotter::clearRegions()
00214 {
00215 if (rep == 0) {
00216 crisis();
00217 return;
00218 }
00219 rep->clearAllRegions();
00220 }
00221
00222
00223
00224
00225 bool AIDA_Plotter::setParameter(const std::string& parameter,
00226 const std::string& options)
00227 {
00228 if (rep == 0) {
00229 crisis();
00230 return false;
00231 }
00232 return rep->setParameter(parameter, options);
00233 }
00234
00235
00236
00237
00238 std::string AIDA_Plotter::parameterValue(const std::string& param) const
00239 {
00240 if (!rep) {
00241 crisis();
00242 return "";
00243 }
00244 return rep->parameterValue(param);
00245 }
00246
00247
00248
00249
00250 std::vector<std::string>
00251 AIDA_Plotter::availableParameterOptions(const std::string& parameter) const
00252 {
00253 if (rep == 0) {
00254 crisis();
00255 return std::vector<std::string>();
00256 }
00257 return rep->availableOptions(parameter);
00258 }
00259
00260
00261
00262
00263 std::vector<std::string> AIDA_Plotter::availableParameters() const
00264 {
00265 if (rep == 0) {
00266 crisis();
00267 return std::vector<std::string>();
00268 }
00269 return rep->availableParameters();
00270 }
00271
00272
00273
00274
00275 bool AIDA_Plotter::show()
00276 {
00277
00278 return true;
00279 }
00280
00281
00282
00283
00284 bool AIDA_Plotter::refresh()
00285 {
00286 if (rep == 0) {
00287 crisis();
00288 return false;
00289 }
00290 return rep->refresh();
00291 }
00292
00293
00294
00295
00296 bool AIDA_Plotter::hide()
00297 {
00298
00299 return false;
00300 }
00301
00302
00303
00304
00305 bool AIDA_Plotter::interact()
00306 {
00307
00308 return false;
00309 }
00310
00311
00312
00313
00314 bool AIDA_Plotter::writeToFile(const std::string& filename,
00315 const std::string& type)
00316 {
00317 if (rep == 0) {
00318 crisis();
00319 return false;
00320 }
00321 return rep->writeToFile(filename, type);
00322 }
00323
00324
00325
00326
00327 void AIDA_Plotter::setTitle(const std::string& title)
00328 {
00329 if (rep == 0) {
00330 crisis();
00331 return;
00332 }
00333 rep->setTitle(title);
00334 }
00335
00336
00337
00338
00339 AIDA::ITitleStyle& AIDA_Plotter::titleStyle()
00340 {
00341 static AIDA_TitleStyle pr;
00342 if (rep == 0) {
00343 crisis();
00344 return pr;
00345 }
00346 TitleStyle& realTitleStyle = rep->titleStyle();
00347 pr.setRep(realTitleStyle, false);
00348 return pr;
00349 }
00350
00351
00352
00353
00354 void AIDA_Plotter::setTitleStyle(const AIDA::ITitleStyle& style)
00355 {
00356 if (rep == 0) {
00357 crisis();
00358 return;
00359 }
00360 const AIDA_TitleStyle* pr = dynamic_cast<const AIDA_TitleStyle*>(&style);
00361 if (pr == 0) return;
00362 AIDA_TitleStyle* ncpr = const_cast<AIDA_TitleStyle*>(pr);
00363 TitleStyle* gts = ncpr->theRep();
00364 if (gts == 0) return;
00365 rep->setTitleStyle(*gts);
00366 }
00367
00368
00369
00370
00371 void AIDA_Plotter::setRep(Plotter& s, bool ownership)
00372 {
00373 if (ownRep) delete rep;
00374 rep = &s;
00375 ownRep = ownership;
00376 }
00377
00378
00379
00380 Plotter* AIDA_Plotter::theRep()
00381 {
00382 return rep;
00383 }
00384
00385
00386
00387
00388
00390
00391
00392
00394
00395 void AIDA_Plotter::crisis() const
00396 {
00397 std::cout << "*** AIDA_Plotter_Grace SEVERE ERROR: proxy failure in AIDA_Plotter" << std::endl;
00398 }
00399
00400
00401
00402 }
00403 }
00404