示例#1
0
QLagrage::CAL_TYPE QLagrage::setCalType(CAL_TYPE type)
{
    CAL_TYPE old = calType;
    calType = type;
    updateCurve();
    return old;
}
示例#2
0
EditCurve::EditCurve(BezierCurve *targetCurve, Color curveColor) : UIElement() {

    this->targetCurve = targetCurve;

    poly = new Polycode::Polygon();

    for(int i=0; i < CURVE_SIZE; i++) {
        poly->addVertex(0.0, 0.0, 0.0);
    }

    visMesh = new ScreenMesh(Mesh::LINE_STRIP_MESH);
    visMesh->getMesh()->addPolygon(poly);

    visMesh->lineSmooth = true;
    visMesh->lineWidth = 2.0;

    addChild(visMesh);
    visMesh->setPosition(0, 254);
    visMesh->color = curveColor;

    pointsBase = new UIElement();
    addChild(pointsBase);

    pointToRemove = NULL;

    updateCurve();
    updatePoints();

    Deactivate();
}
void JCurveGroupWidget::updateCurves(int index)
{
    //
    JAutoCursor autoCursor(Qt::BusyCursor);

    if (index < 0) {
        QListIterator<JCurveWidget *> citer(q_curveViews);
        while (citer.hasNext()) {
            updateCurve(citer.next());
        }
    } else if (index < q_curveViews.count()) {
        updateCurve(q_curveViews.at(index));
    } else {
        return;
    }
}
示例#4
0
文件: nurbs.cpp 项目: CPSC589/PUPS
void Nurbs::updateAll()
{
    knots.clear();
    double step_denominator = 0;

    //generate knots
    //won't work properly if order is more than num control points
    if (uniform)
    {
        step_denominator = (control_points.size()+order);
        for (int i = 0; i <= step_denominator; i++){
            knots.push_back(i/step_denominator);
        }
    }
    else {
        step_denominator = (control_points.size() - order + 1);
        for (int i = 0; i < order; i++){
            knots.push_back(0);
        }
        for (int i = 0; i < control_points.size() - order; i++){
            knots.push_back((double)(i+1)/step_denominator);
        }
        for (int i = 0; i < order; i++){
            knots.push_back(1);
        }
    }

    updateCurve();
}
示例#5
0
void EditCurve::Update() {
    if(pointToRemove) {
        targetCurve->removePoint(pointToRemove->point);
        updatePoints();
        updateCurve();
        pointToRemove = NULL;
    }
}
示例#6
0
//没有必要按照X的升序排列
void QBezier::addPoint(const QPointF& c)
{
    if (c.isNull())
	return;
    if ( knowPoints.isEmpty() )
    {
        knowPoints.append(c);
	updateCurve();
	return;
    }
    if(-1 != knowPoints.indexOf(c))
    {
        return;
    }
    knowPoints.append(c);
    updateCurve();
}
示例#7
0
LRESULT CLeftView::OnFlyingStateData(WPARAM w, LPARAM l)
{
	/*
	 * First check the newest fly state group
	 */
	if (!newestFSG)	{
		AfxMessageBox("No fly state group coming", MB_OK | MB_ICONSTOP);
		return TRUE;
	}

	// Get the client
	CNetCln *cln = ((CGTApp*)AfxGetApp())->getCln();

	/* 
	 * Check the serial number of the newest fly state group
	 */
	char com[6];
	__int16 *inst = (__int16 *)com;
	inst[0] = FIT_FLYINGSTATEDATAACT;

	__int32 *rpy = (__int32 *)(com + 2);
	if (newestFSG->serial == expect) {    // Make it
		rpy[0] = newestFSG->serial;

		cln->SendSvr(com, sizeof(com));

		expect++;
	} else {
		rpy[0] = expect - 1;
		cln->SendSvr(com, sizeof(com));
		return TRUE;
	}

	/*
	 * Update the edit control
	 */
	updateEditControl();
	
	// Then update the curve
	updateCurve();

	/*
	 * Update the instruments and the 3-d helicopter model
	 */
	GetDocument()->lowerRightView->updateFS(&(newestFSG->states[FLYSTATEGROUPNUMBER - 1]));

	/*
	 * Update the GPS
	 */
	GetDocument()->upperRightView->updateFS(&(newestFSG->states[FLYSTATEGROUPNUMBER - 1]));

	/*
	 * Finally we should store the fly state into files when the buffer is full
	 */
	serialize();
	return TRUE;
}
示例#8
0
//设置控制点
void QBezier::addPoint(const ICalCurve::T_CURVE& ctrlPoints)
{
    if(ctrlPoints.isEmpty())
    {
        return;
    }
    knowPoints = ctrlPoints;
    updateCurve();
}
示例#9
0
void QLagrage::addPoint(const ICalCurve::T_CURVE& ps)
{
    if( ps.isEmpty() )
    {
        return;
    }
    knowPoints = ps;
    updateCurve();
}
示例#10
0
void CDPUpperRightView::updateFS(pFlyState fs)
{
	updateEdits(fs);

	mapData.push_back(FPOINT((float)dpXCoor, (float)dpYCoor));

	updateCurve();

	UpdateData(FALSE);
}
TrendDataCollector::TrendDataCollector()
{
    this->mAttribute = nullptr;
    this->mAttributeName = "";
    this->mInterval = 200;
    connect(&this->mTimer, SIGNAL(timeout()), this, SLOT(updateCurve()));
//    this->mMutex = QMutex();
    this->mStopProcess = false;
    this->mPauseProcess = true;
}
示例#12
0
FMOD_RESULT F_CALLBACK pcmreadcallback(FMOD_SOUND *sound, void *data, unsigned int datalen)
{
	UScopeMutex scopeMutex(&g_mutex);
	//ROS_INFO("datalen=%d, g_readPtr=%d", datalen, g_readPtr);
    unsigned int  count;
    char * buffer = (char *)data;

    bool okToCpy = false;

    if(g_readPtr < g_writePtr)
    {
    	okToCpy = true;
    }
    else if(g_readingLooped < g_writingLooped)
    {
    	okToCpy = true;
    }

    if(okToCpy)
    {
    	g_warn = true;
    	unsigned int start = g_readPtr;
		for(count=0; count<datalen; ++count)
		{
			*(buffer++) = g_ringBuffer[g_readPtr++];
			g_readPtr %= g_ringBuffer.size();
		}
		if(g_readPtr < start)
		{
			++g_readingLooped;
		}

		if(g_plot && g_plot->isVisible() && g_curvePlaying)
		{
			int channels, bitsPerSample;
			FMOD_Sound_GetFormat(sound, 0, 0, &channels, &bitsPerSample);
			updateCurve(g_curvePlaying, &g_ringBuffer[start], datalen, channels, bitsPerSample/8);
		}
		//ROS_INFO("datalen=%d, writePtr=%d, readPtr=%d", datalen, g_writePtr, g_readPtr);
    }
    else
    {
    	if(g_warn)
    	{
    		g_warn = false;
    		ROS_WARN("Empty buffer : stream down? (this warning is shown only one time)");
    	}

    	//fill data with zeros
    	memset(buffer, 0, datalen);
    }
    return FMOD_OK;
}
示例#13
0
void EditCurve::handleEvent(Event *event) {
    if(event->getEventCode() == Event::CHANGE_EVENT) {
        updateCurve();
    }

    if(event->getEventCode() == Event::CANCEL_EVENT) {
        for(int i=0; i < points.size(); i++) {
            if(event->getDispatcher() == points[i]) {
                pointToRemove = points[i];
                break;
            }
        }
    }
}
void OscilloscopePlot::timerEvent( QTimerEvent *event )
{
    if ( event->timerId() == d_timerId )
    {
        updateCurve();

        const double elapsed = d_clock.elapsed() / 1000.0;
        if ( elapsed > d_interval.maxValue() )
            incrementInterval();

        return;
    }

    QwtPlot::timerEvent( event );
}
示例#15
0
void QLagrage::addPoint(const QPointF& p)
{
    if( p.isNull())
        return;
    QList<QPointF>::iterator itor;
    for( itor = knowPoints.begin();itor != knowPoints.end();itor++)
    {
        if(*itor == p || qAbs(p.x() - (*itor).x()) < deta)
            return;
        if( (*itor).x() > p.x())
            break;
    }
    knowPoints.insert(itor,p);
    updateCurve();
}
示例#16
0
void frameReceivedCallback(const utilite::AudioFramePtr & msg)
{
	if(msg->data.size())
	{
		UScopeMutex scopeMutex(&g_mutex);
		if(g_sound)
		{
			int channels, bitsPerSample;
			float fs;
			g_sound->getFormat(0, 0, &channels, &bitsPerSample);
			g_sound->getDefaults(&fs, 0, 0, 0);
			if(fs != msg->fs || channels != (int)msg->nChannels || bitsPerSample/8 != (int)msg->sampleSize)
			{
				UWARN("Sound format changed (old was fs=%f, channels=%d, sample size=%d), resetting...", fs, channels, bitsPerSample/8);
				FMOD_RESULT result;

				result = g_channel->stop(); ERRCHECK(result);
				g_channel = 0;
				result = g_sound->release(); ERRCHECK(result);
				g_sound = 0;

				g_ringBuffer.clear();
				g_readPtr = 0;
				g_writePtr = 0;
				g_readingLooped = 0;
				g_writingLooped = 0;

				g_initialized = false;
			}
		}

		if(!g_ringBuffer.size())
		{
			g_ringBuffer = std::vector<char>(msg->data.size() * 5 * msg->nChannels * msg->sampleSize, 0);
		}

		//ROS_INFO("Received audio frame size=(%d), writePtr=%d", msg->data.size(), g_writePtr);
		unsigned int start = g_writePtr;
		if(g_writePtr + msg->data.size() <= g_ringBuffer.size())
		{
			memcpy(g_ringBuffer.data()+g_writePtr, msg->data.data(), msg->data.size());
			g_writePtr += msg->data.size();
			g_writePtr %= g_ringBuffer.size();
		}
		else
		{
			unsigned int size2 = (g_writePtr + msg->data.size()) - g_ringBuffer.size();
			unsigned int size1 = msg->data.size() - size2;
			memcpy(g_ringBuffer.data()+g_writePtr, msg->data.data(), size1);
			memcpy(g_ringBuffer.data(), msg->data.data() + size1, size2);
			g_writePtr = size2;
		}
		if(g_writePtr < start)
		{
			++g_writingLooped;
		}

		bool plotAboutToBeShown = false;
		if(!g_initialized)
		{
			//wait for second frame
			if(g_writePtr > msg->data.size() * 2)
			{
				g_initialized = initAudioPlayer(msg->data.size(), msg->fs, msg->nChannels, msg->sampleSize);
				if(!g_initialized)
				{
					ROS_ERROR("Cannot initialize the audio player...");
					exit(-1);
				}
			}
			else if(g_plot)
			{
				if(g_plot->isVisible() && ((msg->data.size() / msg->nChannels) / msg->sampleSize) % PLOT_SAMPLING_RATIO != 0)
				{
					QMetaObject::invokeMethod(g_plot, "hide");
					ROS_WARN("Frame length (%d) must be a multiple of %d to show audio plot...", (int)((msg->data.size() / msg->nChannels) / msg->sampleSize), PLOT_SAMPLING_RATIO);
				}
				else if(g_curveReceiving && g_curvePlaying)
				{
					if(!g_plotAlreadyShown && g_plot->isHidden())
					{
						g_plotAlreadyShown = true;
						QMetaObject::invokeMethod(g_plot, "show");
						plotAboutToBeShown = true;
					}

					QMetaObject::invokeMethod(g_curveReceiving, "setXIncrement", Q_ARG(float, float(PLOT_SAMPLING_RATIO)/float(msg->fs)));
					QMetaObject::invokeMethod(g_curvePlaying, "setXIncrement", Q_ARG(float, float(PLOT_SAMPLING_RATIO)/float(msg->fs)));
				}
			}
		}
		if(g_plot && (g_plot->isVisible() || plotAboutToBeShown) && g_curveReceiving)
		{
			updateCurve(g_curveReceiving, msg->data.data(), msg->data.size(), msg->nChannels, msg->sampleSize);
		}
	}
示例#17
0
bool JCurveGroupWidget::addCurveView(const QString &suffix, const QString &nameX,
                                     const QString &nameY, int axisXYType)
{
    if (axisXYType == JCurveWidget::AxisXY_Invalid) {
        return false;
    }

    JCurveWidget *curveView = new JCurveWidget(this, true);
    curveView->setMinimumHeight(300);
    curveView->setAxisXYType((JCurveWidget::AxisXYType)axisXYType);
    curveView->setTitle(QString("%2 - %3 (<font color='#aaf'>%1</font>)")
                        .arg(QString(suffix).replace('_', '-')).arg(nameX).arg(nameY));
    curveView->setProperty("suffix", suffix);
    curveView->setProperty("nameX", nameX);
    curveView->setProperty("nameY", nameY);
    //
    curveView->setLegendVisible(false);
    curveView->setEnableDbClick(true);
    curveView->setBaseLineVisible(false);
    curveView->setBaseLineEnabled(false);
    //
    if (!GlobalConfig::instance()->canExportData()) {
        curveView->setExportVisible(false);
    }
    //
    if (axisXYType == JCurveWidget::AxisXY_Time_Time
            || axisXYType == JCurveWidget::AxisXY_Time_Value) {
        if (GlobalConfig::instance()->canWriteDatabase()) {
            curveView->setEditEnabled(true);
        }
        curveView->setZoomModeVisible(true);
        curveView->setSiftModeVisible(true);
    } else {
        curveView->setEditEnabled(false);
        curveView->setZoomModeVisible(false);
        curveView->setSiftModeVisible(false);
    }
    curveView->setZoomMode(true);
    //
    q_curveViews.append(curveView);
    q_vertLayoutCurveArea->addWidget(curveView);

    //
    updateCurve(curveView);

    //
    //updateBaseLine(curveView);

    //
    int currentIndex = q_curveViews.count() - 1;

    //
    connect(curveView, &JCurveWidget::doubleClicked, [=](bool checked){
        //
        bool zoomEnabled = (q_curveViews.count() < 3) ? true : checked;
        QListIterator<JCurveWidget *> citer(q_curveViews);
        while (citer.hasNext()) {
            JCurveWidget *item = citer.next();
            if (item == 0) {
                continue;
            }
            //
            if (item != curveView) {
                item->setVisible(!checked);
            }
            //
            if (!item->editEnabled()) {
                item->setZoomMode(zoomEnabled);
            }
        }
        //
        Q_EMIT curveViewDoubleClicked(currentIndex, checked);
    });
    connect(curveView, &JCurveWidget::editClicked, [=](){
        //
        Q_EMIT editClicked(currentIndex);
    });
    connect(curveView, &JCurveWidget::timeBandApply,
            [=](const QTime &minimum, const QTime &maximum, bool retain){
        //
        Q_EMIT timeBandApply(currentIndex, minimum, maximum, retain);
    });

    return true;
}