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

AIDA_Plotter.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:16:54 2002
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 // Constructors, destructor and operator= //
00054 //                                        //
00056 
00057 AIDA_Plotter::AIDA_Plotter()
00058   : rep   (0),
00059     ownRep(false)
00060 {
00061   // no-op
00062 }
00063 
00064 
00065 
00066 
00067 AIDA_Plotter::AIDA_Plotter(Plotter* p, bool own)
00068   : rep   (p),
00069     ownRep(own)
00070 {
00071   // no-op
00072 }
00073 
00074 
00075 
00076 
00077 AIDA_Plotter::~AIDA_Plotter()
00078 {
00079   if (ownRep) delete rep;
00080 }
00081 
00082 
00083 
00084 
00086 //                //
00087 // Public methods //
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); // keeps ownership!
00098   if (newRegion == 0) return 0;
00099   static AIDA_PlotterRegion pr;
00100   pr.setRep(*newRegion, false);
00101   return &pr;
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 &pr;
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   //ND ?
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   //ND ?
00299   return false;
00300 }
00301 
00302 
00303 
00304 
00305 bool AIDA_Plotter::interact()
00306 {
00307   //ND ?
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; //ND plugnplay message?
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 // Private methods //
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 } // end of namespace AIDA_Plotter_Grace
00403 } // end of namespace Anaphe
00404 

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