Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Giovanni [dacav] Simoni
committed
Jun 14, 2010
1 parent
f136d3d
commit b705ae5
Showing
6 changed files
with
251 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#ifndef __defined_gnup_plots_hpp | ||
#define __defined_gnup_plots_hpp | ||
|
||
#include <gnup/gp_base.hpp> | ||
#include <gnup/except.hpp> | ||
|
||
namespace gnup { | ||
|
||
enum axis_t { DATA, AUTO }; | ||
|
||
class Plot2D : public Plot { | ||
|
||
public: | ||
Plot2D (const char *title, axis_t x, axis_t y); | ||
|
||
void writePlotting (Comm *c, DataSet::iterator begin, | ||
DataSet::iterator end); | ||
|
||
size_t getDimension (); | ||
|
||
void addVector (float x, float y); | ||
|
||
void writeFormat (Comm *c); | ||
|
||
private: | ||
struct { axis_t x, y; } coords; | ||
uint8_t realsize; | ||
|
||
}; | ||
|
||
class Plot3D : public Plot { | ||
|
||
public: | ||
Plot3D (const char *title, axis_t x, axis_t y, axis_t z); | ||
|
||
void writePlotting (Comm *c, DataSet::iterator begin, | ||
DataSet::iterator end); | ||
|
||
size_t getDimension (); | ||
|
||
void addVector (float x, float y, float z); | ||
|
||
void writeFormat (Comm *c); | ||
|
||
private: | ||
struct { axis_t x, y, z; } coords; | ||
|
||
uint8_t realsize; | ||
|
||
}; | ||
|
||
} | ||
|
||
#endif // __defined_gnup_plots_hpp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#include <gnup.hpp> | ||
|
||
namespace gnup { | ||
|
||
Plot2D::Plot2D (const char *title, axis_t x, axis_t y) | ||
: Plot(title) | ||
{ | ||
coords.x = x; | ||
coords.y = y; | ||
|
||
realsize = 0; | ||
if (x == DATA) realsize ++; | ||
if (y == DATA) realsize ++; | ||
} | ||
|
||
void Plot2D::writePlotting (Comm *c, DataSet::iterator b, | ||
DataSet::iterator e) | ||
{ | ||
// Alternative (incremental) value for the y axis (if not | ||
// specified). | ||
unsigned alt_y = 0; | ||
|
||
while (b != e) { | ||
const float *vals = *b; | ||
|
||
if (coords.x == AUTO) { | ||
c->command("%f\n", coords.y == DATA ? vals[1] : alt_y ++); | ||
} else { | ||
c->command("%f %f\n", | ||
vals[0], coords.y == DATA ? vals[1] : alt_y ++); | ||
} | ||
|
||
b ++; | ||
} | ||
} | ||
|
||
size_t Plot2D::getDimension () | ||
{ | ||
return 2; | ||
} | ||
|
||
void Plot2D::addVector (float x, float y) | ||
{ | ||
float v[] = {x, y}; | ||
Plot::addVector(v); | ||
} | ||
|
||
void Plot2D::writeFormat (Comm *c) | ||
{ | ||
} | ||
|
||
Plot3D::Plot3D (const char *title, axis_t x, axis_t y, axis_t z) | ||
: Plot(title) | ||
{ | ||
coords.x = x; | ||
coords.y = y; | ||
coords.z = z; | ||
|
||
realsize = 0; | ||
if (x == DATA) realsize ++; | ||
if (y == DATA) realsize ++; | ||
if (z == DATA) realsize ++; | ||
} | ||
|
||
size_t Plot3D::getDimension () | ||
{ | ||
return 3; | ||
} | ||
|
||
void Plot3D::addVector (float x, float y, float z) | ||
{ | ||
float v[] = {x, y, z}; | ||
Plot::addVector(v); | ||
} | ||
|
||
void Plot3D::writePlotting (Comm *c, DataSet::iterator b, | ||
DataSet::iterator e) | ||
{ | ||
// Alternative (incremental) values for the x and y axis (if not | ||
// specified). | ||
unsigned alt_x = 0, alt_y = 0, alt_z = 0; | ||
|
||
while (b != e) { | ||
const float *vals = *b; | ||
|
||
c->command("%f %f %f\n", | ||
coords.x == DATA ? vals[0] : alt_x ++, | ||
coords.y == DATA ? vals[1] : alt_y ++, | ||
coords.z == DATA ? vals[2] : alt_z ++); | ||
b ++; | ||
} | ||
} | ||
|
||
void Plot3D::writeFormat (Comm *c) | ||
{ | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
|
||
def main (argv=None): | ||
if not argv: args = sys.argv | ||
try: | ||
while 1: | ||
print >> sys.stderr, raw_input() | ||
except: | ||
pass | ||
return 0 | ||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) | ||
|