Exemplo n.º 1
0
void QSplitter::moveAfter( int pos, int id, bool upLeft )
{
    QSplitterLayoutStruct *s = id < int(data->list.count()) ?
			       data->list.at(id) : 0;
    if ( !s )
	return;
    QWidget *w = s->wid;
    if ( w->isHidden() ) {
	moveAfter( pos, id+1, upLeft );
    } else if ( pick( w->pos() ) == pos ) {
	//No need to do anything if it's already there.
	return;
    } else if ( s->isSplitter ) {
	int dd = s->sizer;
	if ( upLeft ) {
	    setG( w, pos, dd );
	    moveAfter( pos+dd, id+1, upLeft );
	} else {
	    moveAfter( pos+dd, id+1, upLeft );
	    setG( w, pos, dd );
	}
    } else {
	int right = pick( w->geometry().bottomRight() );

       	int dd = right - pos + 1;
	dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
	int newRight = pos+dd-1;
	setG( w, pos, dd );
	moveAfter( newRight+1, id+1, upLeft );
    }
}
Exemplo n.º 2
0
void QSplitter::moveBefore( int pos, int id, bool upLeft )
{
    QSplitterLayoutStruct *s = data->list.at(id);
    if ( !s )
	return;
    QWidget *w = s->wid;
    if ( w->isHidden() ) {
	moveBefore( pos, id-1, upLeft );
    } else if ( s->isSplitter ) {
	int dd = s->sizer;
	if ( upLeft ) {
	    setG( w, pos-dd+1, dd );
	    moveBefore( pos-dd, id-1, upLeft );
	} else {
	    moveBefore( pos-dd, id-1, upLeft );
	    setG( w, pos-dd+1, dd );
	}
    } else {
	int left = pick( w->pos() );
	int dd = pos - left + 1;
	dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
	int newLeft = pos-dd+1;
	setG( w, newLeft, dd );
	if ( left != newLeft )
	    moveBefore( newLeft-1, id-1, upLeft );
    }
}
Exemplo n.º 3
0
/* int Dstar::computeShortestPath()
 * --------------------------
 * As per [S. Koenig, 2002] except for 2 main modifications:
 * 1. We stop planning after a number of steps, 'maxsteps' we do this
 *    because this algorithm can plan forever if the start is
 *    surrounded by obstacles. 
 * 2. We lazily remove states from the open list so we never have to
 *    iterate through it.
 */
int Dstar::computeShortestPath() {
  
  list<state> s;
  list<state>::iterator i;

  if (openList.empty()) return 1;

  int k=0;
  while ((!openList.empty()) && 
         (openList.top() < (calculateKey(s_start))) || 
         (!isConsistent(s_start))) {

    if (k++ > maxSteps) {
      fprintf(stderr, "At maxsteps\n");
      return -1;
    }
    
    
    state u;
    
    // check consistency (one of the loop conditions)
    bool test = isConsistent(s_start);
    //(getRHS(s_start) != getG(s_start));
    
    // lazy remove
    while(1) { 
      if (openList.empty()) return 1; // checks outer loop condition #1
      u = openList.top();
      
      if (!queuePop()) continue;
      
      if (!(u < s_start) && test) return 2; // checks outer loop conditions #2,3 still hold
    
      break;
    }
    
    state k_old = u;

    if (k_old < calculateKey(u)) { // u is out of date
      insert(u); // u has been removed already, reinsert into pq with new key
    } else if (getG(u) > getRHS(u)) { // needs update (got better)
      setG(u,getRHS(u));
      getPred(u,s);
      for (i=s.begin();i != s.end(); i++) {
        updateVertex(*i);
      }
    } else {   // g <= rhs, state has got worse
      setG(u,INFINITY);
      getPred(u,s);
      for (i=s.begin();i != s.end(); i++) {
        updateVertex(*i);
      }
      updateVertex(u);
    }
  }
  return 0;
}
Exemplo n.º 4
0
/* int Dstar::computeShortestPath()
 * --------------------------
 * As per [S. Koenig, 2002] except for 2 main modifications:
 * 1. We stop planning after a number of steps, 'maxsteps' we do this
 *    because this algorithm can plan forever if the start is
 *    surrounded by obstacles.
 * 2. We lazily remove states from the open list so we never have to
 *    iterate through it.
 */
int Dstar::computeShortestPath() {

  list<state> s;
  list<state>::iterator i;

  if (openList.empty()) return 1;

  int k=0;
  while ((!openList.empty()) &&
         (openList.top() < (s_start = calculateKey(s_start))) ||
         (getRHS(s_start) != getG(s_start))) {

    if (k++ > maxSteps) {
      fprintf(stderr, "At maxsteps\n");
      return -1;
    }


    state u;

    bool test = (getRHS(s_start) != getG(s_start));

    // lazy remove
    while(1) {
      if (openList.empty()) return 1;
      u = openList.top();
      openList.pop();

      if (!isValid(u)) continue;
      if (!(u < s_start) && (!test)) return 2;
      break;
    }

    ds_oh::iterator cur = openHash.find(u);
    openHash.erase(cur);

    state k_old = u;

    if (k_old < calculateKey(u)) { // u is out of date
      insert(u);
    } else if (getG(u) > getRHS(u)) { // needs update (got better)
      setG(u,getRHS(u));
      getPred(u,s);
      for (i=s.begin();i != s.end(); i++) {
        updateVertex(*i);
      }
    } else {   // g <= rhs, state has got worse
      setG(u,INFINITY);
      getPred(u,s);
      for (i=s.begin();i != s.end(); i++) {
        updateVertex(*i);
      }
      updateVertex(u);
    }
  }
  return 0;
}
Exemplo n.º 5
0
// RGBVec: private methods
void RGBVec::normalise() {
	// simply clip the colour
	if (r() > 1.0) setR(1.0);
	if (g() > 1.0) setG(1.0);
	if (b() > 1.0) setB(1.0);

	if (r() < 0.0) setR(0.0);
	if (g() < 0.0) setG(0.0);
	if (b() < 0.0) setB(0.0);
}
Exemplo n.º 6
0
// Set from OpenSSL representation
void OSSLDSAPublicKey::setFromOSSL(const DSA* inDSA)
{
	const BIGNUM* bn_p = NULL;
	const BIGNUM* bn_q = NULL;
	const BIGNUM* bn_g = NULL;
	const BIGNUM* bn_pub_key = NULL;

	DSA_get0_pqg(inDSA, &bn_p, &bn_q, &bn_g);
	DSA_get0_key(inDSA, &bn_pub_key, NULL);

	if (bn_p)
	{
		ByteString inP = OSSL::bn2ByteString(bn_p);
		setP(inP);
	}
	if (bn_q)
	{
		ByteString inQ = OSSL::bn2ByteString(bn_q);
		setQ(inQ);
	}
	if (bn_g)
	{
		ByteString inG = OSSL::bn2ByteString(bn_g);
		setG(inG);
	}
	if (bn_pub_key)
	{
		ByteString inY = OSSL::bn2ByteString(bn_pub_key);
		setY(inY);
	}
}
Exemplo n.º 7
0
// Set from OpenSSL representation
void OSSLDSAPrivateKey::setFromOSSL(const DSA* dsa)
{
	if (dsa->p) { ByteString p = OSSL::bn2ByteString(dsa->p); setP(p); }
	if (dsa->q) { ByteString q = OSSL::bn2ByteString(dsa->q); setQ(q); }
	if (dsa->g) { ByteString g = OSSL::bn2ByteString(dsa->g); setG(g); }
	if (dsa->priv_key) { ByteString x = OSSL::bn2ByteString(dsa->priv_key); setX(x); }
}
Exemplo n.º 8
0
// Set from OpenSSL representation
void OSSLDHPublicKey::setFromOSSL(const DH* inDH)
{
	const BIGNUM* bn_p = NULL;
	const BIGNUM* bn_g = NULL;
	const BIGNUM* bn_pub_key = NULL;

	DH_get0_pqg(inDH, &bn_p, NULL, &bn_g);
	DH_get0_key(inDH, &bn_pub_key, NULL);

	if (bn_p)
	{
		ByteString inP = OSSL::bn2ByteString(bn_p);
		setP(inP);
	}
	if (bn_g)
	{
		ByteString inG = OSSL::bn2ByteString(bn_g);
		setG(inG);
	}
	if (bn_pub_key)
	{
		ByteString inY = OSSL::bn2ByteString(bn_pub_key);
		setY(inY);
	}
}
// Set from Botan representation
void BotanDHPublicKey::setFromBotan(const Botan::DH_PublicKey* dh)
{
	ByteString p = BotanUtil::bigInt2ByteString(dh->group_p());
	setP(p);
	ByteString g = BotanUtil::bigInt2ByteString(dh->group_g());
	setG(g);
	ByteString y = BotanUtil::bigInt2ByteString(dh->get_y());
	setY(y);
}
// Set from Botan representation
void BotanDSAPrivateKey::setFromBotan(const Botan::DSA_PrivateKey* dsa)
{
	ByteString p = BotanUtil::bigInt2ByteString(dsa->group_p());
	setP(p);
	ByteString q = BotanUtil::bigInt2ByteString(dsa->group_q());
	setQ(q);
	ByteString g = BotanUtil::bigInt2ByteString(dsa->group_g());
	setG(g);
	ByteString x = BotanUtil::bigInt2ByteString(dsa->get_x());
	setX(x);
}
Exemplo n.º 11
0
// Set from Botan representation
void BotanDSAPrivateKey::setFromBotan(const Botan::DSA_PrivateKey* inDSA)
{
    ByteString inP = BotanUtil::bigInt2ByteString(inDSA->group_p());
    setP(inP);
    ByteString inQ = BotanUtil::bigInt2ByteString(inDSA->group_q());
    setQ(inQ);
    ByteString inG = BotanUtil::bigInt2ByteString(inDSA->group_g());
    setG(inG);
    ByteString inX = BotanUtil::bigInt2ByteString(inDSA->get_x());
    setX(inX);
}
Exemplo n.º 12
0
/* void Dstar::updateStart(int x, int y)
 * --------------------------
 * Update the position of the robot, this does not force a replan.
 */
void Dstar::updateStart(int x, int y) {

  s_start.x = x;
  s_start.y = y;
  
  k_m += heuristic(s_last,s_start);
  
  setRHS(s_start,INFINITY);
  setG(s_start,INFINITY);
  s_start = calculateKey(s_start);
  s_last  = s_start;
}
Exemplo n.º 13
0
bool DHParameters::deserialise(ByteString& serialised)
{
	ByteString dP = ByteString::chainDeserialise(serialised);
	ByteString dG = ByteString::chainDeserialise(serialised);

	if ((dP.size() == 0) ||
	    (dG.size() == 0))
	{
		return false;
	}

	setP(dP);
	setG(dG);

	return true;
}
Exemplo n.º 14
0
void TGAImage::initFirstLOD( unsigned char* srcData)
{

	lodData[0] = new unsigned char[ getLODwidth(0) * getLODheight(0) * BPP ] ;
	
	for( int i = 0 ; i < getLODwidth(0) ; i++ )
		for( int j = 0 ; j < getLODheight(0) ; j++ )
		{
			unsigned char r, g, b, a ;
			if( srcData ) getRGBA( srcData, i, getLODheight(0) - 1 - j, r, g, b, a ) ;
			else r = g = b = a = 0 ;

			setR( 0, i, j, r ) ;
			setG( 0, i, j, g ) ;
			setB( 0, i, j, b ) ;
			setA( 0, i, j, a ) ;
		}
	goodLOD = 0 ;
}
Exemplo n.º 15
0
bool Astar::checkOpen(int col, int row, int id)
{
    // 检查open列表中是否有更小的步长,并排序
    for(int i = _open->count() - 1; i > 0; i--) {
        auto item = (AstarItem*)_open->getObjectAtIndex(i);
        if(item->getCol() == col && item->getRow() == row) {
            int tempG = getG(col, row, id);
            if(tempG < item->getG()) {
                item->setG(tempG);
                item->setFid(id);
                item->setF(tempG + item->getH());
                resetSort(i);
            }
            return false;
        }
    }

    return true;
}
Exemplo n.º 16
0
bool DHPrivateKey::deserialise(ByteString& serialised)
{
	ByteString dP = ByteString::chainDeserialise(serialised);
	ByteString dG = ByteString::chainDeserialise(serialised);
	ByteString dX = ByteString::chainDeserialise(serialised);

	if ((dP.size() == 0) ||
	    (dG.size() == 0) ||
	    (dX.size() == 0))
	{
		return false;
	}

	setP(dP);
	setG(dG);
	setX(dX);

	return true;
}
Exemplo n.º 17
0
CSeaData::CSeaData( const CSeaData &object )
{
    setWaveInputType( object.waveInputType() );
    setWaveAngle( object.waveAngle() );
    setWaveHeight( object.waveHeight() );
    setWaveMaxHeight( object.waveMaxHeight() );
    setWaveSpreading( object.waveSpreading() );
    setWaveType( object.waveType() );
    setWaveLength( object.waveLength() );
    setWavePeriod( object.wavePeriod() );
    setCurrentInputType( object.currentInputType() );
    setFlowAngle( object.flowAngle() );
    setFlowSpeed( object.flowSpeed() );
    setSeaTemperature( object.seaTemperature() );
    setSeaTemperaturechange( object.seaTemperatureChange() );
    setIceThickness( object.iceThickness() );
    setR( object.r() );
    setB( object.b() );
    setG( object.g() );
}
Exemplo n.º 18
0
CSeaData::CSeaData():
    m_dbWaveInputType( false ),
    m_dWaveAngle( 0.0 ),
    m_dWaveHeight( 0.0 ),
    m_dWaveMaxHeight( 0.0 ),
    m_diWaveSpreading( 0 ),
    m_dWaveType( 0.0 ),
    m_dWaveLength( 0.0 ),
    m_dWavePeriod( 0.0 ),
    m_dbCurrentInputType( false ),
    m_dFlowAngle( 0.0 ),
    m_dFlowSpeed( 0.0 ),
    m_dSeaTemperature( 0.0 ),
    m_dSeaTemperaturechange( 0.0 ),
    m_dIceThickness( 0.0 )

{
    setR(0);
    setB(0);
    setG(0);
}
Exemplo n.º 19
0
void TGAImage::generateLOD( int lod )
{
	int dstW = getLODwidth(lod) ;
	int dstH = getLODheight(lod);

	if( lodData[lod] == NULL ) lodData[lod] = new unsigned char[ dstW * dstH * BPP ] ;

	int s = getLODwidth(0) / dstW ;
	int t = getLODheight(0) / dstH ;

	for( int i = 0 ; i < dstW ; i++ )
		for( int j = 0 ; j < dstH ; j++ )
		{
			
			int r = 0, g = 0, b = 0, a = 0 ;

			for( int k = 0 ; k < s ; k++ )
				for( int l = 0 ; l < t ; l++ )
				{
					r += getR( 0, i * s + k, j * t + l ) ;
					g += getG( 0, i * s + k, j * t + l ) ;
					b += getB( 0, i * s + k, j * t + l ) ;
					a += getA( 0, i * s + k, j * t + l ) ;
				}

			r /= s * t ;
			g /= s * t ;
			b /= s * t ;
			a /= s * t ;
			
			setR( lod, i, j, r ) ;
			setG( lod, i, j, g ) ;
			setB( lod, i, j, b ) ;
			setA( lod, i, j, a ) ;
		}

	goodLOD = lod ;
}
Exemplo n.º 20
0
// Set from OpenSSL representation
void OSSLDHPrivateKey::setFromOSSL(const DH* dh)
{
	if (dh->p) { ByteString p = OSSL::bn2ByteString(dh->p); setP(p); }
	if (dh->g) { ByteString g = OSSL::bn2ByteString(dh->g); setG(g); }
	if (dh->priv_key) { ByteString x = OSSL::bn2ByteString(dh->priv_key); setX(x); }
}
Exemplo n.º 21
0
void TGAImage::setG( int i, int j, int v )
{
	setG( 0, i, j, v ) ;
}