Exemple #1
0
        bool Page::deleteObj(long long headerpos)
        {
            //reading the Page
            tasking::RWLockGuard<> lock(m_rwLock, tasking::WRITE);
            auto l_header = reinterpret_cast<HeaderMetaData*>(static_cast<char*>(m_header) + headerpos);
            auto l_oid = l_header->getOID();
            //start delete by calculating the start position and passing the hash of the obj name
            deleteObj(l_header->getObjektType(), static_cast<char*>(m_body) + l_header->getPos());

            //now its delete put the freetype ptr to the start
            //of the "prepared" deleted object
            auto l_free = m_free;
            while (l_free->getNext() == 0)
                l_free = reinterpret_cast<FreeType*>(reinterpret_cast<char*>(l_free) + l_free->getNext());
            // now l_Free is the last element;
            l_free->setNext(dist(l_free, static_cast<char*>(m_body) + l_header->getPos()));

            // Delete header
            l_free = m_headerFree;
            while (l_free->getNext() == 0)
                l_free = reinterpret_cast<FreeType*>(reinterpret_cast<char*>(l_free) + l_free->getNext());

            //now we have the last free element of the header
            //insert free type with the right size
            auto l_deletedHeader = new(l_header) FreeType(sizeof(HeaderMetaData));
            //set the freeType pointer to it
            l_free->setNext(dist(l_free, l_deletedHeader));

            //delete the obj of the idx
            index::ObjectIndex::getInstance().erase(l_oid);
            //do NOT delete the Meta! it is way faster to
            //insert with meta then without so keep the data
            return true;
        }
Exemple #2
0
void EnrollmentDao::deleteObjs(std::vector<Enrollment> *enrollments){
    connect();
    while(!enrollments->empty()){
        deleteObj(enrollments->back());
        enrollments->pop_back();
    }
    disconnect();
}
void VisualizerContainer::switchPopState()
{
    if(this->window != nullptr)
    {
        this->setParent(nullptr);
        deleteObj(&this->window);
        this->show();
    }
    else
    {
        this->moveToNewMdiChild();
    }
}
Exemple #4
0
void ICPWidget::delObj(void)
{
    if(-1==currentObjIndex)return;
    emit deleteObj(currentObjIndex);
    _ObjList.erase(_ObjList.begin()+currentObjIndex);
    std::vector<GeoObj::Ptr>::iterator iter;
    int index = 0;
    for(iter=_ObjList.begin();iter!=_ObjList.end();++iter)
    {
        (*iter)->setIndex(index);
        ++index;
    }
    currentObjIndex = -1;
}
Exemple #5
0
/*
 * deleteObjChain() wipes out an object chain and all the objects it contains
 */
void
deleteObjChain(void *o)
{
    Obj *top, *cur, *next;

    top = OBJ(o);

    if (top != (Obj*)0) {
	cur = top;
	do {
	    next = cur->next;
	    deleteObj(cur);
	    if (next == 0)
		break;
	    cur = next;
	} while (cur != top);
    }
} /* deleteObjChain */
Exemple #6
0
void main (void){
  timer= newObj(Timer,(ulong)500); 
  
 /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
 /*** End of Processor Expert internal initialization.                    ***/
  
  Teclas_Init();
  Display_Init(); // Inicializacion del display
  Grabacion_Init();
  
  newAllocObj(&mainThread,ThreadAdjuntable);
  cap=GET_INSTANCE();
  #ifdef _ENTRADA_SIMULADA
  CapturadorSimulado_setMicroSegundos(cap,100000000);
  CapturadorSimulado_setPulsos(cap,2);
  #endif
  {
    void * adjuntador= ThreadAdjuntable_getAdjuntador(&mainThread);
    newAllocObj(&sensorRpm,SensorRpm,adjuntador,1000,cap,&config,"SEn rPM");
    deleteObj(&adjuntador);
  }
 	
 	  														 
  for(;;){
    WDog1_Clear();
    
    
    
    if(Timer_isfinish(timer)){
      Timer_Restart(timer);
      _GetterPrint(&sensorRpm,1);
    //  Pasar_Numero(Capturador_getMicroSegundos(cap)/1000,0,0);
    //  Pasar_Numero(Capturador_getPulsos(cap),1,0);
     // CapturadorSimulado_setPulsos(cap,CapturadorSimulado_getPulsos(cap)+1);
    }

    //Eventos
    MethodContainer_Execute(&mainThread);
  }
}
void VisualizerContainer::moveToNewMdiChild()
{
    if(this->window != nullptr)
    {
        this->setParent(nullptr);
        deleteObj(&this->window);
    }

    this->window = this->container->addSubWindow(this);
    this->window->move(10, 10);
    this->window->setWindowIcon(icon);
    this->window->show();

    connect(this->window, &QMdiSubWindow::destroyed, this, &VisualizerContainer::destroyme);

    this->container->setActiveSubWindow(this->window);

    connect(this->window, &QMdiSubWindow::windowStateChanged, this, &VisualizerContainer::subWindowChanged);

    this->sidePanelVisiblityChanged(true);
}
Exemple #8
0
//ray picking via mouse function!
void mouse(int button, int state, int x, int y) {

    //grab matrices
    double matModelView[16], matProjection[16];
    int viewport[4];

    glGetDoublev(GL_MODELVIEW_MATRIX, matModelView);
    glGetDoublev(GL_PROJECTION_MATRIX, matProjection);
    glGetIntegerv(GL_VIEWPORT, viewport);

    //unproject values
    double winX = (double)x;
    double winY = viewport[3] - (double)y;

    // get point on the 'near' plane
    gluUnProject(winX, winY, 0.0, matModelView, matProjection,
                 viewport, &start[0], &start[1], &start[2]);

    // get point on the 'far' plane
    gluUnProject(winX, winY, 1.0, matModelView, matProjection,
                 viewport, &end[0], &end[1], &end[2]);

    //difference
    end[0] = end[0] - start[0];
    end[1] = end[1] - start[1];
    end[2] = end[2] - start[2];

    //magnitude
    double M = sqrt(end[0]*end[0] + end[1]*end[1] + end[2]*end[2]);

    //unit vector
    end[0] /= M;
    end[1] /= M;
    end[2] /= M;

    //list of intersection distances
    vector<double> *intersections = new vector<double>;
    //find the relative distance for each object in scene
    for (int i = 0; i < sceneObjs->size(); ++i)
    {   double intersection = sceneObjs->at(i)->box->slab(start,end);
        intersections->insert(intersections->begin()+i, intersection);
    }

    //compare these distances
    double t;
    double closest = std::numeric_limits<double>::infinity();
    int closestIndex = -1;
    for (int i = 0; i < intersections->size(); ++i) {
        t = intersections->at(i);
        if (t<closest && t>0) {
            closest = t;
            closestIndex = i;
        }
    }
    //select closest intersected object, if any
    if(button ==  GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
        if (closestIndex > -1) {
            currentObj->unselect();
            currentObj = sceneObjs->at(closestIndex);
            currentObj->select();
        }
    }
    //delete closest intersected object, if any
    if(button ==  GLUT_RIGHT_BUTTON && state == GLUT_DOWN && sceneObjs->size()!=0) deleteObj(currentObj->ID);
}
Exemple #9
0
//callbacks
void keyboard(unsigned char key, int x, int y)
{
    switch (key)
    {
    case 27:
        exit (0);
        break;
    //draw objects
    case 'y':
        insertObj(Cube);
        break;
    case 'u':
        insertObj(Sphere);
        break;
    case 'i':
        insertObj(Cone);
        break;
    case 'o':
        insertObj(Torus);
        break;
    case 'p':
        insertObj(Teapot);
        break;
    //transformations
    case 'a': //-x
        if (sceneObjs->size()!=0) {
            if (mode%3==0) currentObj->translate(-0.1, 0, 0);
            if (mode%3==1&&!currentObj->isLight) currentObj->scale(-0.1, 0,0);
            if (mode%3==2&&!currentObj->isLight) currentObj->rotate(-5,0,0);
        }
        break;
    case 'd': //+x
        if (sceneObjs->size()!=0) {
            if (mode%3==0) currentObj->translate(0.1, 0, 0);
            if (mode%3==1&&!currentObj->isLight) currentObj->scale(0.1,0,0);
            if (mode%3==2&&!currentObj->isLight) currentObj->rotate(5,0,0);
        }
        break;
    case 'q': //-z
        if (sceneObjs->size()!=0) {
            if (mode%3==0) currentObj->translate(0, 0, -0.1);
            if (mode%3==1&&!currentObj->isLight) currentObj->scale(0, 0,-0.1);
            if (mode%3==2&&!currentObj->isLight) currentObj->rotate(0,0,-5);
        }
        break;
    case 'e': //+z
        if (sceneObjs->size()!=0) {
            if (mode%3==0) currentObj->translate(0, 0, 0.1);
            if (mode%3==1&&!currentObj->isLight) currentObj->scale(0, 0,0.1);
            if (mode%3==2&&!currentObj->isLight) currentObj->rotate(0,0,5);
        }
        break;
    case 's': //-y
        if (sceneObjs->size()!=0) {
            if (mode%3==0) currentObj->translate(0, -0.1, 0);
            if (mode%3==1&&!currentObj->isLight) currentObj->scale(0, -0.1,0);
            if (mode%3==2&&!currentObj->isLight) currentObj->rotate(0,-5,0);
        }
        break;
    case 'w': //+y
        if (sceneObjs->size()!=0) {
            if (mode%3==0) currentObj->translate(0, 0.1, 0);
            if (mode%3==1&&!currentObj->isLight) currentObj->scale(0, 0.1,0);
            if (mode%3==2&&!currentObj->isLight) currentObj->rotate(0,5,0);
        }
        break;
    case 't': //transform type toggle
        mode++;
        if (mode%3==0) transformMode = t;
        if (mode%3==1) transformMode = s;
        if (mode%3==2) transformMode = r;
        break;
    case 32: //load/save
        if (glutGetModifiers()==GLUT_ACTIVE_CTRL) {
            sceneObjs = SG->load();
            nextChild = sceneObjs->size();
            currentObj = sceneObjs->at(0);
            currentObj->select();
        }
        else SG->save();
        break;
    //toggle materials
    case '1':
        curMat = m1;
        break;
    case '2':
        curMat = m2;
        break;
    case '3':
        curMat = m3;
        break;
    case '4':
        curMat = m4;
        break;
    case '5':
        curMat = m5;
        break;
    //change selected object's material to current material
    case 'm':
        if (!currentObj->isLight) currentObj->changeMaterial(curMat);
        break;
    //delete selected object
    case 'x':
        if (sceneObjs->size()!=0) {
            deleteObj(currentObj->ID);
        }
        break;
    //reset scene
    case 'r':
        SG = new SceneGraph();
        nextChild = 0;
        sceneObjs = new vector<SceneObj*>;
        insertLight(light_pos0, amb0, diff0, spec0, 0);
        insertLight(light_pos1, amb1, diff1, spec1, 1);
        break;
    case 9: // toggle selected object (was used before ray picking implemented, still useful anyway)
        currentObj->unselect();
        currentObj = sceneObjs->at(currentObjIndex++%sceneObjs->size());
        currentObj->select();
        break;
    default:
        break;
    }
    glutPostRedisplay();
}
void main (void){
  struct Timer * t1=newObj(Timer,(ulong)1000); 
  struct Timer *t2=newObj(Timer,(ulong)4000);
  struct Timer *t3=newObj(Timer,(ulong)6000);
  struct Timer *t4=newObj(Timer,(ulong)8000);
  struct Timer *t5=newObj(Timer,(ulong)10000);
  struct Timer *t6=newObj(Timer,(ulong)12000);
  struct Timer *t7=newObj(Timer,(ulong)18000); 
  int a = 1;
 /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
 /*** End of Processor Expert internal initialization.                    ***/
  Display_Init(); // Inicializacion del display
  PutValLed(1,0);  
  
  
 //lrReg8Bits(TIE, 1);
  /*ComunLeds_SetVal();
  
  for(;;){
    WDog1_Clear();
    Display2_PutVal(a);
   
    if(Timer_isfinish(t1)){
      a<<=1;
      Timer_Restart(t1);
      if(a==0)
        a=1;
    }
  //  clrReg8Bits(DDRA, DDRA_BIT0_MASK);
    setReg8Bits(PORTA,0);
    bits5ULN_PutVal(0);
  }
  
    */
    
  for(;;){
    WDog1_Clear();
    if(t1 && Timer_isfinish(t1)){
      PasarASCII("Ok88",0); //texto fijo
      deleteObj(&t1);
    }
    if(t2 &&Timer_isfinish(t2)){
      deleteObj(&t2);
      PasarASCII("P.8o.8",1);  //texto fijo con punto
    }
    if(t3 &&Timer_isfinish(t3)){
      deleteObj(&t3);
      Pasar_Numero(2568,1,0);   //paso numero de 4 cifras
    }
    if(t4 &&Timer_isfinish(t4)){
      deleteObj(&t4);
      Pasar_Numero(25681,0,1);   //paso numero de 5 cifras
    }
    if(t5 &&Timer_isfinish(t5)){
      deleteObj(&t5);
       PasarASCII("P.dhAcEL",0);  //texto scroll con punto
    }
    if(t6 &&Timer_isfinish(t6)){
      deleteObj(&t6);
       PasarASCII("V 000.7",1);  //texto scroll con punto
    }
    if(t7 &&Timer_isfinish(t7)){
      deleteObj(&t7);
       PasarASCII("JoniM",1);  //texto scroll con punto
    }  
      
  }
  
}
Exemple #11
0
void CPlotDlg::OnMenu(UINT nID)
{
	static char fullfname[MAX_PATH];
	static CAxis *axSpec(NULL);
	CAxis *localax(gcf->ax[0]); // Following the convention
	CRect rt;
	CSize sz;
	CFont editFont;
	CPosition pos;
	double range, miin(1.e15), maax(-1.e15);
	double width, newmin, newmax;
	int i, len, id1, id2, iSel(-1);
	char errstr[256];
	CSignals signal;
	bool multi;
	static void  *playPoint;
	switch (nID)
	{
	case IDM_FULLVIEW:
		localax->setRange('x',localax->m_ln[0]->xdata[0], localax->m_ln[0]->xdata[localax->m_ln[0]->len-1]);
		localax->setTick('x', 0, localax->m_ln[0]->xdata[localax->m_ln[0]->len-1]/10, 1, 0, "%6.3f");
		// 2/3/2011, commented out by jhpark, because y axis is not affected by zooming.
		//localax->setRange('y', -1, 1);
		OnMenu(IDM_SPECTRUM_INTERNAL);
		return;

	case IDM_ZOOM_IN:
		width = localax->xlim[1] - localax->xlim[0];
		if (width<0.005) return;
		localax->setRange('x', localax->xlim[0] + width/4., localax->xlim[1] - width/4.);
		width = localax->xtick.a2 - localax->xtick.a1;
		localax->xtick.a2 -= width/4.;
		localax->xtick.a1 += width/4.;
		OnMenu(IDM_SPECTRUM_INTERNAL);
		return;

	case IDM_ZOOM_OUT:
		if (localax->xlim[1]==localax->xlimFull[1] && localax->xlim[0]==localax->xlimFull[0]) return;
		for (i=0; i<localax->nLines; i++)
			miin = min(miin, getMin(localax->m_ln[i]->len, localax->m_ln[i]->xdata));
		for (i=0; i<localax->nLines; i++)
			maax = max(maax, getMax(localax->m_ln[i]->len, localax->m_ln[i]->xdata));
		width = localax->xlim[1] - localax->xlim[0];
		localax->setRange('x', max(miin,localax->xlim[0] - width/2.), min(maax,localax->xlim[1] + width/2.));
		width = localax->xtick.a2 - localax->xtick.a1;
		//Oh, I just realized that a1 and a2 do not need to be within the range==> no need to check, it will still draw the ticks only within the range.
		localax->xtick.a2 += width/2.;
		localax->xtick.a1 -= width/2.;
		if (localax->xtick.a1<0) localax->xtick.a1=0;
		OnMenu(IDM_SPECTRUM_INTERNAL);
		return;
	case IDM_SCROLL_LEFT:
		for (i=0; i<localax->nLines; i++)
			miin = min(miin, getMin(localax->m_ln[i]->len, localax->m_ln[i]->xdata));
		range = localax->xlim[1] - localax->xlim[0];
		newmin = max(miin, localax->xlim[0]-range);
		localax->setRange('x', newmin, newmin+range);
		rt = localax->axRect;
		rt.InflateRect(5,0,5,30);
		InvalidateRect(&rt);
		OnMenu(IDM_SPECTRUM_INTERNAL);
		return;
	case IDM_SCROLL_RIGHT:
		for (i=0; i<localax->nLines; i++)
			maax = max(maax, getMax(localax->m_ln[i]->len, localax->m_ln[i]->xdata));
		range = localax->xlim[1] - localax->xlim[0];
		newmax = min(maax, localax->xlim[1]+range);
		localax->setRange('x', newmax-range, newmax);
		rt = localax->axRect;
		rt.InflateRect(5,0,5,30);
		InvalidateRect(&rt);
		OnMenu(IDM_SPECTRUM_INTERNAL);
		return;
	case IDM_LEFT_STEP:
		for (i=0; i<localax->nLines; i++)
			miin = min(miin, getMin(localax->m_ln[i]->len, localax->m_ln[i]->xdata));
		range = localax->xlim[1] - localax->xlim[0];
		newmin = max(miin, localax->xlim[0]-range/4.);
		localax->setRange('x', newmin, newmin+range);
		rt = localax->axRect;
		rt.InflateRect(5,0,5,30);
		InvalidateRect(&rt);
		OnMenu(IDM_SPECTRUM_INTERNAL);
		return;
	case IDM_RIGHT_STEP:
		for (i=0; i<localax->nLines; i++)
			maax = max(maax, getMax(localax->m_ln[i]->len, localax->m_ln[i]->xdata));
		range = localax->xlim[1] - localax->xlim[0];
		newmax = min(maax, localax->xlim[1]+range/4.);
		localax->setRange('x', newmax-range, newmax);
		rt = localax->axRect;
		rt.InflateRect(5,0,5,30);
		InvalidateRect(&rt);
		OnMenu(IDM_SPECTRUM_INTERNAL);
		return;
	case IDM_PLAY:
		errstr[0]=0;
		if (!playing)
			if(!GetSignalInRange(signal,1))		MessageBox (errStr);
			else 
			{
				playPoint = signal.PlayArray(devID, WM__SOUND_EVENT, hDlg, &block, errstr);
				playing = true;
			}
		else
		{
			PauseResumePlay(playPoint, paused);
			playing = paused;
			if (paused) paused = false;
		}
		return;
	case IDM_PAUSE:
		errstr[0]=0;
		if (playing)
		{
			PauseResumePlay(playPoint, false);
			paused = true;
		}
		return;
	case IDM_SPECTRUM:
		// To draw a spectrum, first re-adjust the aspect ratio of the client window 
		// so that the width is at least 1.5 times the height.
		if (!specView)
		{
			GetWindowRect(&rt);
			sz = rt.Size();
			if (sz.cx<3*sz.cy/2)
			{
				rt.InflateRect(0, 0, 3*sz.cy/2, 0);
				MoveWindow(&rt, 0);
			}
			//Again, //Assuming that the first axis is the waveform viewer, the second one is for spectrum viewing
			lastPos = gcf->ax[0]->pos;
			gcf->ax[0]->setPos(.08, .1, .62, .8);
			axSpec = gcf->axes(.75, .3, .22, .4);
			axSpec->colorBack = RGB(230, 230, 190);
			OnMenu(IDM_SPECTRUM_INTERNAL);
		}
		else
		{
			deleteObj(axSpec);
			axSpec=NULL;
			gcf->ax[0]->setPos(lastPos);
		}
		specView = !specView;
		break;
	case IDM_SPECTRUM_INTERNAL:
		rfftw_plan plan;
		double *freq, *fft, *mag, *fft2, *mag2, fs, maxx, maxmag, ylim;
		multi = localax->nLines>1 ? true : false;
		if (gcf->nAxes==1) break;
		fs = (double)sig.GetFs();
		for (; gcf->ax[1]->nLines>0;)	
			deleteObj(gcf->ax[1]->m_ln[0]);
		GetIndicesInRange(localax, id1, id2);
		len = id2-id1+1;
		freq = new double[len];
		fft = new double[len];
		mag = new double[len/2];
		for (i=0; i<len; i++)
			freq[i]=(double)i/(double)len*fs;
		plan = rfftw_create_plan(len, FFTW_FORWARD, FFTW_ESTIMATE|FFTW_OUT_OF_PLACE);
		rfftw_one(plan, &localax->m_ln[0]->ydata[id1], fft);
		if (multi) 
		{
			fft2 = new double[len];
			mag2 = new double[len/2];
			rfftw_one(plan, &localax->m_ln[1]->ydata[id1], fft2);
		}
		rfftw_destroy_plan(plan);
		for (i=0; i<len/2; i++)		mag[i] = 20.*log10(fabs(fft[len-i]));
		if (multi) for (i=0; i<len/2; i++)	mag2[i] = 20.*log10(fabs(fft2[len-i]));
		maxmag = getMax(len/2,mag);
		maxx = 5.*(maxmag/5.+1);
		for (int j=0; j<len/2; j++)	mag[j] -= maxx;
		if (multi) 
		{
			maxmag = getMax(len/2,mag2);
			maxx = 5.*(maxmag/5.+1);
			for (int j=0; j<len/2; j++)	mag2[j] -= maxx;
		}
		ylim = 10.*(maxmag/10.+1)-maxx;
		PlotDouble(gcf->ax[1], len/2, freq, mag);
		SetRange(gcf->ax[1], 'x', 0, fs/2);
		SetTick(gcf->ax[1], 'x', 0, 1000, 0, 0, "%2.0lfk", 0.001);
		SetRange(gcf->ax[1], 'y', getMean(len/2,mag)-40, ylim);
		SetTick(gcf->ax[1], 'y', 0, 10);
		gcf->ax[1]->m_ln[0]->color = gcf->ax[0]->m_ln[0]->color;
		if (multi) 
		{
			PlotDouble(gcf->ax[1], len/2, freq, mag2);
			gcf->ax[1]->m_ln[1]->color = gcf->ax[0]->m_ln[1]->color;
			delete[] fft2;
			delete[] mag2;
		}
		delete[] freq;
		delete[] fft;
		delete[] mag;
		break;
	case IDM_WAVWRITE:
		char fname[MAX_PATH];
		CFileDlg fileDlg;
		fileDlg.InitFileDlg(hDlg, hInst, "");
		errstr[0]=0;
		if(!GetSignalInRange(signal,1))
		{	MessageBox (errStr);	return;	}
		if (fileDlg.FileSaveDlg(fullfname, fname, "Wav file (*.WAV)\0*.wav\0", "wav"))
			if (!signal.Wavwrite(fullfname, errstr))	
			{MessageBox (errstr);}
		else
		{
			CStdString str;
			if (GetLastError()!=0) { GetLastErrorStr(str); MessageBox (str.c_str(), "Filesave error");}
		}
		return;
	}
	InvalidateRect(NULL);
}