Пример #1
0
/*
 * NAME:	synth->half()
 * DESCRIPTION:	perform half frequency PCM synthesis
 */
static
void synth_half(struct mad_synth *synth, struct mad_frame /*const*/ *frame,
		unsigned int nch, unsigned int ns)
{
  unsigned int phase, ch, s, sb, pe, po;
  short int *pcm1, *pcm2;
  mad_fixed_t (*filter)[2][2][16][8];
  mad_fixed_t (*sbsample)[36][32];
  register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
  register mad_fixed_t const (*Dptr)[32], *ptr ;
  register mad_fixed64hi_t hi;
  register mad_fixed64lo_t lo;
  mad_fixed_t raw_sample;
  
  static short int short_sample_buff[16];

  phase = synth->phase;

  for (s = 0; s < ns; ++s)
  {
    memset (short_sample_buff, 0x00, sizeof(short_sample_buff));

    for (ch = 0; ch < nch; ++ch)
    {
      sbsample = &frame->sbsample[ch];
      filter   = &synth->filter[ch];      
      pcm1     = short_sample_buff;

      dct32((*sbsample)[s], phase >> 1,
	    (*filter)[0][phase & 1], (*filter)[1][phase & 1]);

      pe = phase & ~1;
      po = ((phase - 1) & 0xf) | 1;

      /* calculate 16 samples */

      fe = &(*filter)[0][ phase & 1][0];
      fx = &(*filter)[0][~phase & 1][0];
      fo = &(*filter)[1][~phase & 1][0];

      Dptr = &D[0];

      ptr = *Dptr + po;
      ML0(hi, lo, (*fx)[0], ptr[ 0]);
      MLA(hi, lo, (*fx)[1], ptr[14]);
      MLA(hi, lo, (*fx)[2], ptr[12]);
      MLA(hi, lo, (*fx)[3], ptr[10]);
      MLA(hi, lo, (*fx)[4], ptr[ 8]);
      MLA(hi, lo, (*fx)[5], ptr[ 6]);
      MLA(hi, lo, (*fx)[6], ptr[ 4]);
      MLA(hi, lo, (*fx)[7], ptr[ 2]);
      MLN(hi, lo);

      ptr = *Dptr + pe;
      MLA(hi, lo, (*fe)[0], ptr[ 0]);
      MLA(hi, lo, (*fe)[1], ptr[14]);
      MLA(hi, lo, (*fe)[2], ptr[12]);
      MLA(hi, lo, (*fe)[3], ptr[10]);
      MLA(hi, lo, (*fe)[4], ptr[ 8]);
      MLA(hi, lo, (*fe)[5], ptr[ 6]);
      MLA(hi, lo, (*fe)[6], ptr[ 4]);
      MLA(hi, lo, (*fe)[7], ptr[ 2]);

      raw_sample = SHIFT(MLZ(hi, lo));
      raw_sample = scale(raw_sample);
      (*pcm1++) += (short int)raw_sample;
      pcm2 = pcm1 + 14;

      for (sb = 1; sb < 16; ++sb)
      {
        ++fe;
        ++Dptr;

        /* D[32 - sb][i] == -D[sb][31 - i] */

        ptr = *Dptr + po;
        ML0(hi, lo, (*fo)[0], ptr[ 0]);
        MLA(hi, lo, (*fo)[1], ptr[14]);
        MLA(hi, lo, (*fo)[2], ptr[12]);
        MLA(hi, lo, (*fo)[3], ptr[10]);
        MLA(hi, lo, (*fo)[4], ptr[ 8]);
        MLA(hi, lo, (*fo)[5], ptr[ 6]);
        MLA(hi, lo, (*fo)[6], ptr[ 4]);
        MLA(hi, lo, (*fo)[7], ptr[ 2]);
        MLN(hi, lo);

        ptr = *Dptr + pe;
        MLA(hi, lo, (*fe)[7], ptr[ 2]);
        MLA(hi, lo, (*fe)[6], ptr[ 4]);
        MLA(hi, lo, (*fe)[5], ptr[ 6]);
        MLA(hi, lo, (*fe)[4], ptr[ 8]);
        MLA(hi, lo, (*fe)[3], ptr[10]);
        MLA(hi, lo, (*fe)[2], ptr[12]);
        MLA(hi, lo, (*fe)[1], ptr[14]);
        MLA(hi, lo, (*fe)[0], ptr[ 0]);

        raw_sample = SHIFT(MLZ(hi, lo));
        raw_sample = scale(raw_sample);
        (*pcm1++) += (short int)raw_sample;

        ptr = *Dptr - pe;
        ML0(hi, lo, (*fe)[0], ptr[31 - 16]);
        MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
        MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
        MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
        MLA(hi, lo, (*fe)[4], ptr[31 -  8]);
        MLA(hi, lo, (*fe)[5], ptr[31 -  6]);
        MLA(hi, lo, (*fe)[6], ptr[31 -  4]);
        MLA(hi, lo, (*fe)[7], ptr[31 -  2]);

        ptr = *Dptr - po;
        MLA(hi, lo, (*fo)[7], ptr[31 -  2]);
        MLA(hi, lo, (*fo)[6], ptr[31 -  4]);
        MLA(hi, lo, (*fo)[5], ptr[31 -  6]);
        MLA(hi, lo, (*fo)[4], ptr[31 -  8]);
        MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
        MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
        MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
        MLA(hi, lo, (*fo)[0], ptr[31 - 16]);

        raw_sample = SHIFT(MLZ(hi, lo));
        raw_sample = scale(raw_sample);
        (*pcm2--) += (short int)raw_sample;

        ++fo;
      }

      Dptr++;

      ptr = *Dptr + po;
      ML0(hi, lo, (*fo)[0], ptr[ 0]);
      MLA(hi, lo, (*fo)[1], ptr[14]);
      MLA(hi, lo, (*fo)[2], ptr[12]);
      MLA(hi, lo, (*fo)[3], ptr[10]);
      MLA(hi, lo, (*fo)[4], ptr[ 8]);
      MLA(hi, lo, (*fo)[5], ptr[ 6]);
      MLA(hi, lo, (*fo)[6], ptr[ 4]);
      MLA(hi, lo, (*fo)[7], ptr[ 2]);

      raw_sample = SHIFT(-MLZ(hi, lo));
      raw_sample = scale(raw_sample);
      (*pcm1) += (short int)raw_sample;

    } /* Channel For */

    /* Block render */
    //--render_sample_block(short_sample_buff, 16);
    WriteMP3ToBuffer(short_sample_buff,16);
    phase = (phase + 1) % 16;

  }/* Block For */
}
Пример #2
0
		void GRect::scale(double scl) 
		{ 
			scale(scl,scl);
		}
Пример #3
0
void PianoView::wheelEvent(QWheelEvent* event)
      {
      int step = event->delta() / 120;
      double xmag = transform().m11();
      double ymag = transform().m22();

      if (event->modifiers() == Qt::ControlModifier) {
            if (step > 0) {
                  for (int i = 0; i < step; ++i) {
                        if (xmag > 10.0)
                              break;
                        scale(1.1, 1.0);
                        xmag *= 1.1;
                        }
                  }
            else {
                  for (int i = 0; i < -step; ++i) {
                        if (xmag < 0.001)
                              break;
                        scale(.9, 1.0);
                        xmag *= .9;
                        }
                  }
            emit magChanged(xmag, ymag);

            int tpix  = (480 * 4) * xmag;
            magStep = -5;
            if (tpix <= 4000)
                  magStep = -4;
            if (tpix <= 2000)
                  magStep = -3;
            if (tpix <= 1000)
                  magStep = -2;
            if (tpix <= 500)
                  magStep = -1;
            if (tpix <= 128)
                  magStep = 0;
            if (tpix <= 64)
                  magStep = 1;
            if (tpix <= 32)
                  magStep = 2;
            if (tpix <= 16)
                  magStep = 3;
            if (tpix <= 8)
                  magStep = 4;
            if (tpix <= 4)
                  magStep = 5;
            if (tpix <= 2)
                  magStep = 6;

            //
            // if xpos <= 0, then the scene is centered
            // there is no scroll bar anymore sending
            // change signals, so we have to do it here:
            //
            double xpos = -(mapFromScene(QPointF()).x());
            if (xpos <= 0)
                  emit xposChanged(xpos);
            }
      else if (event->modifiers() == Qt::ShiftModifier) {
            QWheelEvent we(event->pos(), event->delta(), event->buttons(), 0, Qt::Horizontal);
            QGraphicsView::wheelEvent(&we);
            }
      else if (event->modifiers() == 0) {
            QGraphicsView::wheelEvent(event);
            }
      else if (event->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier)) {
            if (step > 0) {
                  for (int i = 0; i < step; ++i) {
                        if (ymag > 3.0)
                              break;
                        scale(1.0, 1.1);
                        ymag *= 1.1;
                        }
                  }
            else {
                  for (int i = 0; i < -step; ++i) {
                        if (ymag < 0.4)
                              break;
                        scale(1.0, .9);
                        ymag *= .9;
                        }
                  }
            emit magChanged(xmag, ymag);
            }
      }
Пример #4
0
 virtual uint64_t toHours(const uint64_t d) {
     return scale(d, (C6 / C5), (TimeUnit::MAX / (C6 / C5)));
 }
Пример #5
0
/* ------------------------------------------------------------------ run --- */
int BASE::run()
{
	int	i = 0;
	double roomsig[2][BUFLEN], rvbsig[2][BUFLEN];

	const int totalSamps = insamps + tapcount;

	const int frameCount = framesToRun();
	
	DBG1(printf("%s::run(): totalSamps = %d\n", name(), totalSamps));

	// this will return frameCount' worth of input, even if we have
	// passed the end of the input (will produce zeros)

	getInput(cursamp, frameCount);

	DBG1(printf("getInput(%d, %d) called\n", cursamp, frameCount));
	
	int bufsamps = getBufferSize();
	
	// loop for required number of output samples

	while (i < frameCount) {
		// limit buffer size to end of current pull (chunksamps)
		if (frameCount - i < bufsamps)
			bufsamps = max(0, frameCount - i);

		DBG1(printf("top of main loop: i = %d  cursamp = %d  bufsamps = %d\n",
				   i, cursamp, bufsamps));
		DBG(printf("input signal:\n"));
		DBG(PrintInput(&in[i], bufsamps));
		
		// add signal to delay
		put_tap(cursamp, &in[i], bufsamps);

		// if processing input signal or flushing delay lines ... 

		if (cursamp < totalSamps) {
			// limit buffer size of end of input data
			if (totalSamps - cursamp < bufsamps)
				bufsamps = max(0, totalSamps - cursamp);
			
			if ((tapcount = updatePosition(cursamp)) < 0)
				return PARAM_ERROR;

			DBG1(printf("  inner loop: bufsamps = %d\n", bufsamps));
		
			for (int ch = 0; ch < 2; ch++) {
				for (int path = 0; path < 13; path++) {
					Vector *vec = &m_vectors[ch][path];
					DBG(printf("vector[%d][%d]:\n", ch, path));
					/* get delayed samps */
					get_tap(cursamp, ch, path, bufsamps);
					DBG(PrintSig(vec->Sig, bufsamps));   
					/* air absorpt. filters */
		 				air(vec->Sig, bufsamps, vec->Airdata);			
					/* wall absorpt. filters */
					if (path > 0)	// no filtering of direct signal
		 				wall(vec->Sig, bufsamps, vec->Walldata);
					/* do binaural angle filters if necessary*/
					if (m_binaural)						
						fir(vec->Sig, cursamp, g_Nterms[path], 
							vec->Fircoeffs, vec->Firtaps, bufsamps);
		   				// sum unscaled reflected paths as input for RVB.
					// first path is set; the rest are summed
					if (path == 1)
						copyBuf(&roomsig[ch][0], vec->Sig, bufsamps);			 
					else if (path > 1)
						addBuf(&roomsig[ch][0], vec->Sig, bufsamps);			 
					/* now do cardioid mike effect if not binaural mode */
					if (!m_binaural)
						scale(vec->Sig, bufsamps, vec->MikeAmp);
					DBG(printf("after final scale before rvb:\n"));
					DBG(PrintSig(vec->Sig, bufsamps, 0.1));
		 		}
				/* scale reverb input by amp factor */
				scale(&roomsig[ch][0], bufsamps, m_rvbamp);
			}
			/* run 1st and 2nd generation paths through reverberator */
 			for (int n = 0; n < bufsamps; n++) {
				if (m_rvbamp != 0.0) {
					double rmPair[2];
					double rvbPair[2];
					rmPair[0] = roomsig[0][n];
					rmPair[1] = roomsig[1][n];
					RVB(rmPair, rvbPair, cursamp + n);
					rvbsig[0][n] = rvbPair[0];
					rvbsig[1][n] = rvbPair[1];
				}
				else
					rvbsig[0][n] = rvbsig[1][n] = 0.0;
			}
			DBG(printf("summing vectors\n"));
			if (!m_binaural) {
		   		// re-sum scaled direct and reflected paths as early response
				// first path is set; the rest are summed
				for (int path = 0; path < 13; path++) {
					if (path == 0) {
						copyBuf(&roomsig[0][0], m_vectors[0][path].Sig, bufsamps);
						copyBuf(&roomsig[1][0], m_vectors[1][path].Sig, bufsamps);
					}		   
					else {
						addBuf(&roomsig[0][0], m_vectors[0][path].Sig, bufsamps);
						addBuf(&roomsig[1][0], m_vectors[1][path].Sig, bufsamps);
					}
				}		  
			}
			DBG(printf("left signal:\n"));
			DBG(PrintSig(roomsig[0], bufsamps, 0.1));
			DBG(printf("right signal:\n"));
			DBG(PrintSig(roomsig[1], bufsamps, 0.1));
			/* sum the early response & reverbed sigs  */
			register float *outptr = &this->outbuf[i*2];
			for (int n = 0; n < bufsamps; n++) {
				*outptr++ = roomsig[0][n] + rvbsig[0][n];
				*outptr++ = roomsig[1][n] + rvbsig[1][n];
			}
			DBG(printf("FINAL MIX:\n"));
			DBG(PrintInput(&this->outbuf[i], bufsamps));
		}

		else {		 /* flushing reverb */
			// this is the current location in the main output buffer
			// to write to now
			register float *outptr = &this->outbuf[i*2];
			DBG1(printf("  flushing reverb: i = %d, bufsamps = %d\n", i, bufsamps));
			for (int n = 0; n < bufsamps; n++) {
				if (m_rvbamp > 0.0) {
					double rmPair[2];
					double rvbPair[2];
					rmPair[0] = 0.0;
					rmPair[1] = 0.0;
					RVB(rmPair, rvbPair, cursamp + n);
					*outptr++ = rvbPair[0];
					*outptr++ = rvbPair[1];
				}
				else {
					*outptr++ = 0.0;
					*outptr++ = 0.0;
				}
			}
		}
		cursamp += bufsamps;
		i += bufsamps;
		bufsamps = getBufferSize();		// update
	}
	DBG1(printf("%s::run done\n\n", name()));
	return i;
}
Пример #6
0
 virtual uint64_t toMicros(const uint64_t d) {
     return scale(d, (C6 / C1), (TimeUnit::MAX / (C6 / C1)));
 }
Пример #7
0
 virtual uint64_t toSeconds(const uint64_t d) {
     return scale(d, (C6 / C3), (TimeUnit::MAX / (C6 / C3)));
 }
Пример #8
0
void LifeCounter::Draw(mat4 view, mat4 projection) {
	projection = ortho(0.0f, 20.0f * (scene->width / (float)scene->height), 0.0f, 20.0f, -20.0f, 20.0f);
	for(int i=0; i<lives; i++) {
		Content::shader(basic).Begin();
			mat4 model = translation(position + vec3(i * icon.size.x, 0, 0))  * mat4_cast(orientation) * scale(size);
			model = model;
			glUniformMatrix4fv(Content::shader(basic)("inv_view"), 1, GL_FALSE, &(model[0][0]));
			icon.Draw(model, projection);
		Content::shader(basic).End();
	}
}
Пример #9
0
void ConvexShape::_renderDebug( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *mat )
{   
   GFXDrawUtil *drawer = GFX->getDrawUtil();

   GFX->setTexture( 0, NULL );

   // Render world box.
   if ( false )
   {
      Box3F wbox( mWorldBox );
      //if ( getServerObject() )      
      //   Box3F wbox = static_cast<ConvexShape*>( getServerObject() )->mWorldBox;      
      GFXStateBlockDesc desc;
      desc.setCullMode( GFXCullNone );
      desc.setFillModeWireframe();
      drawer->drawCube( desc, wbox, ColorI::RED );
   }


   const Vector< Point3F > &pointList = mGeometry.points;
	const Vector< ConvexShape::Face > &faceList = mGeometry.faces;

   // Render Edges.
   if ( false )
   {
      GFXTransformSaver saver;
      //GFXFrustumSaver fsaver;

      MatrixF xfm( getRenderTransform() );
      xfm.scale( getScale() );
      GFX->multWorld( xfm );

      GFXStateBlockDesc desc;
      desc.setZReadWrite( true, false );
      desc.setBlend( true );
      GFX->setStateBlockByDesc( desc );

      //MathUtils::getZBiasProjectionMatrix( 0.01f, state->getFrustum(), )

      const Point3F &camFvec = state->getCameraTransform().getForwardVector();



      for ( S32 i = 0; i < faceList.size(); i++ )
      {         
         const ConvexShape::Face &face = faceList[i];
         
         const Vector< ConvexShape::Edge > &edgeList = face.edges;

         const Vector< U32 > &facePntList = face.points;

         PrimBuild::begin( GFXLineList, edgeList.size() * 2 );
         
         PrimBuild::color( ColorI::WHITE * 0.8f );

         for ( S32 j = 0; j < edgeList.size(); j++ )         
         {
            PrimBuild::vertex3fv( pointList[ facePntList[ edgeList[j].p0 ] ] - camFvec * 0.001f );
            PrimBuild::vertex3fv( pointList[ facePntList[ edgeList[j].p1 ] ] - camFvec * 0.001f );
         }
         
         PrimBuild::end();
      }
   }

   ColorI faceColorsx[4] = 
   {
      ColorI( 255, 0, 0 ),
      ColorI( 0, 255, 0 ),
      ColorI( 0, 0, 255 ),
      ColorI( 255, 0, 255 )
   };

   MatrixF objToWorld( mObjToWorld );
   objToWorld.scale( mObjScale );

   // Render faces centers/colors.
   if ( false )
   {
      GFXStateBlockDesc desc;
      desc.setCullMode( GFXCullNone );
      
      Point3F size( 0.1f );

      for ( S32 i = 0; i < faceList.size(); i++ )
      {
         ColorI color = faceColorsx[ i % 4 ];
         S32 div = ( i / 4 ) * 4;
         if ( div > 0 )
            color /= div;
         color.alpha = 255;
         
         Point3F pnt;
         objToWorld.mulP( faceList[i].centroid, &pnt );
         drawer->drawCube( desc, size, pnt, color, NULL );
      }
   }

   // Render winding order.
   if ( false )
   {
      GFXStateBlockDesc desc;
      desc.setCullMode( GFXCullNone );
      desc.setZReadWrite( true, false );
      GFX->setStateBlockByDesc( desc );  

      U32 pointCount = 0;
      for ( S32 i = 0; i < faceList.size(); i++ )      
         pointCount += faceList[i].winding.size();      

      PrimBuild::begin( GFXLineList, pointCount * 2 );
      
      for ( S32 i = 0; i < faceList.size(); i++ )
      {
         for ( S32 j = 0; j < faceList[i].winding.size(); j++ )
         {
            Point3F p0 = pointList[ faceList[i].points[ faceList[i].winding[j] ] ];
            Point3F p1 = p0 + mSurfaces[ faceList[i].id ].getUpVector() * 0.75f * ( Point3F::One / mObjScale );

            objToWorld.mulP( p0 );
            objToWorld.mulP( p1 );

            ColorI color = faceColorsx[ j % 4 ];
            S32 div = ( j / 4 ) * 4;
            if ( div > 0 )
               color /= div;
            color.alpha = 255;
            
            PrimBuild::color( color );
            PrimBuild::vertex3fv( p0 );            
            PrimBuild::color( color );
            PrimBuild::vertex3fv( p1 );                        
         }
      }

      PrimBuild::end();
   }

   // Render Points.
   if ( false )
   {      
      /*
      GFXTransformSaver saver;

      MatrixF xfm( getRenderTransform() );
      xfm.scale( getScale() );
      GFX->multWorld( xfm );

      GFXStateBlockDesc desc;
      Point3F size( 0.05f );
      */
   }

   // Render surface transforms.
   if ( false )
   {
      GFXStateBlockDesc desc;
      desc.setBlend( false );
      desc.setZReadWrite( true, true );

      Point3F scale(mNormalLength);

      for ( S32 i = 0; i < mSurfaces.size(); i++ )
      {
         MatrixF objToWorld( mObjToWorld );
         objToWorld.scale( mObjScale );

         MatrixF renderMat;
         renderMat.mul( objToWorld, mSurfaces[i] );

         renderMat.setPosition( renderMat.getPosition() + renderMat.getUpVector() * 0.001f );
              
         drawer->drawTransform( desc, renderMat, &scale, NULL );
      }
   }
}
Пример #10
0
void NavigationView::zoomIn()
{
	if (transform().m11() * ZOOMFACTOR <= MAXZOOM)	// m11 = horizontal scaling factor
		scale(ZOOMFACTOR, ZOOMFACTOR);				// of the scene.
}
Пример #11
0
void Response::update(const Game* game, const Level* level) {

#ifdef DEBUG
    LOGV(LOG_LEVEL_RESPONSE, (*game->getLog() % 100), LOG_FORMAT(" - g:%x; l:%x (r:%s)"), __PRETTY_FUNCTION__, __LINE__, game,
            level, (mToRender)? "true":"false");
#endif
    if (!mToRender)
        return;

    // Rotation according device position
    if (game->mAccelData) {

#ifdef __ANDROID__
#ifdef DEBUG
        const Input* accelInput = Inputs::getInstance()->get(Inputs::ACCEL);
        assert((*static_cast<const float*>(accelInput->getConfig())) < ((ACCEL_LIMITS_SUP * 2.f) + 1.f));
        assert((*static_cast<const float*>(accelInput->getConfig())) > ((ACCEL_LIMITS_SUP * 2.f) - 1.f));
#endif
        float x = ACCEL_CLIP(game->mAccelData->X);
        float y = ACCEL_CLIP(game->mAccelData->Y);
        float z = ACCEL_CLIP(game->mAccelData->Z);

#else
        // No maximum accelerometer value available on iOS
        // -> Using a common range of [-11;11] values (after having * 10)

        float x = ACCEL_CLIP(-game->mAccelData->X * 10.f);
        float y = ACCEL_CLIP(-game->mAccelData->Y * 10.f);
        float z = ACCEL_CLIP(-game->mAccelData->Z * 10.f);
#endif
        unsigned char orientation = 0;
        if ((ORIENTATION_INF < z) && (z < ORIENTATION_SUP)) {

            if ((ORIENTATION_INF < x) && (x < ORIENTATION_SUP)) orientation = (ORIENTATION_SUP < y)? PORTRAIT:REV_PORTRAIT;
            else if ((ORIENTATION_INF < y) && (y < ORIENTATION_SUP)) orientation = (ORIENTATION_SUP < x)? LANDSCAPE:REV_LANDSCAPE;
        }
        if ((!orientation) && (ORIENTATION_INF < x) && (x < ORIENTATION_SUP) &&
                (ORIENTATION_INF < y) && (y < ORIENTATION_SUP)) orientation = (ORIENTATION_SUP < z)? FLAT:REVERSED;

        unsigned char prevOrientation = mOrientation;
        if (orientation)
            mOrientation = orientation;

        switch (mOrientation) {
            default: {

                mOrientation = PORTRAIT;
                //break;
            }
            case PORTRAIT: { // Portrait (home button at bottom)

                if (prevOrientation == LANDSCAPE) {

                    mRotation -= (2.f * PI_F);
                    mRotateVel -= (2.f * PI_F);
                }
                else if (ACCEL_CHANGED(mCurAccel.X, x))
                    mRotateVel = x * ACCEL_TO_ROTATION;
                break;
            }
            case REV_PORTRAIT: { // Reversed portrait

                if (ACCEL_CHANGED(mCurAccel.X, x))
                    mRotateVel = (x * -ACCEL_TO_ROTATION) + PI_F;
                break;
            }
            case LANDSCAPE: { // Landscape (home button at right)

                if (prevOrientation == PORTRAIT) {

                    mRotation += (2.f * PI_F);
                    mRotateVel += (2.f * PI_F);
                }
                else if (ACCEL_CHANGED(mCurAccel.Y, y))
                    mRotateVel = (y * -ACCEL_TO_ROTATION) + ((3.f * PI_F) / 2.f);
                break;
            }
            case REV_LANDSCAPE: { // Reversed landscape

                if (ACCEL_CHANGED(mCurAccel.Y, y))
                    mRotateVel = (y * ACCEL_TO_ROTATION) + (PI_F / 2.f);
                break;
            }
            case FLAT: // Flat
            case REVERSED: { // Reversed

                if ((!ACCEL_CHANGED(mCurAccel.X, x)) && (!ACCEL_CHANGED(mCurAccel.Y, y)))
                    break;

                static unsigned char prevPos = 0;
                if ((y > 0.f) && (x < 0.f)) {

                    mRotateVel = std::atan(-x / y);
                    prevPos = 0;
                }
                else if ((y < 0.f) && (x < 0.f)) {

                    mRotateVel = std::atan(y / x) + (PI_F / 2.f);
                    prevPos = 0;
                }
                else if ((y < 0.f) && (x > 0.f)) {

                    if (prevPos == 2)
                        mRotation += (2.f * PI_F);
                    mRotateVel = PI_F - std::atan(x / y);
                    prevPos = 1;
                }
                else if ((y > 0.f) && (x > 0.f)) { // 'else if' instead of 'else' coz 'y' must be > 0

                    if (prevPos == 1)
                        mRotation -= (2.f * PI_F);
                    mRotateVel = -std::atan(x / y);
                    prevPos = 2;
                }
                //else // 'x' & 'y' are equal to 0: Nothing to do
                break;
            }
        }
        if (ACCEL_CHANGED(mCurAccel.X, x)) mCurAccel.X = x;
        if (ACCEL_CHANGED(mCurAccel.Y, y)) mCurAccel.Y = y;
        if (ACCEL_CHANGED(mCurAccel.Z, z)) mCurAccel.Z = z;

        mRotation = mRotation - ((mRotation - mRotateVel) / VELOCITY);
        rotate(ROTATION_CORRECTION + mRotation);
    }

    // Hide & Display response
    if (mCancel) {

        if (getAlpha() < ALPHA_VEL_A) {

            mToDisplay = 0;
            mToRender = false;
            mCancel = false;
            mForce = false;
        }
        else
            setAlpha(getAlpha() - (ALPHA_VEL_A * game->getDelta() / DELTA_REF));

        if (mScale < MAX_SCALE) {

            mScale += (SCALE_VELOCITY * game->getDelta() / DELTA_REF);
            scale(mScale, mScale);
        }
        return;
    }

    if (mForce) {

        mScale = MAX_SCALE;
        //setAlpha(MAX_ALPHA); // Let caller manage this
        scale(MAX_SCALE, MAX_SCALE);
        return;
    }
    if (getAlpha() < ((mToDisplay == RESPONSE_ID_STORES)? 1.f:MAX_ALPHA)) {

        setAlpha(getAlpha() + (ALPHA_VEL_A * game->getDelta() / DELTA_REF));
        if (mScale < MAX_SCALE) {

            mScale += (SCALE_VELOCITY * game->getDelta() / DELTA_REF);
            scale(mScale, mScale);
        }
    }
}
Пример #12
0
void NavigationView::zoomOut()
{
	if (scene()->width() * transform().m11() / ZOOMFACTOR >= width() &&
		scene()->height() * transform().m11() / ZOOMFACTOR >= height())
		scale(1.0 / ZOOMFACTOR, 1.0 / ZOOMFACTOR);
}
Пример #13
0
void bb_scan(tld::TldStruct& tld, Eigen::Vector4d const & bb,
		Eigen::Vector2i imsize, int minwin) {
	double shift = 0.1;
	//used for scaling the bb
	Eigen::VectorXd scale(21);
	scale << -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
	for (unsigned int i = 0; i < 21; i++)
		scale(i) = pow(1.2, scale(i));
	int minBB = minwin;

	if (bb_width(bb) < minwin)
		return;

	Eigen::VectorXd bbW(21);
	//scale bb on x axis
	for (unsigned int x = 0; x < 21; x++) {
		bbW(x) = floor((bb_width(bb) * scale(x)) + 0.5);
	}

	Eigen::VectorXd bbH(21);
	//scale bb on y axis
	for (unsigned int x = 0; x < 21; x++) {
		bbH(x) = floor((bb_height(bb) * scale(x)) + 0.5);
	}

	Eigen::VectorXd bbSHH(21);
	Eigen::VectorXd bbSHW(21);
	//shift the scales
	for (unsigned int x = 0; x < 21; x++)
		bbSHH(x) = bbH(x) * shift;

	for (unsigned int x = 0; x < 21; x++) {
		if (bbH(x) <= bbW(x))
			bbSHW(x) = bbH(x) * shift;
		else
			bbSHW(x) = bbW(x) * shift;
	}

	Eigen::VectorXd bbF(4);
	bbF << 2, 2, imsize(0), imsize(1);
	Eigen::Matrix<double, 6, Eigen::Dynamic> bbs;
	Eigen::Matrix<double, 6, Eigen::Dynamic> bbsbak;
	Eigen::Matrix<double, 2, Eigen::Dynamic> sca;
	//create a grid of bounding boxes with different scales
	for (unsigned int i = 0, last_scale = 0; i < 21; i++) {
		if (bbW(i) < minBB || bbH(i) < minBB)
			continue;
		Eigen::VectorXd left;
		Eigen::VectorXd leftbak;
		Eigen::VectorXd top;
		Eigen::VectorXd topbak;
		double val;

		val = bbF(0);
		for (unsigned int p = 0; val <= bbF(2) - bbW(i) - 1; val += bbSHW(i), p++) {
			leftbak.resize(left.size());
			leftbak = left;
			left.resize(p + 1);
			if (p > 0)
				left << leftbak, floor(val + 0.5);
			else
				left(0) = floor(val + 0.5);
		}

		if(left.size() == 0)
			continue;

		val = bbF(1);
		for (unsigned int p = 0; val <= bbF(3) - bbH(i) - 1; val += bbSHH(i), p++) {
			topbak.resize(top.size());
			topbak = top;
			top.resize(p + 1);
			if (p > 0)
				top << topbak, floor(val + 0.5);
			else
				top(0) = floor(val + 0.5);
		}

		if(top.size() == 0)
			continue;

		Eigen::MatrixXd grid(2, top.size() * left.size());

		unsigned int cnt = 0;
		for (int k = 0; k < left.size(); k++)
			for (int w = 0; w < top.size(); w++) {
				grid(0, cnt) = top(w);
				grid(1, cnt) = left(k);
				cnt++;
			}

		Eigen::MatrixXd bbsnew(6, grid.cols());
		bbsnew.row(0) = grid.row(1);
		bbsnew.row(1) = grid.row(0);
		bbsnew.row(2) = grid.array().row(1) + bbW(i) - 1;
		bbsnew.row(3) = grid.array().row(0) + bbH(i) - 1;
		bbsnew.row(4) = Eigen::MatrixXd::Constant(1, grid.cols(), last_scale + 1);
		bbsnew.row(5) = Eigen::MatrixXd::Constant(1, grid.cols(), left.size());
		bbsbak.resize(6, bbs.cols());
		bbsbak = bbs;
		bbs.resize(6, bbs.cols() + bbsnew.cols());
		//lets have some fun!
		if (i > 0)
			bbs << bbsbak, bbsnew;
		else
			bbs = bbsnew;
		//save the scales on x and y axis
		sca.conservativeResize(2, sca.cols() + 1);
		sca(0, sca.cols() - 1) = bbH(i);
		sca(1, sca.cols() - 1) = bbW(i);

		last_scale++;
	}
	tld.grid = bbs;
	tld.nGrid = bbs.cols();
	tld.scales = sca;
}
//Here starts the main program when testing Multiply Matrix_Scalar
void multiplyMatrixScalar()
{

    agile::GPUTimer Timer;

    double timer_value;


    //Initialisation of the Output Text File
    std::fstream myfile;
    const char * file_name = "../test/gpu_matrix_vs_gpu_matrix_pitched/Timer Results";
    myfile.open (file_name, std::fstream::out);

    if (!myfile.is_open())
    {
        std::cerr << "File not found: " << file_name << std::endl;
    }

    // Create a vector first on the CPU and transfer it to the GPU.
    std::vector<TType> result_vector_CUBLAS_host;
    std::vector<TType> result_vector_CUDA_host;
    // Create a dense matrix on the CPU. The elements are stored in row-major order.
    std::vector<TType> matrix_host;


    //GPU Matrix A (CUBLAS)
    agile::GPUMatrix<TType> Matrix_CUBLAS;
    //pitched GPU_Matrix B (CUDA)
    agile::GPUMatrixPitched<TType> Matrix_CUDA;

    //GPU Matrix for Result  (CUBLAS)
    agile::GPUMatrix<TType> ResultMatrix_CUBLAS;
    //pitched GPU_Matrix for Result (CUDA)
    agile::GPUMatrixPitched<TType> ResultMatrix_CUDA;

    //Delete Vector Contents and set size back to 0
    matrix_host.clear();
    result_vector_CUDA_host.clear();
    result_vector_CUDA_host.clear();

    TType alpha = 10.123456789;

    unsigned int num_rows;
    unsigned int num_columns;

    //myfile << "\n\tMultiply Matrix Scalar CUBLAS";
    for(unsigned test_ctr = 1; test_ctr <= 1000; test_ctr++)
    {

        num_rows = test_ctr;
        num_columns = test_ctr;

        //create Matrix
        for (unsigned row = 0; row < num_rows; ++row)
            for (unsigned column = 0; column < num_columns; ++column)
            {
                if((column % 2) == 1)
                {
                    matrix_host.push_back((row % 30 + 1)*(column % 30 + 1));
                }
                else
                {
                    matrix_host.push_back((row % 30 + 1)*(column % 30 + 1)*(-1));
                }


            }

        //Transfer the Matrix data from the Host to the GPUMatrix
        Matrix_CUBLAS.assignFromHost(num_rows, num_columns, &matrix_host[0]);
        Matrix_CUDA.assignFromHost(num_rows, num_columns, &matrix_host[0]);

        ResultMatrix_CUBLAS.assignFromHost(num_rows, num_columns, NULL);
        ResultMatrix_CUDA.assignFromHost(num_rows, num_columns, NULL);

        matrix_host.clear();
        result_vector_CUDA_host.clear();
        result_vector_CUDA_host.clear();

        //Multiply Matrix Scalar CUDA
        //start Timer
        Timer.start();
        for(unsigned i=0; i<2000; i++)
        {
            // Now we can use our matrix. Perform the matrix-scalar product
            // \f$ y \leftarrow Ax \f$.
            scale(alpha, Matrix_CUDA, ResultMatrix_CUDA);
        }
        //stop Timer and write Timer Values to std::cout and file
        timer_value = Timer.stop();
        myfile << std::endl << num_rows << "\t" << num_columns << "\t" << std::setprecision(8)<< timer_value;
        std::cout << std::endl << "NumRows: " << num_rows << "   NumColumns: " << num_columns << "   ------>    CUDA: " << std::setprecision(8)<< timer_value << "[ms]";
        //End Multiply Matrix Vector CUDA

        ResultMatrix_CUDA.copyToHost(result_vector_CUDA_host);
        timer_value = 0;

        //Multiply Matrix Scalar CUBLAS
        //start Timer
        Timer.start();
        for(unsigned i=0; i<2000; i++)
        {
            // Now we can use our matrix. Perform the matrix-scalar product
            // \f$ y \leftarrow Ax \f$.
            scale(alpha, Matrix_CUBLAS, ResultMatrix_CUBLAS);
        }
        //stop Timer and write Timer Values to std::cout and file
        timer_value = Timer.stop();
        myfile  << "\t" << std::setprecision(8)<< timer_value;
        std::cout << "      CUBLAS: " << std::setprecision(8)<< timer_value << "[ms]";
        //End Multiply Matrix Vector CUBLAS

        ResultMatrix_CUBLAS.copyToHost(result_vector_CUBLAS_host);



        //Check if the results are equal
        if(result_vector_CUBLAS_host == result_vector_CUDA_host)
        {
            std::cout << "     TRUE";
            //output(result_vector_CUDA_host, result_vector_CUBLAS_host);
            //myfile  << "\t" << "TRUE";
        }
        else
        {
            std::cout << "     FALSE";
            myfile  << "\t" << "FALSE";
            //output(result_vector_CUDA_host, result_vector_CUBLAS_host);
        }

    }

    Matrix_CUDA.~GPUMatrixPitched();
    Matrix_CUBLAS.~GPUMatrix();
    ResultMatrix_CUDA.~GPUMatrixPitched();
    ResultMatrix_CUBLAS.~GPUMatrix();

    std::cout << std::endl;
    //Delete Vector Contents and set size back to 0
    matrix_host.clear();

    myfile.close();

}
Пример #15
0
void MainWindow::actionScale()
{
	ui.glCanvas->setScale(scale());
	actionResolution();
}
Пример #16
0
void Road::draw(VSShaderLib shader, GLint pvm_uniformId,
	GLint vm_uniformId, GLint normal_uniformId) {

	GameObject::drawTextures();

	//Draw Road
	loadMesh(_meshes.at(0), shader);
	pushMatrix(MODEL);

	//
	translate(MODEL, -2.5f, 0.50f, -2.5f);
	rotate(MODEL, 90, 0, 1, 0);
	scale(MODEL, 1.0f, 0.01f, 5.0f);


	renderMesh(_meshes.at(0), pvm_uniformId, vm_uniformId, normal_uniformId);
	popMatrix(MODEL);

	//bottom
	loadMesh(_meshes.at(0), shader);
	pushMatrix(MODEL);

	translate(MODEL, -2.5f, 0.50f, 3.6f);
	rotate(MODEL, 90, 0, 1, 0);
	scale(MODEL, 1.0f, 0.01f, 5.0f);

	renderMesh(_meshes.at(0), pvm_uniformId, vm_uniformId, normal_uniformId);
	popMatrix(MODEL);

	//left
	loadMesh(_meshes.at(0), shader);
	pushMatrix(MODEL);

	translate(MODEL, -3.5f, 0.5f, -3.5f);
	scale(MODEL, 1.0f, 0.01f, 7.1f);


	renderMesh(_meshes.at(0), pvm_uniformId, vm_uniformId, normal_uniformId);
	popMatrix(MODEL);

	//right
	loadMesh(_meshes.at(0), shader);
	pushMatrix(MODEL);

	translate(MODEL, 2.5f, 0.5f, -3.5f);
	scale(MODEL, 1.0f, 0.01f, 7.1f);


	renderMesh(_meshes.at(0), pvm_uniformId, vm_uniformId, normal_uniformId);
	popMatrix(MODEL);

	//Start Marker
	loadMesh(_meshes.at(1), shader);
	pushMatrix(MODEL);

	translate(MODEL, 0.0f, 0.51f, 2.6f);
	scale(MODEL, 0.1f, 0.01f, 1.0f);

	renderMesh(_meshes.at(1), pvm_uniformId, vm_uniformId, normal_uniformId);
	popMatrix(MODEL);

}
Пример #17
0
 virtual uint64_t toNanos(const uint64_t d) {
     return scale(d, (C6 / C0), (TimeUnit::MAX / (C6 / C0)));
 }
Пример #18
0
vqs vqs::operator*( const float&	pScalar )
{
	vqs result;
	result.Set(translation() * pScalar, orientation() * pScalar, scale() * pScalar);
	return result;
}
Пример #19
0
 virtual uint64_t toMillis(const uint64_t d) {
     return scale(d, (C6 / C2), (TimeUnit::MAX / (C6 / C2)));
 }
bool RenderSVGResourceFilter::applyResource(RenderElement& renderer, const RenderStyle&, GraphicsContext*& context, unsigned short resourceMode)
{
    ASSERT(context);
    ASSERT_UNUSED(resourceMode, resourceMode == ApplyToDefaultMode);

    if (m_filter.contains(&renderer)) {
        FilterData* filterData = m_filter.get(&renderer);
        if (filterData->state == FilterData::PaintingSource || filterData->state == FilterData::Applying)
            filterData->state = FilterData::CycleDetected;
        return false; // Already built, or we're in a cycle, or we're marked for removal. Regardless, just do nothing more now.
    }

    auto filterData = std::make_unique<FilterData>();
    FloatRect targetBoundingBox = renderer.objectBoundingBox();

    filterData->boundaries = SVGLengthContext::resolveRectangle<SVGFilterElement>(&filterElement(), filterElement().filterUnits(), targetBoundingBox);
    if (filterData->boundaries.isEmpty())
        return false;

    // Determine absolute transformation matrix for filter. 
    AffineTransform absoluteTransform = SVGRenderingContext::calculateTransformationToOutermostCoordinateSystem(renderer);
    if (!absoluteTransform.isInvertible())
        return false;

    // Eliminate shear of the absolute transformation matrix, to be able to produce unsheared tile images for feTile.
    filterData->shearFreeAbsoluteTransform = AffineTransform(absoluteTransform.xScale(), 0, 0, absoluteTransform.yScale(), 0, 0);

    // Determine absolute boundaries of the filter and the drawing region.
    FloatRect absoluteFilterBoundaries = filterData->shearFreeAbsoluteTransform.mapRect(filterData->boundaries);
    filterData->drawingRegion = renderer.strokeBoundingBox();
    filterData->drawingRegion.intersect(filterData->boundaries);
    FloatRect absoluteDrawingRegion = filterData->shearFreeAbsoluteTransform.mapRect(filterData->drawingRegion);

    // Create the SVGFilter object.
    bool primitiveBoundingBoxMode = filterElement().primitiveUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX;
    filterData->filter = SVGFilter::create(filterData->shearFreeAbsoluteTransform, absoluteDrawingRegion, targetBoundingBox, filterData->boundaries, primitiveBoundingBoxMode);

    // Create all relevant filter primitives.
    filterData->builder = buildPrimitives(*filterData->filter);
    if (!filterData->builder)
        return false;

    // Calculate the scale factor for the use of filterRes.
    // Also see http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion
    FloatSize scale(1, 1);
    if (filterElement().hasAttribute(SVGNames::filterResAttr)) {
        scale.setWidth(filterElement().filterResX() / absoluteFilterBoundaries.width());
        scale.setHeight(filterElement().filterResY() / absoluteFilterBoundaries.height());
    }

    if (scale.isEmpty())
        return false;

    // Determine scale factor for filter. The size of intermediate ImageBuffers shouldn't be bigger than kMaxFilterSize.
    FloatRect tempSourceRect = absoluteDrawingRegion;
    ImageBuffer::sizeNeedsClamping(tempSourceRect.size(), scale);
    tempSourceRect.scale(scale.width(), scale.height());

    // Set the scale level in SVGFilter.
    filterData->filter->setFilterResolution(scale);

    static const unsigned maxTotalOfEffectInputs = 100;
    FilterEffect* lastEffect = filterData->builder->lastEffect();
    if (!lastEffect || lastEffect->totalNumberOfEffectInputs() > maxTotalOfEffectInputs)
        return false;

    RenderSVGResourceFilterPrimitive::determineFilterPrimitiveSubregion(*lastEffect);
    FloatRect subRegion = lastEffect->maxEffectRect();
    // At least one FilterEffect has a too big image size,
    // recalculate the effect sizes with new scale factors.
    if (ImageBuffer::sizeNeedsClamping(subRegion.size(), scale)) {
        filterData->filter->setFilterResolution(scale);
        RenderSVGResourceFilterPrimitive::determineFilterPrimitiveSubregion(*lastEffect);
    }

    // If the drawingRegion is empty, we have something like <g filter=".."/>.
    // Even if the target objectBoundingBox() is empty, we still have to draw the last effect result image in postApplyResource.
    if (filterData->drawingRegion.isEmpty()) {
        ASSERT(!m_filter.contains(&renderer));
        filterData->savedContext = context;
        m_filter.set(&renderer, WTFMove(filterData));
        return false;
    }

    // Change the coordinate transformation applied to the filtered element to reflect the resolution of the filter.
    AffineTransform effectiveTransform;
    effectiveTransform.scale(scale.width(), scale.height());
    effectiveTransform.multiply(filterData->shearFreeAbsoluteTransform);

    RenderingMode renderingMode = renderer.frame().settings().acceleratedFiltersEnabled() ? Accelerated : Unaccelerated;

    auto sourceGraphic = SVGRenderingContext::createImageBuffer(filterData->drawingRegion, effectiveTransform, ColorSpaceLinearRGB, renderingMode);
    if (!sourceGraphic) {
        ASSERT(!m_filter.contains(&renderer));
        filterData->savedContext = context;
        m_filter.set(&renderer, WTFMove(filterData));
        return false;
    }
    
    // Set the rendering mode from the page's settings.
    filterData->filter->setRenderingMode(renderingMode);

    GraphicsContext& sourceGraphicContext = sourceGraphic->context();
  
    filterData->sourceGraphicBuffer = WTFMove(sourceGraphic);
    filterData->savedContext = context;

    context = &sourceGraphicContext;

    ASSERT(!m_filter.contains(&renderer));
    m_filter.set(&renderer, WTFMove(filterData));

    return true;
}
Пример #21
0
 virtual uint64_t toMinutes(const uint64_t d) {
     return scale(d, (C6 / C4), (TimeUnit::MAX / (C6 / C4)));
 }
Пример #22
0
static rational lass(rational *A, int LastPlane_, int d)
/* A has exact dimension (LastPlane_+1)*(d+1). The function returns
   the volume; an underscore is appended to LastPlane_ and d */

{   rational * redA;            /* A reduced by one dimension and constraint */
    int i, j;
    T_LassInt baserow = 0, basecol = 0, col;
    int dimdiff, row;         /* dimension difference */
    boolean store_volume;
    boolean i_balance = FALSE;
    rational ma, mi, *volume, *realp1, *realp2;
    int Index_needed;         /* Boolean, if index operations are needed */
    T_LassInt * Del_index = NULL; /* contains the indices of the deleted planes */

    /* test if volume is already known and return it if so */

    dimdiff = G_d-d;
    if ((G_Storage > (dimdiff-2)) && (dimdiff >= 2)) {
        tree_out (&tree_volumes, &i_balance, key, &volume, &keyfound, KEY_PLANES_VAR);
        if ((*volume)>=0)  {  /* this volume has already been computed */
	    #ifdef STATISTICS
		Stat_CountRetrieved [d] ++;
	    #endif
	    return (*volume)*scale(dimdiff, 
	                           keyfound->hypervar.variables,
				   key.hypervar.variables);
	}
        (*volume)=0;      /* initialize */
        store_volume=TRUE;
        #ifdef STATISTICS
           Stat_CountStored [d] ++;
        #endif
    }
    else store_volume=FALSE;

    /* if d==1 compute the volume and give it back */

    if (d == 1) {
	ma=-MAXIMUM;
	mi= MAXIMUM;
	for (i=0; i<=LastPlane_; i++,A+=2) { 
	    if (*A>EPSILON_LASS) { if ((*(A+1)/ *A)<mi) mi=(*(A+1)/ *A); }
	    else if (*A<-EPSILON_LASS) { if ((*(A+1)/ *A)>ma) ma=*(A+1)/ *A; } 
            else if ((*(A+1))<-(100000*EPSILON_LASS)) return 0; 
	}
	if ((ma<-.5*MAXIMUM)||(mi>.5*MAXIMUM)) {
	    printf("\nVolume is unbounded!\n");
	    exit(0);
	}
	if ((mi-ma)>EPSILON_LASS) {
	    if (store_volume) (*volume)=mi-ma;
	    return mi-ma;
	}
	return 0;
    }

    /* if d>1 apply the recursive scheme by fixing constraints. */

    Index_needed = (G_Storage>(G_d-d-1));
    if (Index_needed){
	if (!(Del_index = (T_LassInt *) my_malloc ((LastPlane_ + 2) * sizeof (T_LassInt)))){
	    fprintf (stderr, "\n***** ERROR/WARNING: Out of memory in 'lass'\n");
	    exit(0);
	};
        Del_index[0]=G_m+2;   /* initialize: mark end */
    }
    ma=0;                                         /* used to sum up the summands */
    if (norm_and_clean_constraints(A, &LastPlane_, d, Del_index, Index_needed)!=0)
        goto label2;

    /* if appropriate shift polytope */

    if (d>=LaShiftLevel) {
	realp1=A+d;
	realp2=realp1+LastPlane_*(d+1);
	j=0;
	while (realp1<=realp2) {
	    if (fabs(*realp1)<EPSILON_LASS) j++;
	    realp1+=d+1;
	}
	if (d-j>=LaShift) shift_P(A, LastPlane_, d);
    }


    redA = (rational *) my_malloc (LastPlane_* d*sizeof(rational));
    if (redA == NULL) {
	fprintf (stderr, "\n***** ERROR/WARNING: Out of memory in 'lass.*redA'\n");
	exit(0);
    }
#ifdef ReverseLass
    for (row=LastPlane_; row>=0; row--) {
#else
    for (row=0; row<=LastPlane_; row++) {
#endif
	if (fabs(*(A+row*(d+1)+d))<EPSILON_LASS) 
            continue;                        /* skip this constraint if b_row == 0 */
	if (Index_needed)
	{  baserow=add_reduced_index(row, NULL, All_index);
           p2c[G_d-d][1] = baserow;
	   add_hypervar (baserow, G_d+1, &key);
	}	
	memcpy(&pivotrow[0], A+row*(d+1), sizeof(rational)*(d+1));
	col=0;                               /* search for pivot column */
	for (i=0; i<d; i++) {        
#if PIVOTING_LASS == 0
	    if (fabs(pivotrow[i])>=MIN_PIVOT_LASS) {col=i; break;};
#endif
	    if (fabs(pivotrow[i])>fabs(pivotrow[col])) col=i;
	};
	if (G_Storage>(G_d-d-1))
	{  basecol=add_reduced_index(col, NULL, Pivot);
           p2c[G_d-d][0] = basecol;
	   add_hypervar (G_m+1, basecol, &key);
	}

        /* copy A onto redA and at the same time perform pivoting */
	 
	mi=1.0/pivotrow[col];
	for (i=0; i<=d; i++) pivotrow[i]*=mi;
	realp1=A;
	realp2=redA;
	for (i=0; i<=LastPlane_; i++) {
	    if (i==row) {
		realp1+=d+1;
		continue;
	    };
	    mi=*(A+(i*(d+1))+col);
	    for (j=0; j<=d; j++) {
		if (j==col) {
		    realp1++;
		    continue;
		};
		*realp2=(*realp1)-pivotrow[j]*mi;
		realp1++;
		realp2++;
	    };
	};
	ma+= *(A+row*(d+1)+d)/(d*fabs(*(A+row*(d+1)+col)))
	     *lass(redA, LastPlane_-1, d-1);
        if (Index_needed)
        {  rm_original_inElAll_index(baserow);
           delete_hypervar (baserow, G_d+1, &key);
        }
	if (G_Storage>(G_d-d-1))
	{  del_original(basecol, Pivot);
	   delete_hypervar (G_m+1, basecol, &key);
	}
        #ifdef verboseFirstLevel
            if (d==G_d) 
	        printf("\nVolume accumulated to iteration %i is %20.12f",row,ma );
        #endif
    };
    my_free (redA, LastPlane_* d * sizeof (rational));
    label2: 
    if (Index_needed) {
	del_original_indices(Del_index, All_index);
        my_free (Del_index, (LastPlane_ + 2) * sizeof (T_LassInt));
    };
    if (store_volume)(*volume)=ma;
    return ma;
}

/****************************************************************************************/

void volume_lasserre_file (rational *volume, char *planesfile)

{  int i;

   read_hyperplanes (planesfile);
   if (G_m > 254)
   {  fprintf (stderr, "\n***** ERROR: Trying to use 'rlass' with more than 254 hyperplanes.");
      fprintf (stderr, "\nThis restriction can be changed, though. Please contact the authors.\n");
      exit (0);
   }
   if (G_Storage > G_d - 3)
      G_Storage = G_d - 3;
      /* necessary to prevent memory waste because in the tree arrays of length         */
      /* G_Storage + 2 are allocated                                                    */

   pivotrow = (rational *) my_malloc ((G_d + 1) * sizeof (rational));
   All_index = (T_LassInt *) my_malloc ((G_m + 1) * sizeof (T_LassInt));
   Pivot = (T_LassInt *) my_malloc ((G_d + 1) * sizeof (T_LassInt));
   p2c = (int **) my_malloc (G_d * sizeof (int *));
   for (i=0; i<G_d; i++){
       p2c[i] = (int *) my_malloc (2 * sizeof (int));
   }
   A=compact();
   planescopy=compact();
   tree_volumes = NULL;
   create_key (&key, KEY_PLANES_VAR);
   key.hypervar.hyperplanes [0] = G_m + 1;
   key.hypervar.variables [0] = G_d + 1;
   All_index[0]=G_m+2;  /* initialization (end mark) */
   Pivot[0]=G_m+2;	/* initialization (end mark) */
#ifdef STATISTICS
   init_statistics ();
#endif
   *volume = lass (A, G_m-1, G_d);

/*
   free_key (key, KEY_PLANES_VAR);
*/
}
Пример #23
0
    //-----------------------------------------------------------------------
    //                          T M e s h S h a p e
    //-----------------------------------------------------------------------
    TMeshShape::TMeshShape(IMesh* mesh, const matrix4& transform, bool isConvex) : TCollisionShape(),        
        m_baseCount(0),
        m_hullCount(0)
    {
        TApplication* app = getApplication();
        app->logMessage(LOG_INFO, "TMeshShape isConvex: %d", isConvex);

        u32 vcount=0, tcount=0;
        for(u32 i=0; i<mesh->getMeshBufferCount(); i++)
        {
            tcount += mesh->getMeshBuffer(i)->getIndexCount() / 3;
            vcount += mesh->getMeshBuffer(i)->getVertexCount();
        }
        app->logMessage(LOG_INFO, "   org vert count: %d", vcount);
        app->logMessage(LOG_INFO, "   org  tri count: %d", tcount);

        btQuaternion q(TMath::HALF_PI,0.f,0.f);
        m_localTransform = transform;
        m_localScale = transform.getScale();

        m_triMesh = extractTriangles(mesh, true);        
        app->logMessage(LOG_INFO, "   ext  tri count: %d", m_triMesh->getNumTriangles());

        if(isConvex)
        {
            if(1)
            {   // using Bullet's btShapeHull class - faster, typically produces less verts/tris
                btConvexShape* tmpConvexShape = new btConvexTriangleMeshShape(m_triMesh);
                m_shape = tmpConvexShape;
                btShapeHull* hull = new btShapeHull(tmpConvexShape);
                btScalar margin = tmpConvexShape->getMargin();
                hull->buildHull(margin);
                tmpConvexShape->setUserPointer(hull);

                app->logMessage(LOG_INFO, "  hull vert count: %d", hull->numVertices());
                app->logMessage(LOG_INFO, "  hull  tri count: %d", hull->numTriangles());

                //btConvexHullShape* chShape = new btConvexHullShape((const btScalar *)hull->getVertexPointer(),hull->numVertices());
                btConvexHullShape* chShape = new btConvexHullShape();
                
                const btVector3* vp = hull->getVertexPointer();
                const unsigned int* ip = hull->getIndexPointer();
                for (int i=0;i<hull->numTriangles();i++)
                {
                    chShape->addPoint(vp[ip[i*3]]);     
                    chShape->addPoint(vp[ip[i*3+1]]);     
                    chShape->addPoint(vp[ip[i*3+2]]);     
                }
                
                m_shape = chShape;
                delete hull;
                delete tmpConvexShape;
            }
            else
            {   // using Bullet's hull library directly
                HullResult  result;
                HullLibrary hl;
                HullDesc    desc;

                desc.mMaxFaces = 256;
                desc.mMaxVertices = 256;
                desc.SetHullFlag(QF_TRIANGLES);
                PHY_ScalarType type, indicestype;
                const unsigned char* indexbase;
                int istride,numfaces;

                m_triMesh->getLockedReadOnlyVertexIndexBase((const unsigned char**)&desc.mVertices, (int&)desc.mVcount, type, 
                    (int&)desc.mVertexStride, &indexbase, istride, numfaces, indicestype);

                HullError ret = hl.CreateConvexHull(desc,result);
                if(ret == QE_OK)
                {
                    app->logMessage(LOG_INFO, "  hull vert count: %d", result.mNumOutputVertices);
                    app->logMessage(LOG_INFO, "  hull  tri count: %d", result.mNumFaces);
                    btConvexHullShape* chShape = new btConvexHullShape();

                    for (unsigned int i=0;i<result.mNumFaces;i++)
                    {             
                        chShape->addPoint(result.m_OutputVertices[result.m_Indices[i*3]]);
                        chShape->addPoint(result.m_OutputVertices[result.m_Indices[i*3+1]]);
                        chShape->addPoint(result.m_OutputVertices[result.m_Indices[i*3+2]]);
                    }

                    m_shape = chShape;
                }
                else
                {
                    m_shape = new btBvhTriangleMeshShape(m_triMesh,true,true);                
                }
                hl.ReleaseResult(result);
            }
        }
        else 
        {
            //m_shape = _decomposeTriMesh();
            m_shape = new btBvhTriangleMeshShape(m_triMesh,true,true);
        }
        btVector3 scale(m_localScale.X, m_localScale.Y, m_localScale.Z);
        m_shape->setLocalScaling(scale);
    }
Пример #24
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
	ui.setupUi(this);

	connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(close()));
    //connect(ui.actionExport_Accessed_Files, SIGNAL(triggered()), this, SLOT(exportAccessedFiles()));

	connect(ui.actionRun, SIGNAL(triggered()), this, SLOT(sendRun()));

	connect(ui.actionRotate_Left, SIGNAL(triggered()), this, SLOT(rotateLeft()));
	connect(ui.actionRotate_Right, SIGNAL(triggered()), this, SLOT(rotateRight()));
	connect(ui.actionPortrait, SIGNAL(triggered()), this, SLOT(portrait()));
	connect(ui.actionPortrait_Upside_Down, SIGNAL(triggered()), this, SLOT(portraitUpsideDown()));
	connect(ui.actionLandscape_Left, SIGNAL(triggered()), this, SLOT(landscapeLeft()));
	connect(ui.actionLandscape_Right, SIGNAL(triggered()), this, SLOT(landscapeRight()));

	connect(ui.action15_fps, SIGNAL(triggered()), this, SLOT(action15_fps()));
	connect(ui.action30_fps, SIGNAL(triggered()), this, SLOT(action30_fps()));
	connect(ui.action60_fps, SIGNAL(triggered()), this, SLOT(action60_fps()));
	connect(ui.actionUnlimited, SIGNAL(triggered()), this, SLOT(actionUnlimited()));

	connect(ui.action320x480, SIGNAL(triggered()), this, SLOT(actionResolution()));
	connect(ui.action768x1024, SIGNAL(triggered()), this, SLOT(actionResolution()));
	connect(ui.action640x960, SIGNAL(triggered()), this, SLOT(actionResolution()));
    connect(ui.action1536x2048, SIGNAL(triggered()), this, SLOT(actionResolution()));
	connect(ui.action320x568, SIGNAL(triggered()), this, SLOT(actionResolution()));
	connect(ui.action640x1136, SIGNAL(triggered()), this, SLOT(actionResolution()));
	connect(ui.action480x800, SIGNAL(triggered()), this, SLOT(actionResolution()));
	connect(ui.action240x320, SIGNAL(triggered()), this, SLOT(actionResolution()));
	connect(ui.action540x960, SIGNAL(triggered()), this, SLOT(actionResolution()));
	connect(ui.action480x854, SIGNAL(triggered()), this, SLOT(actionResolution()));
	connect(ui.action240x400, SIGNAL(triggered()), this, SLOT(actionResolution()));
	connect(ui.action360x640, SIGNAL(triggered()), this, SLOT(actionResolution()));
	connect(ui.action800x1280, SIGNAL(triggered()), this, SLOT(actionResolution()));
	connect(ui.action600x1024, SIGNAL(triggered()), this, SLOT(actionResolution()));
	connect(ui.action600x800, SIGNAL(triggered()), this, SLOT(actionResolution()));
	connect(ui.action768x1366, SIGNAL(triggered()), this, SLOT(actionResolution()));
    connect(ui.action720x1280, SIGNAL(triggered()), this, SLOT(actionResolution()));
    connect(ui.action1080x1920, SIGNAL(triggered()), this, SLOT(actionResolution()));


    connect(ui.actionQuarter, SIGNAL(triggered()), this, SLOT(actionScale()));
	connect(ui.actionHalf, SIGNAL(triggered()), this, SLOT(actionScale()));
	connect(ui.actionOriginal, SIGNAL(triggered()), this, SLOT(actionScale()));

	orientationGroup_ = new QActionGroup(this);
	orientationGroup_->addAction(ui.actionPortrait);
	orientationGroup_->addAction(ui.actionPortrait_Upside_Down);
	orientationGroup_->addAction(ui.actionLandscape_Left);
	orientationGroup_->addAction(ui.actionLandscape_Right);

	resolutionGroup_ = new QActionGroup(this);
	resolutionGroup_->addAction(ui.action320x480);
	resolutionGroup_->addAction(ui.action768x1024);
	resolutionGroup_->addAction(ui.action640x960);
    resolutionGroup_->addAction(ui.action1536x2048);
	resolutionGroup_->addAction(ui.action320x568);
	resolutionGroup_->addAction(ui.action640x1136);
	resolutionGroup_->addAction(ui.action480x800);
	resolutionGroup_->addAction(ui.action240x320);
	resolutionGroup_->addAction(ui.action540x960);
	resolutionGroup_->addAction(ui.action480x854);
	resolutionGroup_->addAction(ui.action240x400);
	resolutionGroup_->addAction(ui.action360x640);
	resolutionGroup_->addAction(ui.action800x1280);
	resolutionGroup_->addAction(ui.action600x1024);
	resolutionGroup_->addAction(ui.action600x800);
	resolutionGroup_->addAction(ui.action768x1366);
    resolutionGroup_->addAction(ui.action720x1280);
    resolutionGroup_->addAction(ui.action1080x1920);

	zoomGroup_ = new QActionGroup(this);
    zoomGroup_->addAction(ui.actionQuarter);
	zoomGroup_->addAction(ui.actionHalf);
	zoomGroup_->addAction(ui.actionOriginal);

	connect(ui.actionAlways_on_Top, SIGNAL(triggered(bool)), this, SLOT(alwaysOnTop(bool)));

	QSettings settings;

	QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint();
	QSize size = settings.value("size", QSize(1, 1)).toSize();
	resize(size);
	move(pos);

	bool alwaysOnTop = settings.value("alwaysOnTop").toBool();
	if (alwaysOnTop)
	{
		setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
		show();
	}

	ui.actionAlways_on_Top->setChecked(alwaysOnTop);

	QTimer::singleShot(0, this, SLOT(afterInitialization()));

	int resolution = settings.value("resolution", 320).toInt();
	switch (resolution)
	{
	case 320:
		ui.action320x480->setChecked(true);
		break;
	case 768:
		ui.action768x1024->setChecked(true);
		break;
	case 640:
		ui.action640x960->setChecked(true);
		break;
    case 1536:
        ui.action1536x2048->setChecked(true);
        break;
    case 320+1:
        ui.action320x568->setChecked(true);
        break;
    case 640+1:
        ui.action640x1136->setChecked(true);
        break;
	case 480:
		ui.action480x800->setChecked(true);
		break;
	case 240:
		ui.action240x320->setChecked(true);
		break;
	case 540:
		ui.action540x960->setChecked(true);
		break;
	case 480+1:
		ui.action480x854->setChecked(true);
		break;
	case 240+1:
		ui.action240x400->setChecked(true);
		break;
	case 360:
		ui.action360x640->setChecked(true);
		break;
	case 800:
		ui.action800x1280->setChecked(true);
		break;
	case 600:
		ui.action600x1024->setChecked(true);
		break;
	case 600+1:
		ui.action600x800->setChecked(true);
		break;
	case 768+1:
		ui.action768x1366->setChecked(true);
		break;
    case 720:
        ui.action720x1280->setChecked(true);
        break;
    case 1080:
        ui.action1080x1920->setChecked(true);
        break;
    }

    switch (settings.value("scale", 1).toInt())
    {
    case 1:
        ui.actionOriginal->setChecked(true);
        break;
    case 2:
        ui.actionHalf->setChecked(true);
        break;
    case 4:
        ui.actionQuarter->setChecked(true);
        break;
    }

	ui.glCanvas->setScale(scale());
	ui.glCanvas->setFixedSize(hardwareWidth()/scale(), hardwareHeight()/scale());
	ui.glCanvas->setResolution(hardwareWidth(), hardwareHeight());

	Orientation orientation = static_cast<Orientation>(settings.value("orientation", ePortrait).toInt());
	switch (orientation)
	{
	case ePortrait:
		portrait();
		ui.actionPortrait->setChecked(true);
		break;
	case eLandscapeLeft:
		landscapeLeft();
		ui.actionLandscape_Left->setChecked(true);
		break;
	case ePortraitUpsideDown:
		portraitUpsideDown();
		ui.actionPortrait_Upside_Down->setChecked(true);
		break;
	case eLandscapeRight:
		landscapeRight();
		ui.actionLandscape_Right->setChecked(true);
		break;
	}

	int fps = settings.value("fps2", 60).toInt();
	if (fps == 15)
		action15_fps();
	else if (fps == 30)
		action30_fps();
	else if (fps == 60)
		action60_fps();
	else
		actionUnlimited();

	connect(ui.glCanvas, SIGNAL(projectNameChanged(const QString&)), this, SLOT(projectNameChanged(const QString&)));
}
Пример #25
0
 inline Vector4 operator - () const
 {
     return scale(-1);
 }
Пример #26
0
void MainWindow::portraitUpsideDown()
{
	ui.glCanvas->setFixedSize(hardwareWidth()/scale(), hardwareHeight()/scale());
	ui.glCanvas->setHardwareOrientation(ePortraitUpsideDown);
}
Пример #27
0
OFX::Host::ImageEffect::Image* clip_t::get_input_image( OfxTime time, OfxRectD *optionalBounds)
{
    assert( node());
    assert( node()->composition());

    node_t *in = node()->input( port());

    if( !in)
	return 0;

    render::render_context_t context = node()->render_context();

    context.composition = node()->composition();
    context.result_node = in;
    context.time = time;

    Imath::Box2i area;

    if( optionalBounds)
    {
        // TODO: is this correct if the effect does not support tiles?
	area = Imath::Box2i( Imath::V2i( optionalBounds->x1, optionalBounds->y1), Imath::V2i( optionalBounds->x2 - 1, optionalBounds->y2 - 1));
	area = node()->vertical_flip_box( area);
    }
    else
        area = scale( node()->defined(), context.subsample);

    render::renderer_t r( context, true, false);
    r.render( area);

    if( optionalBounds)
    {
	area.min.x = optionalBounds->x1;
	area.min.y = optionalBounds->y1;
	area.max.x = optionalBounds->x2 - 1;
	area.max.y = optionalBounds->y2 - 1;
	area = node()->vertical_flip_box( area);
	area = intersect( in->defined(), area);
    }
    else
	area = in->defined();

    if( area.isEmpty())
	return 0;

    image::image_buffer_t pixels = in->image();
    image::const_image_view_t view( in->const_subimage_view( area));

    int rowbytes;
    void *ptr = view_get_ptr_and_stride( view, rowbytes);

    area = node()->vertical_flip_box( area);

    OfxRectI bounds;
    bounds.x1 = area.min.x;
    bounds.y1 = area.min.y;
    bounds.x2 = area.max.x + 1;
    bounds.y2 = area.max.y + 1;

    std::stringstream s;
    for( int i = 0; i < 16; ++i)
	s << (int) in->digest()[i];

    input_image_t *result = new input_image_t( *this, pixels, 1.0 / node()->render_context().subsample, ptr, bounds, bounds, rowbytes, s.str());
    in->release_image();
    return result;
}
Пример #28
0
void MainWindow::landscapeRight()
{
	ui.glCanvas->setFixedSize(hardwareHeight()/scale(), hardwareWidth()/scale());
	ui.glCanvas->setHardwareOrientation(eLandscapeRight);
}
Пример #29
0
static void create_background_realline(const struct Tracker_Windows *window, const struct WBlocks *wblock, const struct WSignatures *wsignature, int realline){

  const struct WTracks *last_wtrack = (const struct WTracks*)ListLast1(&wblock->wtracks->l);
  const struct LocalZooms *localzoom = wblock->reallines[realline];
  
  //int x1 = wblock->linenumarea.x;
  int x1 = wblock->tempocolorarea.x;
  int x2 = last_wtrack->x2;
  int y1 = get_realline_y1(window, realline);
  int y2 = get_realline_y2(window, realline);

  // background
  {
    if(beat_opacity == -1)
      beat_opacity = SETTINGS_read_int("beat_opacity", 950);

    if(first_beat_opacity == -1)
      first_beat_opacity = SETTINGS_read_int("first_beat_opacity", 870);
    
    GE_Context *c;
 
    if (WSIGNATURE_is_first_beat(wsignature))
      c = GE_mix_color_z(GE_get_rgb(15), GE_get_rgb(1), first_beat_opacity, Z_BACKGROUND | Z_STATIC_X);
    else if (wsignature->beat_num>0)
      c = GE_mix_color_z(GE_get_rgb(15), GE_get_rgb(1), beat_opacity, Z_BACKGROUND | Z_STATIC_X);
    else {
      if(localzoom->level>0 && localzoom->zoomline>0 && localzoom->autogenerated==false)
        c = GE_mix_color_z(GE_get_rgb(15), GE_get_rgb(2), 925, Z_BACKGROUND | Z_STATIC_X); // manually splitted line
      else
        c = GE_color_z(15, Z_BACKGROUND | Z_STATIC_X);
    }
    GE_filledBox(c,x1,y1,x2,y2);
  }

  float line_width = 0.6f;

  // realline separator line
  if(1){
    //if(line_opacity == -1)
    //  line_opacity = SETTINGS_read_int("line_opacity", R_MAX(50, beat_opacity-500));
    line_opacity = 900;
    
    if(line_opacity != 1000) {
      GE_Context *c;

      if (WSIGNATURE_is_first_beat(wsignature))
        c = GE_mix_color_z(GE_get_rgb(15), GE_get_rgb(1), first_beat_opacity-250, Z_ABOVE(Z_BACKGROUND) | Z_STATIC_X);
      else if (wsignature->beat_num>0)
        c = GE_mix_color_z(GE_get_rgb(15), GE_get_rgb(1), beat_opacity-250, Z_ABOVE(Z_BACKGROUND) | Z_STATIC_X);
      else
        c = GE_mix_color_z(GE_get_rgb(15), GE_get_rgb(1), line_opacity, Z_ABOVE(Z_BACKGROUND) | Z_STATIC_X);

      if (true) {
        GE_line(c,x1,y1,x2,y1,line_width);

        VECTOR_FOR_EACH(float*, f_pointer, &wsignature->how_much_below){
          float f = *f_pointer;
          if (fabs(f) > 0.1) {
            float y_ = scale(f, 0, 1, y1, y2);
            float x1_ = wblock->linenumarea.x;
            float x2_ = wblock->linenumarea.x2;
            GE_line(c,x1_,y_,x2_,y_,line_width);
          }
        }END_VECTOR_FOR_EACH;

      } else {
Пример #30
0
void ScrollZoomWidget::paintEvent(QPaintEvent * /*paintEvent*/, QPainter & painter)
{
	//draw scroll bar
	UpdateScrollBarPosition();

	//draw slider
	UpdateSliderPosition();

	painter.setPen(Qt::black);
	
	//draw increase box
	{
		painter.setPen(Qt::black);
		QRect increaseRect = GetIncreaseRect();
		painter.drawRect(increaseRect);
		int increaseRectX1;
		int increaseRectY1;
		int increaseRectX2;
		int increaseRectY2;
		increaseRect.getRect(&increaseRectX1, &increaseRectY1, &increaseRectX2, &increaseRectY2);
		int vertLineX1 = increaseRectX1 + increaseRect.width()/2;
		int vertLineY1 = increaseRectY1;
		int vertLineX2 = vertLineX1;
		int vertLineY2 = increaseRectY1+ increaseRectY2;
		painter.drawLine(vertLineX1, vertLineY1, vertLineX2, vertLineY2);
		int horLineX1 = increaseRectX1 ;
		int horLineY1 = increaseRectY1 + increaseRect.height()/2;
		int horLineX2 = increaseRectX1 + increaseRectX2;
		int horLineY2 = horLineY1;
		painter.drawLine(horLineX1, horLineY1, horLineX2, horLineY2);
	}

	//draw scale value
	{
		char scaleChar[10];
		sprintf(scaleChar, "%.0f", scale * 100);
		QString scale(scaleChar);
		painter.setPen(Qt::black);
		QRect scaleRect(GetScaleRect());
		scaleRect.setWidth(SCALE_WIDTH);
		painter.drawText(scaleRect.bottomLeft(), scale);
	}

	//draw decrease box
	{
		painter.setPen(Qt::black);
		QRect decreaseRect = GetDecreaseRect();
		painter.drawRect(decreaseRect);
		int decreaseRectX1;
		int decreaseRectY1;
		int decreaseRectX2;
		int decreaseRectY2;
		decreaseRect.getRect(&decreaseRectX1, &decreaseRectY1, &decreaseRectX2, &decreaseRectY2);
		int horLineX1 = decreaseRectX1 ;
		int horLineY1 = decreaseRectY1 + decreaseRect.height()/2;
		int horLineX2 = decreaseRectX1 + decreaseRectX2;
		int horLineY2 = horLineY1;
		painter.drawLine(horLineX1, horLineY1, horLineX2, horLineY2);
	}
	
}