void DetectorChooserPresenter::changeDetector(int detector){
    if(m_currentDetectorPresenterIndex != detector){
	disconnect(m_currentDetectorPresenter, SIGNAL(detectorChanged()), this, SIGNAL(detectorChanged()));
	m_currentDetectorPresenter->deactivate();
	m_currentDetectorPresenterIndex = detector;
	m_currentDetectorPresenter = m_detectorPresenters[m_currentDetectorPresenterIndex];
	m_chooser->setEnumValue("detector", m_currentDetectorPresenterIndex);
	m_currentDetectorPresenter->activate();
	connect(m_currentDetectorPresenter, SIGNAL(detectorChanged()), this, SIGNAL(detectorChanged()));
	emit detectorChanged();
    }
}
void DetectorChooserPresenter::insertDetector(const QString& name, DetectorPresenter* detector){
    m_detectorPresenterNames.push_back(name);
    m_detectorPresenters.push_back(detector);
    m_chooser->insertEnumValue("detector", name);
    if(m_detectorPresenters.size() == 1){ 
	m_currentDetectorPresenter = detector;
	m_currentDetectorPresenterIndex = 0;
	connect(m_currentDetectorPresenter, SIGNAL(detectorChanged()), this, SIGNAL(detectorChanged()));
	m_currentDetectorPresenter->activate();
    } else{
	detector->deactivate();
	m_currentDetectorPresenter->activate();
    }
}
Esempio n. 3
0
FLIRTDemo::FLIRTDemo(QWidget* parent, SensorStream& sensor): 
    QWidget(parent), 
    m_sensor(sensor),
	m_currentPoint(NULL),
	m_reading(NULL)
{ 
    m_sensorWidget = new SensorStreamWidget(this);
    m_rendererWidget = new RendererWidget(this);
    m_descriptorRendererWidget = new RendererWidget(this);
    m_peakMR = new SimpleMinMaxPeakFinder(0.2, 0.04);
    m_peakR = new SimplePeakFinder(0.2, 0.04);
    m_peakC = new SimplePeakFinder(0.3, 0.004);
    m_peakMNE = new SimpleMinMaxPeakFinder(0.2, 0.04);
    m_peakNE = new SimplePeakFinder(0.2, 0.04);
    m_peakMNB = new SimpleMinMaxPeakFinder(0.2, 0.04);
    m_peakNB = new SimplePeakFinder(0.2, 0.04);
    m_detectorR = new RangeDetector(m_peakMR,1);
    m_detectorC = new CurvatureDetector(m_peakC,1);
    m_detectorNB = new NormalBlobDetector(m_peakMNB,3,1);
    m_detectorNE = new NormalEdgeDetector(m_peakMNE,3,1);
    m_layout = new QGridLayout(this);
    m_parameter = new QTabWidget(this);
    m_chooserW = new QWidget(0);
    m_parameter->insertTab(1,m_chooserW,"Chooser");
    QVBoxLayout *chooserLayout = new QVBoxLayout(m_chooserW);
//     m_paramLayout = new QGridLayout(m_parameter);
    m_plotWidget = new MultiScaleDetectorPlotWidget(this, m_detectorR->getScaleNumber());

    m_detectorPresenterR = new MultiScaleDetectorPresenter(m_detectorR, new TabbedParameterWidget("RangeDetector", m_parameter,0));
    m_peakMRPresenter = new SimplePeakFinderPresenter(m_peakMR, new TabbedParameterWidget("PeakFinder", m_parameter,2));
    m_peakRPresenter = new SimplePeakFinderPresenter(m_peakR, new TabbedParameterWidget("PeakFinder", m_parameter,2));
    m_detectorPresenterR->insertPeakFinder("SimpleMinMax", m_peakMRPresenter);
    m_detectorPresenterR->insertPeakFinder("Simple", m_peakRPresenter);
    
    m_detectorPresenterNB = new MultiScaleNormalDetectorPresenter(m_detectorNB, new TabbedParameterWidget("NormalBlobDetector", m_parameter,1));
    m_peakMNBPresenter = new SimplePeakFinderPresenter(m_peakMNB, new TabbedParameterWidget("PeakFinder", m_parameter,2));
    m_peakNBPresenter = new SimplePeakFinderPresenter(m_peakNB, new TabbedParameterWidget("PeakFinder", m_parameter,2));
    m_detectorPresenterNB->insertPeakFinder("SimpleMinMax", m_peakMNBPresenter);
    m_detectorPresenterNB->insertPeakFinder("Simple", m_peakNBPresenter);
    
    m_detectorPresenterNE = new MultiScaleNormalDetectorPresenter(m_detectorNE, new TabbedParameterWidget("NormalEdgeDetector", m_parameter,1));
    m_peakMNEPresenter = new SimplePeakFinderPresenter(m_peakMNE, new TabbedParameterWidget("PeakFinder", m_parameter,2));
    m_peakNEPresenter = new SimplePeakFinderPresenter(m_peakNE, new TabbedParameterWidget("PeakFinder", m_parameter,2));
    m_detectorPresenterNE->insertPeakFinder("SimpleMinMax", m_peakMNEPresenter);
    m_detectorPresenterNE->insertPeakFinder("Simple", m_peakNEPresenter);
    
    m_detectorPresenterC = new MultiScaleCurvatureDetectorPresenter(m_detectorC, new TabbedParameterWidget("CurvatureDetector", m_parameter,1)); 
    m_peakCPresenter = new SimplePeakFinderPresenter(m_peakC, new TabbedParameterWidget("PeakFinder", m_parameter,2));
    m_detectorPresenterC->insertPeakFinder("Simple", m_peakCPresenter);
    
    m_chooser = new DetectorChooserPresenter(new ParameterWidget("DetectorChooser", m_chooserW));
    m_chooser->insertDetector("CurvatureDetector", m_detectorPresenterC);
    m_chooser->insertDetector("RangeDetector", m_detectorPresenterR);
    m_chooser->insertDetector("NormalBlobDetector", m_detectorPresenterNB);
    m_chooser->insertDetector("NormalEdgeDetector", m_detectorPresenterNE);
    
    m_descriptorGeneratorS = new ShapeContextGenerator(0.02, 0.5, 4, 12);
    m_descriptorPresenterS = new ShapeContextPresenter(m_descriptorGeneratorS, new TabbedParameterWidget("ShapeContext", m_parameter,3));
    
    m_descriptorGeneratorB = new BetaGridGenerator(0.02, 0.5, 4, 12);
    m_descriptorPresenterB = new BetaGridPresenter(m_descriptorGeneratorB, new TabbedParameterWidget("BetaGrid", m_parameter,3));
    
    m_chooserD = new DescriptorChooserPresenter(new ParameterWidget("DescriptorChooser", m_chooserW));
    m_chooserD->insertDescriptor("BetaGrid", m_descriptorPresenterB);
    m_chooserD->insertDescriptor("ShapeContext", m_descriptorPresenterS);
    
    m_interestRenderer = 0;
    m_laserRenderer = 0;
    m_supportRenderer = 0;
    m_polarRenderer = 0;

    m_layout->setSpacing(3);
    m_layout->setMargin(3);
    m_layout->addWidget(m_sensorWidget,0,0);
    m_layout->addWidget(m_rendererWidget,1,0);
    m_layout->addWidget(m_descriptorRendererWidget,2,1);
    m_layout->setRowStretch(1,1);
    m_layout->addWidget(m_plotWidget,2,0);
    m_layout->addWidget(m_parameter,1,1);
    chooserLayout->addWidget(m_chooser->getChooserParameter());
    chooserLayout->addWidget(m_chooserD->getChooserParameter());
/*    m_paramLayout->setSpacing(3);
    m_paramLayout->setMargin(3);
    m_paramLayout->addWidget(m_detectorPresenterC->getDetectorParameter(),0,0);
    m_paramLayout->addWidget(m_detectorPresenterR->getDetectorParameter(),0,0);
    m_paramLayout->addWidget(m_detectorPresenterNB->getDetectorParameter(),0,0);
    m_paramLayout->addWidget(m_detectorPresenterNE->getDetectorParameter(),0,0);
    m_paramLayout->addWidget(m_peakMRPresenter->getPeakFinderParameter(),1,0);
    m_paramLayout->addWidget(m_peakRPresenter->getPeakFinderParameter(),1,0);
    m_paramLayout->addWidget(m_peakCPresenter->getPeakFinderParameter(),1,0);
    m_paramLayout->addWidget(m_peakMNEPresenter->getPeakFinderParameter(),1,0);
    m_paramLayout->addWidget(m_peakNEPresenter->getPeakFinderParameter(),1,0);
    m_paramLayout->addWidget(m_peakMNBPresenter->getPeakFinderParameter(),1,0);
    m_paramLayout->addWidget(m_peakNBPresenter->getPeakFinderParameter(),1,0);
    m_paramLayout->addWidget(m_descriptorPresenter->getDescriptorParameter(),2,0);*/
    m_sensor.seek(0,END);
    unsigned int end = m_sensor.tell();
    m_sensor.seek(0,BEGIN);
    m_sensorWidget->seekable(m_sensor.isSeekable(), end);
    m_sensorWidget->streamReady();
    m_sensorWidget->setMaximumHeight(32);
    m_plotWidget->setMaximumHeight(256);
    m_plotWidget->setMinimumHeight(256);
    m_parameter->setMaximumWidth(350);
    m_parameter->setMinimumWidth(350);

    m_parameter->show();

    connect(m_sensorWidget, SIGNAL(newReading()), this, SLOT(next()));
    connect(m_sensorWidget, SIGNAL(newReading(int)), this, SLOT(next(int)));
    connect(m_chooser, SIGNAL(detectorChanged()), this, SLOT(update()));
    connect(m_chooserD, SIGNAL(descriptorChanged()), this, SLOT(updateDescriptor()));
    connect(m_descriptorPresenterS, SIGNAL(descriptorChanged()), this, SLOT(updateDescriptor()));
    connect(m_descriptorPresenterB, SIGNAL(descriptorChanged()), this, SLOT(updateDescriptor()));
    connect(m_rendererWidget, SIGNAL(mousePressedGL(int, int, int)), this, SLOT(mousePressedGL(int, int, int)));

	const AbstractReading* read = m_sensor.current();
    processReading(read);
}