29 #include "getopts/getopts.h"
33 #include "graph/graphic.hh"
49 GColor
_bg( 0, 140, 150 );
72 main(
int argc,
char **argv )
78 opts.addOption(
"" ,
"log-level",
"Set the log level (debug, warn, info, error)",
true );
79 opts.addOption(
"v",
"version" ,
"Display version info" ,
false );
80 opts.addOption(
"o",
"model" ,
"File with serialized model" ,
true );
81 opts.addOption(
"s",
"scale" ,
"Scale factor for model output" ,
true );
83 std::string log_level(
"info");
84 std::string model_file;
86 if ( ! opts.parse( argc, argv ) ) {
88 opts.showHelp( argv[0] );
97 while ( ( option = opts.cycle() ) >= 0 ) {
102 log_level = opts.getArgs( option );
105 printf(
"om_niche %s\n", om.
getVersion().c_str() );
106 printf(
"This is free software; see the source for copying conditions. There is NO\n");
107 printf(
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
111 model_file = opts.getArgs( option );
114 _scale = atoi( opts.getArgs( option ).c_str() );
123 if ( model_file.empty() ) {
125 printf(
"Please specify a model file\n");
151 alg->setNormalization( env );
154 int nmap = env->numLayers();
159 env->getExtremes( &min, &max );
166 else if ( nmap > 2 ) {
168 Log::instance()->
error(
"Maximum number of environmental variables (2) exceeded!\n" );
175 _presences = samp->getPresences();
176 _absences = samp->getAbsences();
181 GFrame *frame = createFrame(
"openModeller Niche Viewer", 1, dimx, dimy );
182 _cnv = frame->newCanvas( 0, 0, dimx, dimy );
183 _pm = frame->newPixmap(
_cnv, dimx, dimy );
187 _graph->scale( min[0], min[1], max[0], max[1] );
194 frame->funcShow(
draw );
201 catch ( std::exception& e ) {
239 Scalar xmin = graph->minX();
240 Scalar ymin = graph->minY();
241 Scalar xmax = graph->maxX();
242 Scalar ymax = graph->maxY();
243 Scalar xstep = graph->stepX();
244 Scalar ystep = graph->stepY();
251 for ( *y = ymin; *y < ymax; *y += ystep ) {
253 for ( *x = xmin; *x < xmax; *x += xstep ) {
255 GColor color = GColor::Blue;
257 graph->pixel(
float(*x),
float(*y), color );
260 if ( ! ( ++i % 10 ) ) {
273 if ( occurs && occurs->numOccurrences() ) {
280 for ( ; oc != occurs->end(); ++oc ) {
282 amb = env->get( (*oc)->x(), (*oc)->y() );
284 if ( amb.
size() >= 2 ) {
286 graph->markAxe( amb[0], amb[1], 1, color );
static ConfigurationPtr readXml(char const *filename)
double Scalar
Type of map values.
void draw_niche(GGraph *graph)
static Log * instance()
Returns the instance pointer, creating the object on the first call.
Log::Level getLogLevel(std::string level)
void setLevel(Level level)
EnvironmentPtr getEnvironment()
void error(const char *format,...)
'Error' level.
OccurrencesPtr _presences
void setupExternalResources()
AlgorithmPtr getAlgorithm()
int main(int argc, char **argv)
Scalar getValue(const ConstEnvironmentPtr &env, Coord x, Coord y)
static int searchDefaultDirs()
void draw_occur(GGraph *graph, const OccurrencesPtr &oc, GColor color)
const SamplerPtr & getSampler() const
std::vector< OccurrencePtr >::const_iterator const_iterator
void setModelConfiguration(const ConstConfigurationPtr &)