00001 #include "FeatureSetMatcherPresenter.h" 00002 #include "FeatureSetMatcherPresenter.moc" 00003 00004 #include <iostream> 00005 00006 FeatureSetMatcherPresenter::FeatureSetMatcherPresenter(AbstractFeatureSetMatcher* featureSetMatcher, ParameterWidget* featureSetMatcherParameter): 00007 m_featureSetMatcher(featureSetMatcher), 00008 m_featureSetMatcherParameter(featureSetMatcherParameter) 00009 { 00010 m_featureSetMatcherParameter->addDoubleParameter("acceptanceThreshold", "Threshold on the inlier distance", 0.01 * 5.99, 0., 1e17, 2, 0.01); 00011 syncronize(); 00012 reconnect(); 00013 } 00014 00015 void FeatureSetMatcherPresenter::setFeatureSetMatcher(AbstractFeatureSetMatcher* featureSetMatcher){ 00016 m_featureSetMatcher = featureSetMatcher; 00017 syncronize(); 00018 } 00019 00020 void FeatureSetMatcherPresenter::setFeatureSetMatcherParameter(ParameterWidget* featureSetMatcherParameter){ 00021 disconnect(m_featureSetMatcherParameter, 0, this, 0); 00022 m_featureSetMatcherParameter = featureSetMatcherParameter; 00023 m_featureSetMatcherParameter->clearParameterMap(); 00024 m_featureSetMatcherParameter->addDoubleParameter("acceptanceThreshold", "Threshold on the inlier distance", 0.01 * 5.99, 0., 1e17, 2, 0.01); 00025 syncronize(); 00026 reconnect(); 00027 } 00028 00029 void FeatureSetMatcherPresenter::changeParameter(const QString& name){ 00030 if(!QString::compare(name, "acceptanceThreshold")){ 00031 double guiValue; 00032 bool valid = m_featureSetMatcherParameter->getDoubleValue("acceptanceThreshold", guiValue); 00033 if(valid) {changeAcceptanceThreshold(guiValue);} 00034 } 00035 } 00036 00037 00038 void FeatureSetMatcherPresenter::changeAcceptanceThreshold(double value){ 00039 AbstractFeatureSetMatcher *featureSetMatcher = (AbstractFeatureSetMatcher *) m_featureSetMatcher; 00040 double guiValue; 00041 m_featureSetMatcherParameter->getDoubleValue(QString("acceptanceThreshold"), guiValue); 00042 if(featureSetMatcher->getAcceptanceThreshold() != value || guiValue != value){ 00043 featureSetMatcher->setAcceptanceThreshold(value); 00044 m_featureSetMatcherParameter->setDoubleValue("acceptanceThreshold", featureSetMatcher->getAcceptanceThreshold()); 00045 emit featureSetMatcherChanged(); 00046 } 00047 } 00048 00049 void FeatureSetMatcherPresenter::syncronize(){ 00050 AbstractFeatureSetMatcher *featureSetMatcher = (AbstractFeatureSetMatcher *) m_featureSetMatcher; 00051 m_featureSetMatcherParameter->setDoubleValue("acceptanceThreshold", featureSetMatcher->getAcceptanceThreshold()); 00052 } 00053 00054 void FeatureSetMatcherPresenter::reconnect(){ 00055 connect(m_featureSetMatcherParameter, SIGNAL(parameterChanged(const QString&)), this, SLOT(changeParameter(const QString&))); 00056 }