00001 //###################################################################### 00002 // 00003 // GraspIt! 00004 // Copyright (C) 2002-2009 Columbia University in the City of New York. 00005 // All rights reserved. 00006 // 00007 // GraspIt! is free software: you can redistribute it and/or modify 00008 // it under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation, either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // GraspIt! is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with GraspIt!. If not, see <http://www.gnu.org/licenses/>. 00019 // 00020 // Author(s): Andrew T. Miller 00021 // 00022 // $Id: quality.h,v 1.8 2009/03/31 15:37:06 cmatei Exp $ 00023 // 00024 //###################################################################### 00025 00029 #ifndef QUALITY_H 00030 00031 #include <QString> 00032 #include <string.h> 00033 #include <list> 00034 00035 class Grasp; // defined in grasp.h 00036 class GWS; // defined in gws.h 00037 class QComboBox; 00038 class QualityMeasure; 00039 class QHBox; 00040 class QLineEdit; 00041 class QWidget; 00042 class Grasp; 00043 00045 00048 struct qmDlgDataT { 00050 Grasp *grasp; 00051 00053 QWidget *settingsArea; 00054 00056 QComboBox *qmTypeComboBox; 00057 00059 QLineEdit *qmName; 00060 00062 const char *qmType; 00063 00065 QualityMeasure *currQM; 00066 00068 void *paramPtr; 00069 }; 00070 00071 00073 00079 class QualityMeasure { 00081 QString name; 00082 00083 protected: 00085 Grasp *grasp; 00086 00088 double val; 00089 00090 public: 00091 QualityMeasure(qmDlgDataT *data); 00092 QualityMeasure(Grasp *g, QString n); 00093 virtual ~QualityMeasure(); 00094 00096 virtual const char *getType() const =0; 00097 00099 virtual QString getName() {return name;} 00100 00102 virtual double evaluate() =0; 00103 virtual double evaluate3D() =0; 00104 00105 static void buildParamArea(qmDlgDataT *qmData); 00106 static QualityMeasure *createInstance(qmDlgDataT *qmData); 00107 static const char *TYPE_LIST[]; 00108 00109 }; 00110 00112 00122 class QualEpsilon : public QualityMeasure { 00124 GWS *gws; 00125 00127 static const char *type; 00128 00129 public: 00130 QualEpsilon(qmDlgDataT *data); 00131 QualEpsilon(Grasp *g, QString n, const char *gwsType); 00132 ~QualEpsilon(); 00133 00135 const char *getType() const {return type;} 00136 00137 double evaluate(); 00138 double evaluate3D(); 00139 00140 static void buildParamArea(qmDlgDataT *qmData); 00141 00143 static const char *getClassType() {return type;} 00144 }; 00145 00147 00153 class QualVolume : public QualityMeasure { 00155 GWS *gws; 00156 00158 static const char *type; 00159 00160 public: 00161 QualVolume(qmDlgDataT *data); 00162 QualVolume(Grasp *g, QString n, const char *gwsType); 00163 ~QualVolume(); 00164 00166 const char *getType() const {return type;} 00167 00168 double evaluate(); 00169 double evaluate3D(); 00170 00171 static void buildParamArea(qmDlgDataT *qmData); 00172 00174 static const char *getClassType() {return type;} 00175 }; 00176 00177 /* 00178 class QualWeighted : public QualityMeasure { 00179 QualityMeausre *qm1,*qm2; 00180 double weight1,weight2; 00181 00182 public: 00183 QualWeighted(Grasp *g, char *n, QualityMeasure *q1, QualityMeasure *q2, 00184 double w1, double w2); 00185 double evalute() {return weight1*qm1->evaluate() + weight2*qm2->evaluate();} 00186 00187 }; 00188 00189 */ 00190 #define QUALITY_H 00191 #endif