00001 #include "line.h" 00002 #include "runtime.h" 00003 00004 QString LineValue::toString() 00005 { 00006 return QString("(")+a.toString()+ 00007 QString(", ")+b.toString()+ 00008 QString(")"); 00009 } 00010 00011 bool LineValue::equals_same_type(Value * other) 00012 { 00013 LineValue * o = (LineValue*)other; 00014 return a.equals(o->a) && b.equals(o->b); 00015 } 00016 00017 Value * Runtime::line(Value * image) 00018 { 00019 if (image==NULL) return NULL; 00020 if (typeid(*image)!=typeid(ImageValue)) return NULL; 00021 ImageValue * I = (ImageValue*)image; 00022 LinePicker ip(I); 00023 if (ip.exec()==QDialog::Accepted) 00024 return ip.value(); 00025 return NULL; 00026 } 00027 00028 Value * Runtime::line(vector<Value*> v) 00029 { 00030 if (v.size()==1) return line(v[0]); 00031 return NULL; 00032 } 00033 00034 void LinePicker::nextPoint(PointValue p, bool) 00035 { 00036 if (first) 00037 { 00038 line.a=p; 00039 first = false; 00040 } 00041 else 00042 { 00043 line.b=p; 00044 accept(); 00045 } 00046 } 00047