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