[Thplot-cvs] CVS: thplot/src/Draw Axis.cpp,1.2,1.3 Axis.h,1.2,1.3 Curve.cpp,1.1.1.1,1.2 Curve.h,1.1.
Status: Pre-Alpha
Brought to you by:
apeden
|
From: Tony P. <ap...@us...> - 2002-07-02 17:20:46
|
Update of /cvsroot/thplot/thplot/src/Draw
In directory usw-pr-cvs1:/tmp/cvs-serv11105/src/Draw
Modified Files:
Axis.cpp Axis.h Curve.cpp Curve.h Grid.cpp Grid.h
Log Message:
Changes to support plotting multiple curves.
Index: Axis.cpp
===================================================================
RCS file: /cvsroot/thplot/thplot/src/Draw/Axis.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** Axis.cpp 30 Jun 2002 14:36:10 -0000 1.2
--- Axis.cpp 2 Jul 2002 17:20:42 -0000 1.3
***************
*** 65,69 ****
Axis::~Axis(void){}
! bool Axis::DrawGL(double min, double max, double delta, string pname ) {
float x2, y2;
int i;
--- 65,69 ----
Axis::~Axis(void){}
! bool Axis::DrawGL(double min, double max, double delta, ParamList& pnames ) {
float x2, y2;
int i;
***************
*** 147,151 ****
}
! if(titleson && !pname.empty() ) {
if(vertical) {
#ifndef IS_CYGWIN
--- 147,160 ----
}
! if(titleson && !pnames.empty() ) {
! string tmps;
! tmps="";
! cout << "pnames.size(): " << pnames.size() << endl;
! for(unsigned j=0;j<pnames.size();j++) {
! tmps += pnames[j];
! if ( j < pnames.size()-1 ) {
! tmps += ", ";
! }
! }
if(vertical) {
#ifndef IS_CYGWIN
***************
*** 155,163 ****
#endif
titleFont->draw(float(parent->getX())-20,float(parent->getY()+length/2),
! pname.c_str() );
titleFont->setStringRotation(0);
} else {
titleFont->draw(float(parent->getX()+length/2),float(parent->getY()-15),
! pname.c_str() );
}
--- 164,172 ----
#endif
titleFont->draw(float(parent->getX())-20,float(parent->getY()+length/2),
! tmps.c_str() );
titleFont->setStringRotation(0);
} else {
titleFont->draw(float(parent->getX()+length/2),float(parent->getY()-15),
! tmps.c_str() );
}
Index: Axis.h
===================================================================
RCS file: /cvsroot/thplot/thplot/src/Draw/Axis.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** Axis.h 30 Jun 2002 14:36:10 -0000 1.2
--- Axis.h 2 Jul 2002 17:20:42 -0000 1.3
***************
*** 48,52 ****
void tickLabels(bool enable) { labelson = enable; }
void setWidth(float w) { width = w; }
! bool DrawGL( double min, double max, double delta, string pname);
void setAxisLabel(string al) { axisLabel = al; }
string getAxisLabel(void) { return axisLabel; }
--- 48,52 ----
void tickLabels(bool enable) { labelson = enable; }
void setWidth(float w) { width = w; }
! bool DrawGL( double min, double max, double delta, ParamList& pnames);
void setAxisLabel(string al) { axisLabel = al; }
string getAxisLabel(void) { return axisLabel; }
Index: Curve.cpp
===================================================================
RCS file: /cvsroot/thplot/thplot/src/Draw/Curve.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** Curve.cpp 22 Jun 2002 11:57:11 -0000 1.1.1.1
--- Curve.cpp 2 Jul 2002 17:20:42 -0000 1.2
***************
*** 28,34 ****
#include <Data/csvData.h>
! Curve::Curve(Globals *g, Grid *p){
global=g;
parent=p;
lines=true;
symbols=true;
--- 28,35 ----
#include <Data/csvData.h>
! Curve::Curve(Globals *g, Grid *p, int idx){
global=g;
parent=p;
+ index=idx;
lines=true;
symbols=true;
***************
*** 43,47 ****
double x,y;
d = parent->getData();
! iDep = d->getParameterIdx( parent->getDepName() );
iIndep = d->getParameterIdx( parent->getIndepName() );
--- 44,48 ----
double x,y;
d = parent->getData();
! iDep = d->getParameterIdx( parent->getDepName(index) );
iIndep = d->getParameterIdx( parent->getIndepName() );
Index: Curve.h
===================================================================
RCS file: /cvsroot/thplot/thplot/src/Draw/Curve.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** Curve.h 22 Jun 2002 11:57:11 -0000 1.1.1.1
--- Curve.h 2 Jul 2002 17:20:42 -0000 1.2
***************
*** 35,39 ****
class Curve {
public:
! Curve(Globals *g, Grid *p );
~Curve(void);
--- 35,39 ----
class Curve {
public:
! Curve(Globals *g, Grid *p, int idx );
~Curve(void);
***************
*** 47,50 ****
--- 47,51 ----
Grid *parent;
csvData *data;
+ int index;
string ind_pname, dep_pname;
bool lines, symbols;
Index: Grid.cpp
===================================================================
RCS file: /cvsroot/thplot/thplot/src/Draw/Grid.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Grid.cpp 30 Jun 2002 14:36:44 -0000 1.3
--- Grid.cpp 2 Jul 2002 17:20:42 -0000 1.4
***************
*** 43,51 ****
}
! void Grid::setData(csvData *d, string indep_name, string dep_name) {
! data = d;
! indep = indep_name;
! dep = dep_name;
! curves.push_back( new Curve(global,this) );
}
--- 43,57 ----
}
! void Grid::setData(csvData *d, string independent, ParamList dependents) {
! if( d != NULL ) {
! data = d;
! indep_names.clear();
! indep_names.push_back(independent);
! dep_names = dependents;
! curves.clear();
! for ( unsigned i=0;i<dependents.size();i++) {
! curves.push_back( new Curve(global,this,i) );
! }
! }
}
***************
*** 62,87 ****
if(independent) {
if( data != NULL ) {
! as.setMax( data->getMax(indep) );
! as.setMin( data->getMin(indep) );
as.setNdiv( independent->getNticks() );
indep_min = as.getASMin();
indep_max = as.getASMax();
! indep2grid = w/(indep_max - indep_min);
! independent->DrawGL(indep_min, indep_max,as.getASDelta(), indep );
} else {
! independent->DrawGL(0,0,0,"");
}
}
if(dependent) {
if( data != NULL ) {
! as.setMax( data->getMax(dep) );
! as.setMin( data->getMin(dep) );
as.setNdiv( dependent->getNticks() );
dep_min = as.getASMin();
dep_max = as.getASMax();
dep2grid = h/(dep_max - dep_min);
! dependent->DrawGL(dep_min, dep_max, as.getASDelta(),dep);
} else {
! dependent->DrawGL(0,0,0,"");
}
}
--- 68,103 ----
if(independent) {
if( data != NULL ) {
! as.setMax( data->getMax( indep_names[0] ) );
! as.setMin( data->getMin( indep_names[0] ) );
as.setNdiv( independent->getNticks() );
indep_min = as.getASMin();
indep_max = as.getASMax();
! indep2grid = w/(indep_max - indep_min);
!
! independent->DrawGL(indep_min, indep_max,as.getASDelta(), indep_names );
} else {
! independent->DrawGL(0,0,0,indep_names);
}
}
if(dependent) {
if( data != NULL ) {
! float min, max;
! min=data->getMin( dep_names[0] );
! max=data->getMax( dep_names[0] );
! for(unsigned i=1;i<dep_names.size();i++) {
! if( data->getMin( dep_names[i] ) < min )
! min = data->getMin( dep_names[i] );
! if( data->getMax( dep_names[i] ) > max )
! max = data->getMax( dep_names[i] );
! }
! as.setMax( max );
! as.setMin( min );
as.setNdiv( dependent->getNticks() );
dep_min = as.getASMin();
dep_max = as.getASMax();
dep2grid = h/(dep_max - dep_min);
! dependent->DrawGL(dep_min, dep_max, as.getASDelta(),dep_names);
} else {
! dependent->DrawGL(0,0,0,dep_names);
}
}
Index: Grid.h
===================================================================
RCS file: /cvsroot/thplot/thplot/src/Draw/Grid.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** Grid.h 22 Jun 2002 11:57:09 -0000 1.1.1.1
--- Grid.h 2 Jul 2002 17:20:42 -0000 1.2
***************
*** 39,43 ****
double getW(void) { return w; }
double getH(void) { return h; }
! void setData(csvData* d, string independent, string dependent);
void clearData(void);
csvData* getData(void) { return data; }
--- 39,43 ----
double getW(void) { return w; }
double getH(void) { return h; }
! void setData(csvData* d, string independent, ParamList dependents);
void clearData(void);
csvData* getData(void) { return data; }
***************
*** 48,53 ****
double convertIndepCoord(double icoord);
double convertDepCoord(double dcoord);
! string getIndepName(void) { return indep; }
! string getDepName(void) { return dep; }
bool DrawGL(void);
--- 48,53 ----
double convertIndepCoord(double icoord);
double convertDepCoord(double dcoord);
! string getIndepName(void) { return indep_names[0]; }
! string getDepName(int idx) { return dep_names[idx]; }
bool DrawGL(void);
***************
*** 65,69 ****
CurveList curves;
! string indep,dep;
double indep2grid,indep_max,indep_min;
double dep2grid,dep_max,dep_min;
--- 65,71 ----
CurveList curves;
! ParamList indep_names;
! ParamList dep_names;
!
double indep2grid,indep_max,indep_min;
double dep2grid,dep_max,dep_min;
|