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

AIDA_DataStyle.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:49:35 2002
00032 // 
00033 
00034 
00035 
00036 #include "AIDA_DataStyle.h"
00037 #include "AIDA_LineStyle.h"
00038 #include "AIDA_FillStyle.h"
00039 #include "AIDA_MarkerStyle.h"
00040 #include "GracePlotter/PlotStyle.h"
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_DataStyle::AIDA_DataStyle()
00058   : rep(0),
00059     ownRep(false)
00060 {
00061   // no-op
00062 }
00063 
00064 
00065 
00066 AIDA_DataStyle::AIDA_DataStyle(PlotStyle* x, bool b)
00067   : rep(x),
00068     ownRep(b)
00069 {
00070   // no-op
00071 }
00072 
00073 
00074 
00075 
00076 AIDA_DataStyle::~AIDA_DataStyle()
00077 {
00078   if (ownRep) delete rep;
00079 }
00080 
00081 
00082 
00083 
00085 //                //
00086 // Public methods //
00087 //                //
00089 
00090 void AIDA_DataStyle::reset()
00091 {
00092   if (!rep) { 
00093     crisis();
00094     return;
00095   }
00096   rep->reset();
00097 }
00098 
00099 
00100 
00101 
00102 bool AIDA_DataStyle::setParameter(const std::string& paramName, 
00103                                     const std::string& options)
00104 {
00105   if (!rep) { 
00106     crisis();
00107     return false;
00108   }
00109   return rep->setParameter(paramName,options);
00110 }
00111 
00112 
00113 
00114 
00115 std::string AIDA_DataStyle::parameterValue(const std::string& param) const
00116 {
00117   if (!rep) { 
00118     crisis();
00119     return "";
00120   }
00121   return rep->parameterValue(param);
00122 }
00123 
00124 
00125 
00126 
00127 std::vector<std::string> AIDA_DataStyle::availableParameters() const
00128 {
00129   if (!rep) { 
00130     crisis();
00131     return std::vector<std::string>();
00132   }
00133   return rep->availableParameters();
00134 }
00135 
00136 
00137 
00138 
00139 std::vector<std::string> AIDA_DataStyle::availableParameterOptions(const std::string& paramName) const
00140 {
00141   if (!rep) { 
00142     crisis();
00143     return std::vector<std::string>();
00144   }
00145   return rep->availableOptions(paramName);
00146 }
00147 
00148 
00149 
00150 
00151 AIDA::ILineStyle & AIDA_DataStyle::lineStyle()
00152 {
00153   static AIDA_LineStyle pr;
00154   if (!rep) { 
00155     crisis();
00156     return pr;
00157   }
00158   LineStyle& gls = rep->lineStyle();
00159   pr.setRep(gls,false);
00160   return pr;
00161 }
00162 
00163 
00164 
00165 
00166 AIDA::IMarkerStyle & AIDA_DataStyle::markerStyle()
00167 {
00168   static AIDA_MarkerStyle pr;
00169   if (!rep) { 
00170     crisis();
00171     return pr;
00172   }
00173   MarkerStyle& gms = rep->markerStyle();
00174   pr.setRep(gms,false);
00175   return pr;
00176 }
00177 
00178 
00179 
00180 
00181 AIDA::IFillStyle & AIDA_DataStyle::fillStyle()
00182 {
00183   static AIDA_FillStyle pr;
00184   if (!rep) { 
00185     crisis();
00186     return pr;
00187   }
00188   FillStyle& gfs = rep->fillStyle();
00189   pr.setRep(gfs,false);
00190   return pr; 
00191 }
00192 
00193 
00194 
00195 
00196 bool AIDA_DataStyle::setLineStyle(const AIDA::ILineStyle & lineStyle)
00197 {
00198   if (!rep) { 
00199     crisis();
00200     return false;
00201   }
00202   const AIDA_LineStyle* pr = dynamic_cast<const AIDA_LineStyle*>(&lineStyle);
00203   if (!pr) return false;
00204   AIDA_LineStyle* ncpr = const_cast<AIDA_LineStyle*>(pr);
00205   LineStyle* tsrep = ncpr->theRep();
00206   if (tsrep == 0) return false;
00207   else {
00208     rep->setLineStyle(*tsrep);
00209     return true;
00210   }
00211 }
00212 
00213 
00214 
00215 
00216 bool AIDA_DataStyle::setMarkerStyle(const AIDA::IMarkerStyle & markerStyle)
00217 {
00218   if (!rep) { 
00219     crisis();
00220     return false;
00221   }
00222   const AIDA_MarkerStyle* pr = dynamic_cast<const AIDA_MarkerStyle*>(&markerStyle);
00223   if (!pr) return false;
00224   AIDA_MarkerStyle* ncpr = const_cast<AIDA_MarkerStyle*>(pr);
00225   MarkerStyle* tsrep = ncpr->theRep();
00226   if (tsrep == 0) return false;
00227   else {
00228     rep->setMarkerStyle(*tsrep);
00229     return true;
00230   }
00231 }
00232 
00233 
00234 
00235 
00236 bool AIDA_DataStyle::setFillStyle(const AIDA::IFillStyle & fillStyle)
00237 {
00238   if (!rep) { 
00239     crisis();
00240     return false;
00241   }
00242   const AIDA_FillStyle* pr = dynamic_cast<const AIDA_FillStyle*>(&fillStyle);
00243   if (!pr) return false;
00244   AIDA_FillStyle* ncpr = const_cast<AIDA_FillStyle*>(pr);
00245   FillStyle* tsrep = ncpr->theRep();
00246   if (tsrep == 0) return false;
00247   else {
00248     rep->setFillStyle(*tsrep);
00249     return true;
00250   }
00251 }
00252 
00253 
00254 
00255 
00256 PlotStyle* AIDA_DataStyle::theRep()
00257 {
00258   return rep;
00259 }
00260 
00261 
00262 
00263 void AIDA_DataStyle::setRep(PlotStyle& newRep, bool ownership)
00264 {
00265   if (ownRep) delete rep;
00266   rep = &newRep;
00267   ownRep = ownership;
00268 }
00269 
00270 
00271 
00272 
00274 //                 //
00275 // Private methods //
00276 //                 //
00278 
00279 void AIDA_DataStyle::crisis() const
00280 {
00281   std::cout << "*** AIDA_Plotter_Grace ERROR: proxy failure in AIDA_DataStyle" << std::endl; 
00282 }
00283 
00284 
00285 
00286 } // end of namespace AIDA_Plotter_Grace
00287 } // end of namespace Anaphe
00288 

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