Esempio n. 1
0
void Menu::addButton( Button *b ){
     if( next < capacity ){
         this -> arrayButton[ next ] = new Button( b );
         this -> next++;
     }
     if( next == 1 ) arrayButton[ 0 ] -> setSelected( true );
     setUpdated( false );
}
Esempio n. 2
0
Menu::Menu(){
   this -> arrayButton = (Button **)calloc( sizeof(Button) , 3 ); 
   this -> next = 0;
   setUpdated( false ); 
   setPaintHorizontal( false );
   setCapacity( 3 );      
   setSelectedButton( 0 ); 
}
Esempio n. 3
0
void Menu::updateBounds(){
     if( paintHorizontal ){
         for( int i = 0; i < next; i++ ){
                arrayButton[ i ] -> setLocation( x + i*arrayButton[ i ]->getWidth()+gapSize, y );
           }
     }else{
         for( int i = 0; i < next; i++ ){
                //arrayButton[ i ] -> setLocation( this->getX() , this->getY() + (arrayButton[ i ]->getHeight())*i + gapSize );
                arrayButton[ i ] -> setLocation(this->getX(),this->getY()+(arrayButton[ i ]->getHeight()*i+ i*gapSize));
         }
     }
     setUpdated( true );
}
Esempio n. 4
0
void LayerCamera::editProperties()
{
    if ( dialog == NULL )
    {
        dialog = new CameraPropertiesDialog( mName, viewRect.width(), viewRect.height() );
    }
    dialog->setName(mName);
    dialog->setWidth(viewRect.width());
    dialog->setHeight(viewRect.height());
    int result = dialog->exec();
    if (result == QDialog::Accepted)
    {
        mName = dialog->getName();
        viewRect = QRect(-dialog->getWidth()/2, -dialog->getHeight()/2, dialog->getWidth(), dialog->getHeight());

        setUpdated();
    }
}
Esempio n. 5
0
void WeatherPlugin::element_end(const char *el)
{
    if (!strcmp(el, "obst")){
        setLocation(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "lsup")){
        setUpdated(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "sunr") && m_bCC){
        setSun_raise(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "suns") && m_bCC){
        setSun_set(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "vis") && m_bCC){
        setVisibility(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "tmp") && m_bCC){
        setTemperature(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "flik") && m_bCC){
        setFeelsLike(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "devp") && m_bCC){
        setDewPoint(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "hmid") && m_bCC){
        setHumidity(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "low") && m_day){
        setMinT(m_day, m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "hi") && m_day){
        setMaxT(m_day, m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "t")){
        if (!m_bBar && !m_bWind && !m_bUv){
			if (m_bCC){
				setConditions(m_data.c_str());
			}else{
				setDayConditions(m_day, m_data.c_str());
			}
		}
        if (m_bWind && m_bCC)
            setWind(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "icon")){
		if (m_bCC){
			setIcon(atol(m_data.c_str()));
		}else{
			setDayIcon(m_day, m_data.c_str());
		}
        m_data = "";
        return;
    }
    if (!strcmp(el, "ut")){
        setUT(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "up")){
        setUP(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "us")){
        setUS(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "gust") && m_bCC){
        setWindGust(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "bar")){
        m_bBar = false;
        return;
    }
    if (!strcmp(el, "cc")){
        m_bCC = false;
        return;
    }
    if (!strcmp(el, "r") && m_bBar && m_bCC){
        unsigned long v = 0;
        for (const char *p = m_data.c_str(); *p; p++){
            if (*p == '.')
                break;
            if (*p == ',')
                continue;
            v = (v * 10) + (*p - '0');
        }
        setPressure(v);
        return;
    }
    if (!strcmp(el, "d") && m_bBar && m_bCC){
		setPressureD(m_data.c_str());
		m_data = "";
		return;
	}
    if (!strcmp(el, "wind")){
        m_bWind = false;
        return;
    }
    if (!strcmp(el, "s") && m_bWind && m_bCC){
        setWind_speed(atol(m_data.c_str()));
        return;
    }
    if (!strcmp(el, "uv")){
        m_bUv = false;
        return;
    }
}
Esempio n. 6
0
void ULaserDevice::gotNewScan(ULaserData * gotData)
{ // got new data - check for push commands
  // data is available if needed by a getNewestData(ULaserData *) call
  ULaserData * data = gotData;
  bool isOK;
  //
  // Do we have a scan buffer
  if (pushData == NULL)
    // create empty buffer for scanpush commands
    pushData = new ULaserData();
  //
  if (getPushQueue()->getPushCmdCnt() > 0)
  { // push commands exist
    // is the buffer in use (by a scanpush command)
    if (pushData->tryLock())
    { // not in use, so refresh
      if (data == NULL)
      { // request data from native coded queue
        data = pushData;
        // unpack to local buffer
        isOK = getNewestData(data, 0, false);
      }
      else
      { // data is available as parameter, that is OK
        isOK = true;
        // copy to scanpush buffer
        pushData->copy(data);
      }
      if (isOK)
      { // data is available - ask cmdExe to
        // execute push command (when time allows)
        setUpdated("");
      }
      pushData->unlock();
    }
  }
  // check for log needs
  if (datalogInterval > 0)
  {
    if (datalogSeq == 0)
    {
      if (data == NULL)
      { // especially sick do not decode to ULaserData format
        // so do it now - use push-data buffer
        if (pushData->tryLock())
        { // scanbuffer is available get data
          // unpack to ULaserData format
          if (getNewestData(pushData, 0, false))
            logThisScan(pushData);
          pushData->unlock();
        }
      }
      else
        // no resource problem
        logThisScan(data);
    }
    datalogSeq = (datalogSeq + 1) % datalogInterval;
  }
  // update global variables
  if (data != NULL)
    updateScanData(data->getScanTime());
}
Esempio n. 7
0
FLOAT BlockAStar::dtw_update(int firstR,int firstC,int sizeR,int sizeC,point current,FLOAT minCost)
{
	int startR = firstR;
	int startC = firstC;
	int endR = startR + sizeR - 1;
	int endC = startC + sizeC - 1;

	int n,m;
    FLOAT sumLastColPrev,sumLastRowPrev,lastCellPrev;

	//check, if any of the sides are updated
	/*if (isUpdated(current)==0) { //if not, exit
		setUpdated(current,0,0,0); //no updates done
		return minCost;
	}*/


	lastCellPrev = G.get(endR,endC);

	sumLastColPrev = 0;
	for (n=startR;n<=endR;n++) {
		sumLastColPrev += G.get(n,endC);
	}
	sumLastRowPrev = 0;
	for (m=startC;m<=endC;m++) {
		sumLastRowPrev += G.get(endR,m);
	}

	for (n=startR;n<=endR;n++) {
		for (m=startC;m<=endC;m++) {
			//G.set(n,m,min(min(G.get(n-1,m)+ dtwCostPerNondiagMove,G.get(n-1,m-1)+D.getCost(n,m)),G.get(n,m-1)+dtwCostPerNondiagMove));
			G.set(n,m,min(min(G.get(n-1,m)+ dtwCostPerNondiagMove,G.get(n-1,m-1)+D.getCost(n,m)),min(G.get(n,m-1)+dtwCostPerNondiagMove,G.get(n,m))));
		}
	}

	//return minimum value
	//minDist=min(min(G(endR,startC:endC)),min(G(startR:endR,endC)));

	//return minimum value per side
#ifdef SIMPLEHEURISTIC
	FLOAT uScalar = fCostPerMove*dtwCostPerNondiagMove;
#else
	FLOAT uScalar = ONE_OVER_SQRT2 * fCostPerMove; //1 dimension of unit vector
#endif //SIMPLEHEURISTIC

	//search along the border
	FLOAT tmpDist,tmpHeur;
	FLOAT minDist = G.get(endR,endC); //corner
    FLOAT sumLastCol,sumLastRow,lastCell;

	lastCell = G.get(endR,endC);
	sumLastRow = 0;
	for (m = 0;m<sizeC;m++) { //last row
		tmpHeur = uScalar * (sizeC - m - 1)/blockSize;
		tmpDist = G.get(endR,firstC+m) + tmpHeur;
		if (tmpDist<minDist) {
			minDist = tmpDist;
		}
		sumLastRow += G.get(endR,firstC+m);
	}

	sumLastCol = 0;
	for (n = 0;n<sizeR;n++) { //last column
		tmpHeur = uScalar * (sizeR - n - 1)/blockSize;
		tmpDist = G.get(firstR+n,endC) + tmpHeur;
		if (tmpDist<minDist) {
			minDist = tmpDist;
		}
		sumLastCol += G.get(firstR+n,endC);
	}

	//set update flags
	//setUpdated(current,sumLastRow<sumLastRowPrev,sumLastCol<sumLastColPrev,lastCell<lastCellPrev);
	setUpdated(current);

	return minDist;
}
Esempio n. 8
0
FLOAT BlockAStar::dtw(int firstR,int firstC,int sizeR,int sizeC,point current)
{
	int startR = firstR;
	int startC = firstC;
	int endR = startR + sizeR - 1;
	int endC = startC + sizeC - 1;

	int n,m;

	bool updatedSide[3] = {updated[0]->get(current),updated[1]->get(current),updated[2]->get(current)};

	//update first corner (if it is not the start point, then at least one update has to be 1)
	if ((startC == 0)&&( startR == 0)) {
		G.set(startR,startC,D.getCost(0,0));
	} else {
		G.set(startR,startC,INF);
	}

	if (updatedSide[2]==1) { //diag
		G.set(startR,startC,min(G.get(startR-1,startC-1)+D.getCost(startR,startC),G.get(startR,startC)));
	}
	if (updatedSide[0]==1) { //vert
		G.set(startR,startC,min(G.get(startR-1,startC)+dtwCostPerNondiagMove,G.get(startR,startC)));
	}
	if (updatedSide[1]==1) { //horiz
		G.set(startR,startC,min(G.get(startR,startC-1)+dtwCostPerNondiagMove,G.get(startR,startC)));
	}

	//calculate edge distances
	if ((startC == 0 || updatedSide[1]==0)&&( startR == 0 || updatedSide[0]==0)) //ignore both sides
	{
		for (n=startR+1;n<=endR;n++) {
			G.set(n,0,G.get(n-1,0)+dtwCostPerNondiagMove);
		}
		for (m=startC+1;m<=endC;m++) {
			G.set(0,m,G.get(0,m-1)+dtwCostPerNondiagMove);
		}
		startC = startC+1;
		startR = startR+1;
	}
	else if (startC == 0 || updatedSide[1]==0) {//ignore horizontal side
		for (n=startR+1;n<=endR;n++) {
			G.set(n,startC,G.get(n-1,startC)+dtwCostPerNondiagMove);
		}
		startC = startC+1;
	}
	else if (startR == 0 || updatedSide[0]==0) {//ignore vertical side
		for (m=startC+1;m<=endC;m++) {
			G.set(startR,m,G.get(startR,m-1)+dtwCostPerNondiagMove);
		}
		startR = startR+1;
	}
    
	for (n=startR;n<=endR;n++) {
		for (m=startC;m<=endC;m++) {
			G.set(n,m,min(min(G.get(n-1,m)+ dtwCostPerNondiagMove,G.get(n-1,m-1)+D.getCost(n,m)),G.get(n,m-1)+dtwCostPerNondiagMove));
		}
	}

	//return minimum value
	//minDist=min(min(G(endR,startC:endC)),min(G(startR:endR,endC)));

	//return minimum value per side
#ifdef SIMPLEHEURISTIC
	FLOAT uScalar = fCostPerMove*dtwCostPerNondiagMove;
#else
	FLOAT uScalar = ONE_OVER_SQRT2 * fCostPerMove; //1 dimension of unit vector
#endif //SIMPLEHEURISTIC

	//search along the border
	FLOAT tmpDist,tmpHeur;
	FLOAT minDist = G.get(endR,endC); //corner

	for (m = 0;m<sizeC;m++) { //last row
		tmpHeur = uScalar * (sizeC - m - 1)/blockSize;
		tmpDist = G.get(endR,firstC+m) + tmpHeur;
		if (tmpDist<minDist) {
			minDist = tmpDist;
		}
	}

	for (n = 0;n<sizeR;n++) { //last column
		tmpHeur = uScalar * (sizeR - n - 1)/blockSize;
		tmpDist = G.get(firstR+n,endC) + tmpHeur;
		if (tmpDist<minDist) {
			minDist = tmpDist;
		}
	}

	//set update flags
	setUpdated(current);

	return minDist;
}
Esempio n. 9
0
void WeatherPlugin::element_end(const char *el)
{
    if (!strcmp(el, "day")){
        if ((*getMinT(m_day) == 0) || (*getMaxT(m_day) == 0))
            m_day--;
        return;
    }
    if (!strcmp(el, "obst")){
        setLocation(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "lsup")){
        setUpdated(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "sunr") && (m_day == 0)){
        setSun_raise(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "suns") && (m_day == 0)){
        setSun_set(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "vis") && m_bCC){
        setVisibility(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "tmp") && m_bCC){
        setTemperature(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "flik") && m_bCC){
        setFeelsLike(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "dewp") && m_bCC){
        setDewPoint(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "ppcp") && (m_day == 1) ) {
        if (((m_bDayPart == 'd') && m_bDayForecastIsValid) || ((m_bDayPart == 'n') && ! m_bDayForecastIsValid )){
    	    setPrecipitation(atol(m_data.c_str()));
    	    m_data = "";
    	    return;
	}
    }	
    if (!strcmp(el, "hmid") && m_bCC){
        setHumidity(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "low") && m_day){
        if (m_data == "N/A")
            m_data = "";
        setMinT(m_day, m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "hi") && m_day){
        if (m_data == "N/A")
            m_data = "-255";
        setMaxT(m_day, m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "t")){
        if (!m_bBar && !m_bWind && !m_bUv && !m_bMoon){
            if (m_bCC){
                setConditions(m_data.c_str());
            }else{
                setDayConditions(m_day, m_data.c_str());
		if ((m_data == "N/A") && (m_bDayPart == 'd')) 
		    m_bDayForecastIsValid = false;
            }
        }
        if (m_bWind && m_bCC)
            setWind(m_data.c_str());
        if (m_bUv && m_bCC)
            setUV_Description(m_data.c_str());
        if (m_bMoon && m_bCC)
            setMoonPhase(m_data.c_str());

        m_data = "";
        return;
    }
    if (!strcmp(el, "i")) {
        if (m_bUv && m_bCC)
            setUV_Intensity(strtol(m_data.c_str(),NULL,10));
        m_data = "";
        return;
    }
    if (!strcmp(el, "icon")){
        if (m_bMoon && m_bCC) {
            setMoonIcon(atol(m_data.c_str()));
        } else if (m_bCC){
            setIcon(atoul(m_data.c_str()));
        }else{
            setDayIcon(m_day, m_data.c_str());
        }
        m_data = "";
        return;
    }
    if (!strcmp(el, "ut")){
        setUT(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "up")){
        setUP(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "us")){
        setUS(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "ud")){
        setUD(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "gust") && m_bCC){
        setWindGust(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "bar")){
        m_bBar = false;
        return;
    }
    if (!strcmp(el, "cc")){
        m_bCC = false;
        return;
    }
    if (!strcmp(el, "r") && m_bBar && m_bCC){
        unsigned long v = 0;
        for (const char *p = m_data.c_str(); *p; p++){
            if (*p == '.')
                break;
            if (*p == ',')
                continue;
            v = (v * 10) + (*p - '0');
        }
        setPressure(v);
        return;
    }
    if (!strcmp(el, "d") && m_bBar && m_bCC){
        setPressureD(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "wind")){
        m_bWind = false;
        return;
    }
    if (!strcmp(el, "s") && m_bWind && m_bCC){
        setWind_speed(atol(m_data.c_str()));
        return;
    }
    if (!strcmp(el, "uv")){
        m_bUv = false;
        return;
    }
    if (!strcmp(el, "moon")){
        m_bMoon = false;
        return;
    }
}
Esempio n. 10
0
void WeatherPlugin::element_end(const char *el)
{
	if (!strcmp(el, "obst")){
		setLocation(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "lsup")){
		setUpdated(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "sunr")){
		setSun_raise(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "suns")){
		setSun_set(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "tmp")){
		setTemperature(atol(m_data.c_str()));
		m_data = "";
		return;
	}
	if (!strcmp(el, "hmid")){
		setHumidity(atol(m_data.c_str()));
		m_data = "";
		return;
	}
	if (!strcmp(el, "t")){
		if (!m_bBar && !m_bWind && !m_bUv)
			setConditions(m_data.c_str());
		if (m_bWind)
			setWind(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "icon")){
		setIcon(atol(m_data.c_str()));
		m_data = "";
		return;
	}
	if (!strcmp(el, "ut")){
		setUT(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "up")){
		setUP(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "us")){
		setUS(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "bar")){
		m_bBar = false;
		return;
	}
	if (!strcmp(el, "r") && m_bBar){
		unsigned long v = 0;
		for (const char *p = m_data.c_str(); *p; p++){
			if (*p == '.')
				break;
			if (*p == ',')
				continue;
			v = (v * 10) + (*p - '0');
		}
		setPressure(v);
		return;
	}
	if (!strcmp(el, "wind")){
		m_bWind = false;
		return;
	}
	if (!strcmp(el, "s") && m_bWind){
		setWind_speed(atol(m_data.c_str()));
		return;
	}
	if (!strcmp(el, "uv")){
		m_bUv = false;
		return;
	}
}
Esempio n. 11
0
void setFromPreset(size_t num)
{
    settings->vjoy_controls = getPreset(num);
    settings->vjoy_current_preset = num;
    setUpdated();
}