~ubuntu-branches/ubuntu/gutsy/matplotlib/gutsy

« back to all changes in this revision

Viewing changes to src/_ns_transforms.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Bienia
  • Date: 2007-07-31 23:04:56 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070731230456-lfmr0h69yh1i37w1
Tags: 0.90.1-2ubuntu1
* Merge from Debian unstable. Remaining changes:
  + debian/rules:
    - Check only the files for the python version which just got installed
      (fixes FTBFS).
    - Modify Maintainer value to match DebianMaintainerField spec.

Show diffs side-by-side

added added

removed removed

Lines of Context:
322
322
}
323
323
 
324
324
Py::Object
325
 
Bbox::overlaps(const Py::Tuple &args) {
 
325
Bbox::overlaps(const Py::Tuple &args, const Py::Dict &kwargs) {
326
326
  _VERBOSE("Bbox::overlaps");
327
327
  args.verify_length(1);
328
328
 
329
329
  if (! check(args[0]))
330
330
    throw Py::TypeError("Expected a bbox");
331
331
 
332
 
  int x = Py::Int( overlapsx(args) );
333
 
  int y = Py::Int( overlapsy(args) );
 
332
 
 
333
 
 
334
  int x = Py::Int( overlapsx(args, kwargs) );
 
335
  int y = Py::Int( overlapsy(args, kwargs) );
334
336
  return Py::Int(x&&y);
335
337
}
336
338
 
343
345
}
344
346
 
345
347
Py::Object
346
 
Bbox::overlapsx(const Py::Tuple &args) {
 
348
Bbox::overlapsx(const Py::Tuple &args, const Py::Dict &kwargs) {
347
349
  _VERBOSE("Bbox::overlapsx");
348
350
  args.verify_length(1);
349
351
 
350
352
  if (! check(args[0]))
351
353
    throw Py::TypeError("Expected a bbox");
352
354
 
 
355
  int ignoreend = false;
 
356
  if (kwargs.hasKey("ignoreend")) {
 
357
    ignoreend = Py::Int(kwargs["ignoreend"]);
 
358
  }
 
359
 
353
360
  Bbox* other = static_cast<Bbox*>(args[0].ptr());
354
361
 
355
362
  double minx = _ll->xval();
358
365
  double ominx = other->_ll->xval();
359
366
  double omaxx = other->_ur->xval();
360
367
 
361
 
  int b =  ( ( (ominx>=minx) && (ominx<=maxx)) ||
362
 
             ( (minx>=ominx) && (minx<=omaxx)) );
 
368
  int b=0;
 
369
  if (ignoreend) {
 
370
    b =  ( ( (ominx>minx) && (ominx<maxx)) ||
 
371
           ( (minx>ominx) && (minx<omaxx)) );
 
372
  }
 
373
  else{
 
374
    b =  ( ( (ominx>=minx) && (ominx<=maxx)) ||
 
375
           ( (minx>=ominx) && (minx<=omaxx)) );
 
376
 
 
377
  }
363
378
  return Py::Int(b);
364
379
 
365
380
}
366
381
 
367
382
Py::Object
368
 
Bbox::overlapsy(const Py::Tuple &args) {
 
383
Bbox::overlapsy(const Py::Tuple &args, const Py::Dict &kwargs) {
369
384
  _VERBOSE("Bbox::overlapsy");
370
385
  args.verify_length(1);
371
386
 
372
387
  if (! check(args[0]))
373
388
    throw Py::TypeError("Expected a bbox");
374
389
 
 
390
 
 
391
  int ignoreend = false;
 
392
  if (kwargs.hasKey("ignoreend")) {
 
393
    ignoreend = Py::Int(kwargs["ignoreend"]);
 
394
  }
 
395
 
375
396
  Bbox* other = static_cast<Bbox*>(args[0].ptr());
376
397
 
377
398
  double miny = _ll->yval();
381
402
  double omaxy = other->_ur->yval();
382
403
 
383
404
 
 
405
  int b=0;
 
406
  if (ignoreend) {
 
407
    b =  ( ( (ominy>miny) && (ominy<maxy)) ||
 
408
               ( (miny>ominy) && (miny<omaxy)) );
 
409
  }
 
410
  else {
 
411
    b =  ( ( (ominy>=miny) && (ominy<=maxy)) ||
 
412
               ( (miny>=ominy) && (miny<=omaxy)) );
384
413
 
385
 
  int b =  ( ( (ominy>=miny) && (ominy<=maxy)) ||
386
 
             ( (miny>=ominy) && (miny<=omaxy)) );
 
414
  }
387
415
  return Py::Int(b);
388
416
 
389
417
}
659
687
  try {
660
688
    xout = this->operator()(xin);
661
689
  }
 
690
  catch (const std::exception &e) {
 
691
    throw Py::ValueError(e.what());
 
692
  }
662
693
  catch(...) {
663
694
    throw Py::ValueError("Domain error on Func::map");
664
695
  }
691
722
  try {
692
723
    xy = this->operator()(xin, yin);
693
724
  }
 
725
  catch (const std::exception &e) {
 
726
    throw Py::ValueError(e.what());
 
727
  }
694
728
  catch(...) {
695
729
    throw Py::ValueError("Domain error on FuncXY nonlinear transform");
696
730
  }
853
887
  try {
854
888
    if (!_frozen) eval_scalars();
855
889
  }
 
890
  catch (const std::exception &e) {
 
891
    throw Py::ValueError(e.what());
 
892
  }
 
893
 
856
894
  catch(...) {
857
895
    throw Py::ValueError("Domain error on inverse_xy_tup");
858
896
  }
891
929
  try {
892
930
    if (!_frozen) eval_scalars();
893
931
  }
 
932
  catch (const std::exception &e) {
 
933
    Py_XDECREF(xyin);
 
934
    throw Py::ValueError(e.what());
 
935
  }
 
936
 
894
937
  catch(...) {
895
938
    Py_XDECREF(xyin);
896
939
    throw Py::ValueError("Domain error on Transformation::inverse_numerix_xy");
940
983
  try {
941
984
    if (!_frozen) eval_scalars();
942
985
  }
 
986
  catch (const std::exception &e) {
 
987
    throw Py::ValueError(e.what());
 
988
  }
943
989
  catch(...) {
944
990
    throw Py::ValueError("Domain error on nonlinear transform");
945
991
  }
954
1000
  try {
955
1001
    this->operator()(x, y);
956
1002
  }
 
1003
  catch (const std::exception &e) {
 
1004
    throw Py::ValueError(e.what());
 
1005
  }
957
1006
  catch(...) {
958
1007
    throw Py::ValueError("Domain error on nTransformation::xy_tup operator()(x,y)");
959
1008
  }
982
1031
  try {
983
1032
    if (!_frozen) eval_scalars();
984
1033
  }
 
1034
  catch (const std::exception &e) {
 
1035
    throw Py::ValueError(e.what());
 
1036
  }
985
1037
  catch(...) {
986
1038
    throw Py::ValueError("Domain error on Transformation::seq_x_y");
987
1039
  }
997
1049
    try {
998
1050
      this->operator()(thisx, thisy);
999
1051
    }
 
1052
    catch (const std::exception &e) {
 
1053
      throw Py::ValueError(e.what());
 
1054
    }
1000
1055
    catch(...) {
1001
1056
      throw Py::ValueError("Domain error on Transformation::seq_x_y operator()(thisx, thisy)");
1002
1057
    }
1036
1091
  try {
1037
1092
    if (!_frozen) eval_scalars();
1038
1093
  }
 
1094
  catch (const std::exception &e) {
 
1095
    Py_XDECREF(xyin);
 
1096
    throw Py::ValueError(e.what());
 
1097
  }
1039
1098
  catch(...) {
1040
1099
    Py_XDECREF(xyin);
1041
1100
    throw Py::ValueError("Domain error on Transformation::numerix_xy");
1106
1165
  try {
1107
1166
    if (!_frozen) eval_scalars();
1108
1167
  }
 
1168
  catch (const std::exception &e) {
 
1169
    throw Py::ValueError(e.what());
 
1170
  }
1109
1171
  catch(...) {
1110
1172
    throw Py::ValueError("Domain error on Transformation::numerix_x_y");
1111
1173
  }
1309
1371
  try {
1310
1372
    if (!_frozen) eval_scalars();
1311
1373
  }
 
1374
  catch (const std::exception &e) {
 
1375
    throw Py::ValueError(e.what());
 
1376
  }
1312
1377
  catch(...) {
1313
1378
    throw Py::ValueError("Domain error on Transformation::seq_xy_tups");
1314
1379
  }
1327
1392
    try {
1328
1393
      this->operator()(thisx, thisy);
1329
1394
    }
 
1395
    catch (const std::exception &e) {
 
1396
      throw Py::ValueError(e.what());
 
1397
    }
1330
1398
    catch(...) {
1331
1399
      throw Py::ValueError("Domain error on nonlinear Transformation::seq_xy_tups operator()(thisx, thisy)");
1332
1400
    }
1948
2016
  try {
1949
2017
    eval_scalars();
1950
2018
  }
 
2019
  catch (const std::exception &e) {
 
2020
    throw Py::ValueError(e.what());
 
2021
  }
1951
2022
  catch(...) {
1952
2023
    throw Py::ValueError("Domain error on Affine deepcopy");
1953
2024
  }
2203
2274
  add_varargs_method("ur",      &Bbox::ur, "ur()\n");
2204
2275
  add_varargs_method("contains" , &Bbox::contains, "contains(x,y)\n");
2205
2276
  add_varargs_method("count_contains", &Bbox::count_contains, "count_contains(xys)\n");
2206
 
  add_varargs_method("overlaps" , &Bbox::overlaps, "overlaps(bbox)\n");
2207
 
  add_varargs_method("overlapsx" , &Bbox::overlapsx, "overlapsx(bbox)\n");
2208
 
  add_varargs_method("overlapsy" , &Bbox::overlapsy, "overlapsy(bbox)\n");
 
2277
  add_keyword_method("overlaps" , &Bbox::overlaps, "overlaps(bbox)\n");
 
2278
  add_keyword_method("overlapsx" , &Bbox::overlapsx, "overlapsx(bbox)\n");
 
2279
  add_keyword_method("overlapsy" , &Bbox::overlapsy, "overlapsy(bbox)\n");
2209
2280
  add_varargs_method("intervalx" , &Bbox::intervalx, "intervalx()\n");
2210
2281
  add_varargs_method("intervaly" , &Bbox::intervaly, "intervaly()\n");
2211
2282