Main Page   Namespace List   Alphabetical List   Compound List   File List   Namespace Members   Compound Members  

AIDA_PlotterRegion.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00004 //                                                                     //
00005 //  This library is free software; you can redistribute it and/or      //
00006 //  modify it under the terms of the GNU Lesser General Public         //
00007 //  License as published by the Free Software Foundation; either       //
00008 //  version 2.1 of the License, or (at your option) any later version. //
00009 //                                                                     //
00010 //  This library is distributed in the hope that it will be useful,    //
00011 //  but WITHOUT ANY WARRANTY; without even the implied warranty of     //
00012 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   //
00013 //  Lesser General Public License for more details.                    //
00014 //                                                                     //
00015 //  You should have received a copy of the GNU Lesser General Public   //
00016 //  License along with this library (see file COPYING); if not, write  //
00017 //  to the Free Software Foundation, Inc., 59 Temple Place, Suite      //
00018 //  330, Boston, MA 02111-1307 USA, or contact the author.             //
00019 //                                                                     //
00021 
00030 // 
00031 // Created by user sang on Sun Oct  6 17:22:41 2002
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 // Constructors, destructor and operator= //
00059 //                                        //
00061 
00062 AIDA_PlotterRegion::AIDA_PlotterRegion()
00063   : rep(0),
00064     ownRep(false)
00065 {
00066   // no-op
00067 }
00068 
00069 
00070 
00071 
00072 
00073 AIDA_PlotterRegion::AIDA_PlotterRegion(PlotterRegion* x, bool b)
00074   : rep(x),
00075     ownRep(b)
00076 {
00077   // no-op
00078 }
00079 
00080 
00081 
00082 
00083 AIDA_PlotterRegion::~AIDA_PlotterRegion()
00084 {
00085   if (ownRep) delete rep;
00086 }
00087 
00088 
00089 
00090 
00092 //                //
00093 // Public methods //
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   //ND
00157   return 0;
00158 }
00159 
00160 
00161 
00162 
00163 bool AIDA_PlotterRegion::remove(const AIDA::IFunction& function)
00164 {
00165   //ND
00166   return 0;
00167 }
00168 
00169 
00170 
00171 
00172 bool AIDA_PlotterRegion::remove(const AIDA::IDataPointSet& dataPointSet)
00173 {
00174   //ND
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; //ND plugnplay message?
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   //ND no difference yet :-(
00281   return setStyle(style);
00282 }
00283 
00284 
00285 
00286 
00287 void AIDA_PlotterRegion::setTitle(const std::string& title)
00288 {
00289   //ND not possible in grace plotter yet
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; // no Z limits in Grace
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; //ND plugnplay message?
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 // Private methods //
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   // convert "AIDA::IPlotterStyle* style" to
00411   //         "Anaphe::Style* realStyle"   using lots of horrible casts
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   // dynamic cast in turn to all the AIDA leaf types which GracePlotter is able
00420   // to handle, When I find the correct one, plot it with or without the style.
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   // OK, I couldn't find a reasonable leaf type. bail out.
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   // convert "AIDA::IPlotterStyle* style" to
00457   //         "Anaphe::Style* realStyle"   using lots of horrible casts
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   // OK now plot it 
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   // convert "AIDA::IPlotterStyle* style" to
00482   //         "Anaphe::Style* realStyle"   using lots of horrible casts
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   // OK now plot it 
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 // private methods
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 } // end of namespace AIDA_Plotter_Grace
00511 } // end of namespace Anaphe
00512 

Generated on Tue Jan 28 13:30:45 2003 for Anaphe_AIDA_Plotter_Grace by doxygen1.2.16