00001
00012 #ifdef HAVE_CONFIG_H
00013 #include "config.h"
00014 #else
00015 #ifdef _MSC_VER
00016
00017 #include "msdevstudio/MSconfig.h"
00018 #endif //_MSC_VER
00019 #endif
00020
00021 #include "FuncParmRep.h"
00022
00023 #include "functions/FunctionBase.h"
00024 #include "graphics/ViewBase.h"
00025 #include "projectors/FunctionProjector.h"
00026
00027 #ifdef SSTREAM_DEFECT
00028 #include <strstream>
00029 using std::ostrstream;
00030 #else
00031 #include <sstream>
00032 using std::ostringstream;
00033 #endif
00034
00035 using std::string;
00036 using std::vector;
00037
00038 FuncParmRep::FuncParmRep ( )
00039 : TextRepBase ( "Function Parameters" )
00040 {
00041 }
00042
00043 FuncParmRep::FuncParmRep ( const FuncParmRep & rep )
00044 : TextRepBase( rep )
00045 {
00046 }
00047
00048 RepBase * FuncParmRep::clone ()
00049 {
00050 return new FuncParmRep( *this );
00051 }
00052
00053 void
00054 FuncParmRep::
00055 drawProjectedValues ( ProjectorBase & proj,
00056 ViewBase & view )
00057 {
00058 const FunctionProjector & projector
00059 = dynamic_cast< const FunctionProjector & > ( proj );
00060
00061 FunctionBase * function = projector.function ();
00062
00063 #ifdef SSTREAM_DEFECT
00064 ostrstream strm_text;
00065 #else
00066 ostringstream strm_text;
00067 #endif
00068 const string & name = function->name ();
00069 strm_text << name << std::ends;
00070
00071 string str_text ( strm_text.str () );
00072 float y_pos = 0.0;
00073 view.drawText ( str_text, 5.0, y_pos, m_size, 0, 'l', 't', true );
00074
00075 const vector < string > & parm_names = function->parmNames ();
00076 const vector < double > & parm_values =function->getParameters ();
00077
00078 for ( unsigned int i = 0; i < parm_names.size (); i++ ) {
00079 y_pos += m_size;
00080 strm_text.seekp ( 0 );
00081 strm_text << parm_names[i] << " = " << parm_values[i] << std::ends;
00082 str_text = strm_text.str();
00083 view.drawText ( str_text, 10.0, y_pos, m_size, 0, 'l', 't', true );
00084 }
00085 }