Example #1
0
MarkerList::MarkerList(QWidget *parent)
    : QWidget(parent),
    m_list(new QListWidget(this)),
    m_edit(false)
{
    QGridLayout *layout = new QGridLayout(this);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->addWidget(m_list, 0, 0, 1, 3);
    m_list->setSelectionMode(QAbstractItemView::SingleSelection);
    connect(m_list, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(center()));

    QPushButton *back = new QPushButton("Show map", this);
    back->setShortcut(QKeySequence(Qt::Key_Tab));
    layout->addWidget(back, 1, 0);
    connect(back, SIGNAL(clicked()), this, SIGNAL(back()));

    QPushButton *remove = new QPushButton("&Delete", this);
    remove->setShortcut(QKeySequence(Qt::ALT + Qt::Key_D));
    layout->addWidget(remove, 1, 1);
    connect(remove, SIGNAL(clicked()), this, SLOT(removeMarker()));

    QPushButton *rename = new QPushButton("&Rename", this);
    rename->setShortcut(QKeySequence(Qt::ALT + Qt::Key_R));
    layout->addWidget(rename, 1, 2);
    connect(rename, SIGNAL(clicked()), this, SLOT(beginRenameMarker()));

    resize(320, 240);
}
Example #2
0
Marker* distribute(File* hw, Marker* markers)
{
    double sumRatio;
    int numHWs;
    int numHWsParRatio;
    int numMarkHWs;
    Marker* it;
    Marker* tmp;
    Marker* result;
    int i;
    int r;

    sumRatio = 0;
    for (it = markers; it; it = it->next)
    {
        sumRatio += it->ratio;
    }
    
    numHWs = numFiles(hw);
    numHWsParRatio = (int)(numHWs / sumRatio + EPSILON);

    for (it = markers; it; it = it->next)
    {
        numMarkHWs = (int)(numHWsParRatio * it->ratio + EPSILON);
        for (int i = 0; i < numMarkHWs; ++i)
        {
            it->files = insertFile(it->files, removeFrontFile(&hw));
        }
    }

    result = NULL;
    for (i = numMarkers(markers); hw; --i)
    {
        r = rand() % i;
        tmp = removeMarker(&markers, r);
        tmp->files = insertFile(tmp->files, removeFrontFile(&hw));
        result = insertMarker(result, tmp);
    }

    while (markers)
    {
        result = insertMarker(result, removeMarker(&markers, 0));
    }

    return result;
}
void MapViewer::updateViewer(bool isForward)
{

    if ( isForward )
    {
        if (actionData[currentRecord]){
            addMarker(currentRecord);
        }
        currentRecord != 0 ? addLine(currentRecord) : removeAllLines();
    }
    else
    {
        if (actionData[currentRecord]){
            removeMarker(currentRecord);
        }
        currentRecord != recordCounter - 1 ? removeLine(currentRecord) : addAllLines();
    }
}
void ofMultiTaction::update(bool isDumpOSC)
{
    while (d->receiver.hasWaitingMessages()) {
        ofxOscMessage m;
        d->receiver.getNextMessage(&m);
        
        if (m.getAddress() == "/fingerDown") {
            Finger finger = makeFingerFromOSC(m);
            appendFinger(finger);
        }
        else if(m.getAddress() == "/fingerMove") {
            Finger finger = makeFingerFromOSC(m);
            appendFinger(finger);
        }
        else if(m.getAddress() == "/fingerUp") {
            Finger finger = makeFingerFromOSC(m);
            removeFinger(finger);
        }
        
        else if(m.getAddress() == "/markerDown") {
            Marker marker = makeMarkerFromOSC(m);
            appendMarker(marker);
        }
        else if(m.getAddress() == "/markerMove") {
            Marker marker = makeMarkerFromOSC(m);
            appendMarker(marker);
        }
        else if(m.getAddress() == "/markerUp") {
            Marker marker = makeMarkerFromOSC(m);
            removeMarker(marker);
        }
        
        if (isDumpOSC) {
            dumpOSC(m);
        }
    }
    
}
Example #5
0
void markerList::dropAllMarkers(){
	log << "dropAllMarkers call" << std::endl;
	while(listWidget->count()){
		removeMarker(listWidget->takeItem(0));
	}
}
Example #6
0
void markerList::removeMarker(){
	log << "removeMarker() call" << std::endl;
	if(listWidget->currentItem() != NULL){
		removeMarker(listWidget->currentItem());
	}
}
Example #7
0
void MarkerList::removeMarker()
{
    emit removeMarker(m_list->currentRow());
    m_list->takeItem(m_list->currentRow());
}
Example #8
0
chooseCyclesForm::chooseCyclesForm(model* mainModelGiven, bool showAlreadyPrecalcedCycles){

	// open log file
	log.open("chooseCyclesForm.log");
	log << "constructor call" << std::endl;
	FFTSignal = NULL;
	justDeletedMaker = NULL;


	// attach ui form
	setupUi(this);


	mainModel = mainModelGiven;
	peakSignal = mainModel->givePeakSignal();
	// ask to evaluate peak signal
	//askMainModelToEvaluate();
	// and take it
	//peakSignal = mainModel->givePeakSignal();




	// peak signal plot
	qwtPlot_peakSignal->setAutoReplot(false);

	qwtPlot_peakSignal->setCanvasBackground(QColor(Qt::darkBlue));
	qwtPlot_peakSignal->setTitle("peak signal");
	qwtPlot_peakSignal->setAxisTitle(QwtPlot::xBottom, "FFT cycles");
	qwtPlot_peakSignal->setAxisTitle(QwtPlot::yLeft, "Amplitude");

	QwtLegend *legend = new QwtLegend;
    qwtPlot_peakSignal->insertLegend(legend, QwtPlot::BottomLegend);

	QwtPlotGrid *grid = new QwtPlotGrid;
	grid->enableXMin(true);
	grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine));
	grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
	grid->attach(qwtPlot_peakSignal);

	peakSignalCurve1 = new QwtPlotCurve("Gidrophone 0 peakSignal");
	peakSignalCurve1->setPen(QPen(Qt::cyan));
	peakSignalCurve1->attach(qwtPlot_peakSignal);

	peakSignalCurve2 = new QwtPlotCurve("Gidrophone 0 peakSignal");
	peakSignalCurve2->setPen(QPen(Qt::yellow));
	peakSignalCurve2->attach(qwtPlot_peakSignal);

	showPeakSignal1(0);
	showPeakSignal2(0);

	qwtPlot_peakSignal->setAutoReplot(true);
	// end of peak signal plot




	//FFTSignal
	qwtPlot_FFTCycle->setAutoReplot(false);

	qwtPlot_FFTCycle->setCanvasBackground(QColor(Qt::darkBlue));
	qwtPlot_FFTCycle->setTitle("FFT signal");
	qwtPlot_FFTCycle->setAxisTitle(QwtPlot::xBottom, "FFT beans");
	qwtPlot_FFTCycle->setAxisTitle(QwtPlot::yLeft, "Amplitude");
	
	/*
	qwtPlot_FFTCycle->setAxisTitle(QwtPlot::xTop, "FFT beans");
	QwtInterval interval = qwtPlot_FFTCycle->axisInterval(QwtPlot::xBottom);
	double left = interval.minValue();
	double right = interval.maxValue();
	qwtPlot_FFTCycle->setAxisScale(QwtPlot::xTop, left, right);
	*/

	QwtLegend *legendFFTSignal = new QwtLegend;
    qwtPlot_FFTCycle->insertLegend(legendFFTSignal, QwtPlot::BottomLegend);

	QwtPlotGrid *gridFFTSignal = new QwtPlotGrid;
	gridFFTSignal->enableXMin(true);
	gridFFTSignal->setMajPen(QPen(Qt::white, 0, Qt::DotLine));
	gridFFTSignal->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
	gridFFTSignal->attach(qwtPlot_FFTCycle);

	FFTSignalCurve1 = new QwtPlotCurve("Gidrophone 0 peakSignal");
	FFTSignalCurve1->setPen(QPen(Qt::cyan));
	FFTSignalCurve1->attach(qwtPlot_FFTCycle);

	FFTSignalCurve2 = new QwtPlotCurve("Gidrophone 0 peakSignal");
	FFTSignalCurve2->setPen(QPen(Qt::yellow));
	FFTSignalCurve2->attach(qwtPlot_FFTCycle);

	qwtPlot_FFTCycle->setAutoReplot(true);
	// end of FFT signal plot



	// zoomer and picker and smth else
	// recreare zoomer each time we get new data in the plot
	reCreateZoomer();
	reCreateZoomer2nd();
	// end of zoomer and picker and smth else




	// toolbar
	QToolBar *toolBar = new QToolBar(this);




	// zoom button
    btnZoom = new QToolButton(toolBar);
    btnZoom->setText("Zoom");
    btnZoom->setIcon(QIcon(zoom_xpm));
    btnZoom->setCheckable(true);
    btnZoom->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    toolBar->addWidget(btnZoom);
    connect(btnZoom, SIGNAL(toggled(bool)), SLOT(enableZoomMode(bool)));
	// end of zoom button

	// zoom button 2nd
    toolButton_zoom2nd->setText("Zoom");
    toolButton_zoom2nd->setIcon(QIcon(zoom_xpm));
    toolButton_zoom2nd->setCheckable(true);
    toolButton_zoom2nd->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    connect(toolButton_zoom2nd, SIGNAL(toggled(bool)), SLOT(enableZoomMode2nd(bool)));
	// end of zoom button 2nd




	// marker
	peakSignalMarker = new QwtPlotMarker();
	peakSignalMarker->setValue(0.0, 0.0);
	peakSignalMarker->setLineStyle(QwtPlotMarker::VLine);
	peakSignalMarker->setLabelAlignment(Qt::AlignRight | Qt::AlignBottom);
	peakSignalMarker->setLinePen(QPen(Qt::green, 0, Qt::DashDotLine));
	peakSignalMarker->attach(qwtPlot_peakSignal);
	// end of marker




	// marker list
	listOfMarkers = new markerList(listWidget_FFTCycles, qwtPlot_peakSignal, peakSignalMarker);
	// end of marker list




	// spin boxes
	spinBox_gidrophone1->setMinimum(0);
	spinBox_gidrophone1->setMaximum(peakSignal->sizex() - 1);
	spinBox_gidrophone2->setMinimum(0);
	spinBox_gidrophone2->setMaximum(peakSignal->sizex() - 1);

	connect(spinBox_gidrophone1, SIGNAL( valueChanged(int) ), this, SLOT( showPeakSignal1(int) ) );
	connect(spinBox_gidrophone2, SIGNAL( valueChanged(int) ), this, SLOT( showPeakSignal2(int) ) );
	// end of spin boxes




	// spin boxes 2
	spinBox_FFTGidrophone1->setMinimum(0);
	spinBox_FFTGidrophone1->setMaximum(0);
	spinBox_FFTGidrophone2->setMinimum(0);
	spinBox_FFTGidrophone2->setMaximum(0);
	connect(spinBox_FFTGidrophone1, SIGNAL( valueChanged(int) ), this, SLOT( showFFTSignal1(int) ) );
	connect(spinBox_FFTGidrophone2, SIGNAL( valueChanged(int) ), this, SLOT( showFFTSignal2(int) ) );
	// end of spin boxes 2




	// evaluate button
	// (defined in ui form)
	//connect( pushButton_evaluate, SIGNAL( clicked() ), this, SLOT( evaluatePeakSignal() ) );
	// end of evaluate button




	// signal picker
	// (defined in function reCreateZoomer())
	connect(peakSignalPicker, SIGNAL(moved(const QPoint &)), this, SLOT(showCurrentMarker(const QPoint &)));
	connect(peakSignalPicker, SIGNAL(appended(const QPoint &)), this, SLOT(showCurrentMarker(const QPoint &)));
	// end of signal picker

	connect(pushButton_addFFTCycle, SIGNAL( clicked() ), listOfMarkers, SLOT( addMarker() ) );
	connect(pushButton_removeCycle, SIGNAL( clicked() ), listOfMarkers, SLOT( removeMarker() ) );
	connect(pushButton_FFTCycleShiftLeft, SIGNAL( clicked() ), listOfMarkers, SLOT( shiftCurrentMarkerLeft() ) );
	connect(pushButton_FFTCycleShiftRight, SIGNAL( clicked() ), listOfMarkers, SLOT( shiftCurrentMarkerRight() ) );
	connect(pushButton_calibrate, SIGNAL( clicked() ), this, SLOT( proceedCalibrate() ) );


	//connect(listWidget_FFTCycles, SIGNAL( currentItemChanged( QListWidgetItem*, QListWidgetItem* ) ), this, SLOT( chooseCycleItem( QListWidgetItem*, QListWidgetItem* ) ) );
	connect(listWidget_FFTCycles, SIGNAL( 	itemActivated( QListWidgetItem* ) ), listOfMarkers, SLOT( markerSelected( QListWidgetItem* ) ) );
	if(showAlreadyPrecalcedCycles){
		std::vector<double>* sourceFrequencies = mainModel->giveFrequencies();
		std::vector<int>* alreadyPrecalcedCycles = mainModel->giveCycles();
		int alreadyPrecalcedCyclesAmount = alreadyPrecalcedCycles->size();
		for(int i = 0; i < alreadyPrecalcedCyclesAmount; i++){
			listOfMarkers->addPrecalcedMarker((*alreadyPrecalcedCycles)[i], (*sourceFrequencies)[i]);
		}
	}
}