point.cpp

Go to the documentation of this file.
00001 #include "point.h"
00002 #include "runtime.h"
00003 #include "image-dialog.h"
00004 
00005 class PointPicker: public ImagePicker
00006 {
00007     PointValue point;
00008   public:
00009     PointPicker(ImageValue * I): ImagePicker(I) {};
00010     virtual Value * value() {return new PointValue(point);};
00011     virtual void nextPoint(PointValue point, bool right);
00012 };
00013 
00014 QString PointValue::toString()
00015 {
00016   return QString("(")+QString::number(x)+
00017     QString(", ")+QString::number(y)+
00018     QString(")");
00019 }
00020 
00021 bool PointValue::equals_same_type(Value * other) 
00022 {
00023   PointValue * o = (PointValue*)other;
00024   return x==o->x && y==o->y;
00025 }
00026 
00027 Value * Runtime::select(Value * image)
00028 {
00029   if (image==NULL)  return NULL;
00030   if (typeid(*image)!=typeid(ImageValue)) return NULL;
00031   ImageValue * I = (ImageValue*)image;
00032   PointPicker ip(I);
00033   if (ip.exec()==QDialog::Accepted)
00034     return ip.value();
00035   return NULL;
00036 }
00037 
00038 Value * Runtime::select(vector<Value*> v)
00039 {
00040   if (v.size()==1) return select(v[0]);
00041   return NULL;
00042 }
00043 
00044 PointValue PointValue::operator *(const PointValue& other) const
00045 {
00046   PointValue result;
00047   result.x = x*other.x;
00048   result.y = y*other.y;
00049   return result;
00050 }
00051 
00052 PointValue max(const PointValue &a, const PointValue &b)
00053 {
00054   PointValue result;
00055   result.x=max(a.x,b.x);
00056   result.y=max(a.y,b.y);
00057   return result;
00058 }
00059 
00060 PointValue min(const PointValue &a, const PointValue &b)
00061 {
00062   PointValue result;
00063   result.x=min(a.x,b.x);
00064   result.y=min(a.y,b.y);
00065   return result;
00066 }
00067 
00068 void PointPicker::nextPoint(PointValue p, bool)
00069 {
00070   point=p;
00071   accept();
00072 }

Generated on Mon Jun 5 22:08:42 2006 for iis by  doxygen 1.4.6