Exemplo n.º 1
0
void AP_FormatFrame_preview::draw(void)
{
	GR_Painter painter(m_gc);
	
	UT_sint32 iWidth = m_gc->tlu (getWindowWidth());
	UT_sint32 iHeight = m_gc->tlu (getWindowHeight());
	UT_Rect pageRect(m_gc->tlu(7), m_gc->tlu(7), iWidth - m_gc->tlu(14), iHeight - m_gc->tlu(14));	
	
	painter.fillRect(GR_Graphics::CLR3D_Background, 0, 0, iWidth, iHeight);
	painter.clearArea(pageRect.left, pageRect.top, pageRect.width, pageRect.height);	
	
	
	UT_RGBColor tmpCol;
	
	UT_RGBColor black(0, 0, 0);
	m_gc->setLineWidth(m_gc->tlu(1));
	
	int border = m_gc->tlu(20);
	int cornerLength = m_gc->tlu(5);

//
//  Draw the cell background
//
	
	const gchar * pszBGCol = NULL;
	if(m_pFormatFrame->getImage())
	{
		GR_Image * pImg = m_pFormatFrame->getImage();
		FG_Graphic * pFG = m_pFormatFrame->getGraphic();
		const char * szName = pFG->getDataId();
        const UT_ByteBuf * pBB = static_cast<FG_GraphicRaster *>(pFG)->getBuffer();
		if(pFG->getType() == FGT_Raster)
		{
			pImg = static_cast<GR_Image *>(
				m_gc->createNewImage( szName,
									pBB, pFG->getMimeType(),
									pageRect.width - 2*border,
									pageRect.height - 2*border,
									GR_Image::GRT_Raster));
		}
		else
		{
			pImg = static_cast<GR_Image *>(
				m_gc->createNewImage( szName,
                                      pBB, pFG->getMimeType(),
									pageRect.width - 2*border,
									pageRect.height - 2*border,
									GR_Image::GRT_Vector));
		}

		UT_Rect rec(pageRect.left + border, pageRect.top + border, 
					pageRect.width - 2*border, pageRect.height - 2*border);
		painter.drawImage(pImg,pageRect.left + border, pageRect.top + border);
		delete pImg;
	}
	else
	{
		m_pFormatFrame->getPropVector().getProp(static_cast<const gchar *>("background-color"), pszBGCol);
		if (pszBGCol && *pszBGCol)
		{
			UT_parseColor(pszBGCol, tmpCol);
			painter.fillRect(tmpCol, pageRect.left + border, pageRect.top + border, pageRect.width - 2*border, pageRect.height - 2*border);
		}
	}

//
//  Draw the cell corners
//
	
	m_gc->setColor(UT_RGBColor(127,127,127));
	
	// top left corner
	painter.drawLine(pageRect.left + border - cornerLength, pageRect.top + border,
				   pageRect.left + border, pageRect.top + border);
	painter.drawLine(pageRect.left + border, pageRect.top + border  - cornerLength,
				   pageRect.left + border, pageRect.top + border);

	// top right corner
	painter.drawLine(pageRect.left + pageRect.width - border + cornerLength, pageRect.top + border,
				   pageRect.left + pageRect.width - border, pageRect.top + border);
	painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + border - cornerLength,
				   pageRect.left + pageRect.width - border, pageRect.top + border);

	// bottom left corner
	painter.drawLine(pageRect.left + border - cornerLength, pageRect.top + pageRect.height - border,
				   pageRect.left + border, pageRect.top + pageRect.height - border);
	painter.drawLine(pageRect.left + border, pageRect.top + pageRect.height - border + cornerLength,
				   pageRect.left + border, pageRect.top + pageRect.height - border);

	// bottom right corner
	painter.drawLine(pageRect.left + pageRect.width - border + cornerLength, pageRect.top + pageRect.height - border,
				   pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border);
	painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border + cornerLength,
				   pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border);

//
//  Draw the cell borders
//
	// right border
	if (m_pFormatFrame->getRightToggled())
	{
		UT_sint32 linestyle = m_pFormatFrame->borderLineStyleRight();
		if (linestyle == LS_DOTTED)
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_DOTTED);
		else if (linestyle == LS_DASHED)
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_ON_OFF_DASH);
		else
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_SOLID);

		m_gc->setColor(m_pFormatFrame->borderColorRight());

		UT_sint32 iRightThickness = UT_convertToLogicalUnits(m_pFormatFrame->getBorderThicknessRight().utf8_str());
		m_gc->setLineWidth(iRightThickness);

		painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + border,
						 pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border);
	}

	// left border
	if (m_pFormatFrame->getLeftToggled())
	{
		UT_sint32 linestyle = m_pFormatFrame->borderLineStyleLeft();
		if (linestyle == LS_DOTTED)
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_DOTTED);
		else if (linestyle == LS_DASHED)
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_ON_OFF_DASH);
		else
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_SOLID);

		m_gc->setColor(m_pFormatFrame->borderColorLeft());

		UT_sint32 iLeftThickness = UT_convertToLogicalUnits(m_pFormatFrame->getBorderThicknessLeft().utf8_str());
		m_gc->setLineWidth(iLeftThickness);

		painter.drawLine(pageRect.left + border, pageRect.top + border,
						 pageRect.left + border, pageRect.top + pageRect.height - border);
	}

	// top border
	if (m_pFormatFrame->getTopToggled())
	{
		UT_sint32 linestyle = m_pFormatFrame->borderLineStyleTop();
		if (linestyle == LS_DOTTED)
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_DOTTED);
		else if (linestyle == LS_DASHED)
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_ON_OFF_DASH);
		else
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_SOLID);

		m_gc->setColor(m_pFormatFrame->borderColorTop());		
		UT_sint32 iTopThickness = UT_convertToLogicalUnits(m_pFormatFrame->getBorderThicknessTop().utf8_str());
		m_gc->setLineWidth(iTopThickness);

		painter.drawLine(pageRect.left + border, pageRect.top + border,
						 pageRect.left + pageRect.width - border, pageRect.top + border);
	}

	// bottom border
	if (m_pFormatFrame->getBottomToggled())
	{
		UT_sint32 linestyle = m_pFormatFrame->borderLineStyleBottom();
		if (linestyle == LS_DOTTED)
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_DOTTED);
		else if (linestyle == LS_DASHED)
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_ON_OFF_DASH);
		else
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_SOLID);

		m_gc->setColor(m_pFormatFrame->borderColorBottom());

		UT_sint32 iBottomThickness = UT_convertToLogicalUnits(m_pFormatFrame->getBorderThicknessBottom().utf8_str());
		m_gc->setLineWidth(iBottomThickness);

		painter.drawLine(pageRect.left + border, pageRect.top + pageRect.height - border,
						 pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border);
	}
}
	void FluidDrawerBase::draw(float x, float y) {
		if(enabled == false) return;
		
		draw(x, y, getWindowWidth(), getWindowHeight());
	}
Exemplo n.º 3
0
void Simulate_DLA::draw() {
    glDrawPixels(getWindowWidth(), getWindowHeight(), GL_RGB, GL_UNSIGNED_BYTE, data);  
}
Exemplo n.º 4
0
void AP_FormatTable_preview::draw(const UT_Rect *clip)
{
    UT_UNUSED(clip);
    GR_Painter painter(m_gc);

    UT_sint32 iWidth = m_gc->tlu (getWindowWidth());
    UT_sint32 iHeight = m_gc->tlu (getWindowHeight());
    UT_Rect pageRect(m_gc->tlu(7), m_gc->tlu(7), iWidth - m_gc->tlu(14), iHeight - m_gc->tlu(14));

    painter.fillRect(GR_Graphics::CLR3D_Background, 0, 0, iWidth, iHeight);
    painter.clearArea(pageRect.left, pageRect.top, pageRect.width, pageRect.height);


    UT_RGBColor tmpCol;

    UT_RGBColor black(0, 0, 0);
    m_gc->setLineWidth(m_gc->tlu(1));

    int border = m_gc->tlu(20);
    int cornerLength = m_gc->tlu(5);

//
//  Draw the cell background
//

    const gchar * pszBGCol = NULL;
    if(m_pFormatTable->getImage())
    {
        GR_Image * pImg = m_pFormatTable->getImage();
        FG_Graphic * pFG = m_pFormatTable->getGraphic();
        const char * szName = pFG->getDataId();
        const UT_ByteBuf * pBB = pFG->getBuffer();
        if(pFG->getType() == FGT_Raster)
        {
            pImg = static_cast<GR_Image *>(
                       m_gc->createNewImage( szName,
                                             pBB, pFG->getMimeType(),
                                             pageRect.width - 2*border,
                                             pageRect.height - 2*border,
                                             GR_Image::GRT_Raster));
        }
        else
        {
            pImg = static_cast<GR_Image *>(
                       m_gc->createNewImage( szName,
                                             pBB, pFG->getMimeType(),
                                             pageRect.width - 2*border,
                                             pageRect.height - 2*border,
                                             GR_Image::GRT_Vector));
        }

        UT_Rect rec(pageRect.left + border, pageRect.top + border,
                    pageRect.width - 2*border, pageRect.height - 2*border);
        painter.drawImage(pImg,pageRect.left + border, pageRect.top + border);
        delete pImg;
    }
    else
    {
        m_pFormatTable->getPropVector().getProp(static_cast<const gchar *>("background-color"), pszBGCol);
        if (pszBGCol && *pszBGCol)
        {
            UT_parseColor(pszBGCol, tmpCol);
            painter.fillRect(tmpCol, pageRect.left + border, pageRect.top + border, pageRect.width - 2*border, pageRect.height - 2*border);
        }
    }

//
//  Draw the cell corners
//

    m_gc->setColor(UT_RGBColor(127,127,127));

    // top left corner
    painter.drawLine(pageRect.left + border - cornerLength, pageRect.top + border,
                     pageRect.left + border, pageRect.top + border);
    painter.drawLine(pageRect.left + border, pageRect.top + border  - cornerLength,
                     pageRect.left + border, pageRect.top + border);

    // top right corner
    painter.drawLine(pageRect.left + pageRect.width - border + cornerLength, pageRect.top + border,
                     pageRect.left + pageRect.width - border, pageRect.top + border);
    painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + border - cornerLength,
                     pageRect.left + pageRect.width - border, pageRect.top + border);

    // bottom left corner
    painter.drawLine(pageRect.left + border - cornerLength, pageRect.top + pageRect.height - border,
                     pageRect.left + border, pageRect.top + pageRect.height - border);
    painter.drawLine(pageRect.left + border, pageRect.top + pageRect.height - border + cornerLength,
                     pageRect.left + border, pageRect.top + pageRect.height - border);

    // bottom right corner
    painter.drawLine(pageRect.left + pageRect.width - border + cornerLength, pageRect.top + pageRect.height - border,
                     pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border);
    painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border + cornerLength,
                     pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border);

//
//  Draw the cell borders
//

    // top border
    if (m_pFormatTable->getTopToggled())
    {
        const gchar * pszTopColor = NULL;
        m_pFormatTable->getPropVector().getProp("top-color", pszTopColor);
        if (pszTopColor)
        {
            UT_parseColor(pszTopColor, tmpCol);
            m_gc->setColor(tmpCol);
        }
        else
            m_gc->setColor(black);
        const gchar * pszTopThickness = NULL;
        m_pFormatTable->getPropVector().getProp("top-thickness", pszTopThickness);
        if(pszTopThickness)
        {
            UT_sint32 iTopThickness = UT_convertToLogicalUnits(pszTopThickness);
            m_gc->setLineWidth(iTopThickness);
        }
        else
        {
            m_gc->setLineWidth(m_gc->tlu(1));
        }

        painter.drawLine(pageRect.left + border, pageRect.top + border,
                         pageRect.left + pageRect.width - border, pageRect.top + border);
    }

    // left border
    if (m_pFormatTable->getLeftToggled())
    {
        const gchar * pszLeftColor = NULL;
        m_pFormatTable->getPropVector().getProp("left-color", pszLeftColor);
        if (pszLeftColor)
        {
            UT_parseColor(pszLeftColor, tmpCol);
            m_gc->setColor(tmpCol);
        }
        else
            m_gc->setColor(black);
        const gchar * pszLeftThickness = NULL;
        m_pFormatTable->getPropVector().getProp("left-thickness", pszLeftThickness);
        if(pszLeftThickness)
        {
            UT_sint32 iLeftThickness = UT_convertToLogicalUnits(pszLeftThickness);
            m_gc->setLineWidth(iLeftThickness);
        }
        else
        {
            m_gc->setLineWidth(m_gc->tlu(1));
        }
        painter.drawLine(pageRect.left + border, pageRect.top + border,
                         pageRect.left + border, pageRect.top + pageRect.height - border);
    }

    // right border
    if (m_pFormatTable->getRightToggled())
    {
        const gchar * pszRightColor = NULL;
        m_pFormatTable->getPropVector().getProp("right-color", pszRightColor);
        if (pszRightColor)
        {
            UT_parseColor(pszRightColor, tmpCol);
            m_gc->setColor(tmpCol);
        }
        else
            m_gc->setColor(black);
        const gchar * pszRightThickness = NULL;
        m_pFormatTable->getPropVector().getProp("right-thickness", pszRightThickness);
        if(pszRightThickness)
        {
            UT_sint32 iRightThickness = UT_convertToLogicalUnits(pszRightThickness);
            m_gc->setLineWidth(iRightThickness);
        }
        else
        {
            m_gc->setLineWidth(m_gc->tlu(1));
        }
        painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + border,
                         pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border);
    }

    // bottom border
    if (m_pFormatTable->getBottomToggled())
    {
        const gchar * pszBottomColor = NULL;
        m_pFormatTable->getPropVector().getProp("bot-color", pszBottomColor);
        if (pszBottomColor)
        {
            UT_parseColor(pszBottomColor, tmpCol);
            m_gc->setColor(tmpCol);
        }
        else
            m_gc->setColor(black);
        const gchar * pszBotThickness = NULL;
        m_pFormatTable->getPropVector().getProp("bot-thickness", pszBotThickness);
        if(pszBotThickness)
        {
            UT_sint32 iBotThickness = UT_convertToLogicalUnits(pszBotThickness);
            m_gc->setLineWidth(iBotThickness);
        }
        else
        {
            m_gc->setLineWidth(m_gc->tlu(1));
        }
        painter.drawLine(pageRect.left + border, pageRect.top + pageRect.height - border,
                         pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border);
    }
}
Exemplo n.º 5
0
void TouchManager::overrideTouchTranslation( ci::Vec2f& inOutPoint){
	inOutPoint.set((inOutPoint.x / getWindowWidth()) * mTouchDimensions.x + mTouchOffset.x, 
		(inOutPoint.y / getWindowHeight()) * mTouchDimensions.y + mTouchOffset.y);
}
Exemplo n.º 6
0
void MainTaskHandler::draw(){

    glViewport (0  , 0 , getWindowWidth(), getWindowHeight());
    gl::setMatricesWindow(getWindowWidth(), getWindowHeight());
    gl::color(1.f,1.f,1.f,1.f);
    //  gui->draw();
    
    
    if( cameraHandler->mTexture ) {
		glPushMatrix();
        
		gl::draw( cameraHandler->mTexture );
        
		glPopMatrix();
	}
   
    gl::pushMatrices();
    gl::setMatrices(camera );
    
    gl::drawCoordinateFrame (300,0,0);
    gl::color(ColorA(1,1,1,0.5));
    gl::drawLine(Vec3f(130,0,0), Vec3f(130,0,1500));
    gl::drawLine(Vec3f(-130,0,0), Vec3f(-130,0,1500));
    
   gl::color(ColorA(1,1,1,0.1));
    for(int i=0;i<floorCaptures.size();i++)
    {
        floorCaptures[i]->draw();
    }
    gl::color(ColorA(1,1,1,1));
    
    
    GLfloat light_position[] = {1000,600 , 800,1 };
	glLightfv( GL_LIGHT0, GL_POSITION, light_position );
    glEnable( GL_LIGHT0 );    gl::pushMatrices();
    
    
    glEnable( GL_LIGHT0 );
    ColorA nodeColor =ColorA(1,0,0,1);
   ColorA ambientColor =ColorA(1,1,1,0.3);
    
    
    glEnable(GL_DEPTH_TEST);
    glEnable( GL_LIGHTING );
    glMaterialfv( GL_FRONT, GL_DIFFUSE,	nodeColor );
    glMaterialfv( GL_FRONT, GL_AMBIENT,	ambientColor );
   
    for(int i=0;i<cubes.size();i++)
    {
        float size =cubes[i]->size;
        gl::pushMatrices();
        gl::translate(cubes[i]->center);
        gl::rotate(Vec3f(0,cubes[i]->angle,0));
       // cout << cubes[i]->angle<<endl ;
        gl::drawCube(Vec3f(0,0,0), Vec3f(size,size,size));
      
        gl::popMatrices();
        
        
        
    }
   
    
    
    glDisable( GL_LIGHTING );
	glDisable( GL_LIGHT0 );
    glDisable (GL_DEPTH_TEST);
    
    
    for(int i=0;i<cubes.size();i++)
    {
        
        gl::pushMatrices();
        gl::translate(cubes[i]->center);
         gl::rotate(Vec3f(0,70,180));
        gl::color(1.0f,1.0f,1.0f);
        font->drawString(toString(cubes[i]->center.x)+"-"+toString(cubes[i]->center.z),Vec2f(0,0));
        gl::popMatrices();
        
        
        
    }
    root->drawTarget();
    
    root->drawCurrent();
    
    position->drawTarget();
    position->drawCurrent();
    gl::popMatrices();
    
  



};
Exemplo n.º 7
0
void MainTaskHandler::setup()
{
    
    count =0;
    heightCount=35;
/*
    [503.910252793615, 0, 319.5;
     0, 503.910252793615, 239.5;
     0, 0, 1]
    
    
disatance:
    [0.02562266583003429; -0.144444291145838; 0; 0; 0.08528916548364274]
    */
    
    Font fontMedium = Font( "NewMedia",15);
    font = gl::TextureFont::create(fontMedium);
    
 
  
    cv::Size imageSize;
    
    imageSize.width = 640;
    imageSize.height =480;
    
    //undistort( view, rview, cameraMatrix, distCoeffs, cameraMatrix );
    /*initUndistortRectifyMap(cameraMatrix, distCoeffs, cv::Mat(),
                            getOptimalNewCameraMatrix(cameraMatrix, distCoeffs, imageSize, 1, imageSize, 0),
                            imageSize, CV_16SC2, map1, map2);
    
    */
    
    
    float windowScale =1000;
    float asp =(float)getWindowWidth()/ getWindowHeight();
    center.set(500, 200, 750);
    camera.setOrtho(windowScale, -windowScale, -windowScale/asp, windowScale/asp, 100, 7000);
    camera.lookAt( Vec3f(2000,1000,1000)+center, center, Vec3f(0,1,0) );

	/*for( auto device = Capture::getDevices().begin(); device != Capture::getDevices().end(); ++device ) {
		console() << "Device: " << (*device)->getName() << " "<< std::endl;
        if((*device)->getName().find("Logitech Camera") !=string::npos)
            
        

        {
            try {
                mCapture = Capture::create( 640, 480,(*device) );
                mCapture->start();
            }
            catch( ... ) {
                console() << "Failed to initialize capture" << std::endl;
            }
            
        }
        
	}*/
    
	

};
Exemplo n.º 8
0
void AP_Lists_preview::draw(void)
{
	UT_return_if_fail(m_pFont);

	GR_Painter painter(m_gc);

	m_gc->setFont(m_pFont);
	
	UT_RGBColor clrGrey = UT_RGBColor(128,128,128);
	UT_RGBColor clrBlack = UT_RGBColor(0,0,0);
	UT_sint32 iWidth = m_gc->tlu(getWindowWidth());
	UT_sint32 iHeight = m_gc->tlu(getWindowHeight());
	UT_UCSChar ucs_label[50];

	UT_sint32 iDescent = m_gc->getFontDescent();
	UT_sint32 iAscent = m_gc->getFontAscent();
	UT_sint32 iFont = iDescent + iAscent;
	m_iLine_height = iFont;
	//
	// clear our screen
	//
	if (m_bFirst == true)
	{
		painter.clearArea(0, 0, iWidth, iHeight);
	}
	m_gc->setColor(clrBlack);
	UT_sint32 yoff = m_gc->tlu(5) ;
	UT_sint32 xoff = m_gc->tlu(5) ;
	UT_sint32 i,ii,yloc,awidth,aheight,maxw;
	UT_sint32 twidth =0;
	UT_sint32 j,xy;
	float z,fwidth;
	// todo 6.5 should be the page width in inches
	float pagew = 2.0;
	aheight = m_gc->tlu(16);
	fwidth = static_cast<float>(m_gc->tdu(iWidth));

	z = (float)((fwidth - 2.0*static_cast<float>(m_gc->tdu(xoff))) /pagew);
  UT_sint32 indent = m_gc->tlu(static_cast<UT_sint32>( z*(m_fAlign+m_fIndent)));

	if(indent < 0)
		indent = 0;
	maxw = 0;
	for(i=0; i<4; i++)
	{
		UT_UCSChar * lv = getLists()->getListLabel(i);
		UT_sint32 len =0;

		if(lv != NULL)
		{
			//
			// This code is here because UT_UCS_copy_char is broken
			//
			len = UT_MIN(UT_UCS4_strlen(lv),51);
			for(j=0; j<=len;j++)
			{
				ucs_label[j] = *lv++;
			}

			ucs_label[len] = 0;

			len = UT_UCS4_strlen(ucs_label);
			yloc = yoff + iAscent + (iHeight - 2*yoff -iFont)*i/4;
			//    painter.drawChars(ucs_label,0,len,xoff+indent,yloc);
			twidth = m_gc->measureString(ucs_label,0,len,NULL);
			if(twidth > maxw)
				maxw = twidth;
		}
	}
	//
	// Work out where to put grey areas to represent text
	//
	UT_sint32 xx,yy;
	if(maxw > 0)
		maxw++;

        // UT_sint32 vspace = (iHeight - 2*yoff -iFont)*i/16;
	z = (float)((fwidth - 2.0*static_cast<float>(m_gc->tdu(xoff))) /(float)pagew);
	UT_sint32 ialign = m_gc->tlu(static_cast<UT_sint32>( z*m_fAlign));

	xx = xoff + ialign;
	xy = xoff + ialign;

	if(xx < (xoff + maxw + indent))
		xy = xoff + maxw + indent + m_gc->tlu(1);
	ii = 0;

	for(i=0; i<4; i++)
	{
		yloc = yoff + iAscent + (iHeight - 2*yoff -iFont)*i/4;
		for(j=0; j< 2; j++)
		{
			yy = yloc + m_gc->tlu(5) + j*m_gc->tlu(21);
			m_iLine_pos[ii++] = yy;
		}
	}
	//
	// Now finally draw the preview
	//

	UT_BidiCharType iDirection = getLists()->getBlock()->getDominantDirection();

	for(i=0; i<8; i++)
	{
		//
		// First clear the line
		//
		painter.clearArea(0, m_iLine_pos[i], iWidth, iHeight);
		if((i & 1) == 0)
		{
			//
			// Draw the text
			//
			UT_UCSChar * lv = getLists()->getListLabel(i/2);
			UT_sint32 len =0;

			if(lv != NULL)
			{
				len = UT_MIN(UT_UCS4_strlen(lv),49);

				if(len > 1 && XAP_App::getApp()->theOSHasBidiSupport() == XAP_App::BIDI_SUPPORT_GUI)
				{
					UT_bidiReorderString(lv, len, iDirection, ucs_label);
				}
				else
				{
					for(j=0; j<=len;j++)
						ucs_label[j] = *lv++;
				}

				ucs_label[len] = 0;
				len = UT_UCS4_strlen(ucs_label);
				yloc = yoff + iAscent + (iHeight - 2*yoff -iFont)*i/8;

				if(iDirection == UT_BIDI_RTL)
					painter.drawChars(ucs_label,0,len,iWidth - xoff - indent - maxw,yloc);
				else
					painter.drawChars(ucs_label,0,len,xoff+indent,yloc);

				yy = m_iLine_pos[i];
				awidth = iWidth - 2*xoff - xy;

				if(iDirection == UT_BIDI_RTL)
					painter.fillRect(clrGrey,xoff,yy,awidth,aheight);
				else
					painter.fillRect(clrGrey,xy,yy,awidth,aheight);
			}
			else
			{
				yy = m_iLine_pos[i];
				awidth = iWidth - 2*xoff - xy;

				if(iDirection == UT_BIDI_RTL)
					painter.fillRect(clrGrey,xoff,yy,awidth,aheight);
				else
					painter.fillRect(clrGrey,xy,yy,awidth,aheight);
			}
		}
		else
		{
			yy = m_iLine_pos[i];
			awidth = iWidth - 2*xoff - xx;

			if(iDirection == UT_BIDI_RTL)
				painter.fillRect(clrGrey,xoff,yy,awidth,aheight);
			else
				painter.fillRect(clrGrey,xy,yy,awidth,aheight);
		}
	}
}
Exemplo n.º 9
0
void ProjectManagerApp::resize()
{
	gui->resize(ivec2(getWindowWidth(), getWindowHeight()));
}
void Genetic_AlgorithmApp::setup()
{
    m_appPath = getArgs()[0];
    m_appPath = m_appPath.parent_path();

    /* App */
    m_renderCurrentImage = false;
    /* === */
    /* Algo Gen */
	m_pixelPerSticky = 15;
	m_numberGapPixel = 0;
    m_isStarted = false;
    m_isPaused = false;
    /* === */

    /* Image Load*/
    m_currentImageLoadedIndex = 0;
    /* === */
    
    /* Camera capture */
    setupCapture();
    m_hasCaptureCamera = false;
    m_realTime = false;
    /* === */

    /* IHM */
    m_ihmParam = cinder::params::InterfaceGl::create("Sticky", cinder::Vec2i(245, 340));
    m_ihmParam->setPosition(cinder::Vec2i(20, 20));
    
    m_camParam = cinder::params::InterfaceGl::create("Camera", cinder::Vec2i(250, 150));
    m_camParam->setPosition(cinder::Vec2i(getWindowWidth() - 300, 20));

    m_ihmShader = cinder::params::InterfaceGl::create("Shader", cinder::Vec2i(150, 50));
    m_ihmShader->setPosition(cinder::Vec2i(getWindowWidth() - 200, 190));

    m_ihmStats = cinder::params::InterfaceGl::create("Stats", cinder::Vec2i(200, 100));
    m_ihmStats->setPosition(cinder::Vec2i(getWindowWidth() - 200, 260));
    m_ihmStats->hide();

    setupIHM();
    /* === */

    /* THREAD */
    m_threadRunning = false;
    m_computeFPS = 0.0;
    m_computeHeightFPS = 0.0;

    m_numberOfPopulation = 100;

    /* Camera */
    m_camera.setup(60.0f, getWindowAspectRatio(), 5.0f, 300000.0f, 500.f);

    /* shader */
    m_neighbors = 1;
    try
    {
        m_shader = gl::GlslProg::create(loadResource(SHADER_VERT), loadResource(SHADER_FRAG));
    }
    catch (gl::GlslProgCompileExc& e)
    {
        console() << e.what() << std::endl;
        quit();
    }
    catch (...)
    {
        console() << "Shader error" << std::endl;
        quit();
    }

    m_isBuilder = false;
    //console() << m_shader->getShaderLog(m_shader->getHandle()) << std::endl;
}
Exemplo n.º 11
0
void OpenGLBookApp::resize()
{
    glViewport(0, 0, getWindowWidth(), getWindowHeight());
}
Exemplo n.º 12
0
void DetectingStage::drawGameplay(){

	//get guage
	Rectf gaugeRect = Rectf(0.0f, 0.0f, getWindowWidth(), getWindowHeight());
	//Texture guageTexture = guageVid_.getTexture();


	/////calculate phub time
	//int phubH = timePhub_ / 3600;
	//int phubM = (timePhub_ / 60) % 60;
	//int phubS = timePhub_ % 60;

	//
	//string phubHS,phubMS, phubSS,phubString;
	//if (phubH < 10) phubHS = "0" + toString(phubH);
	//else phubHS = toString(phubH);

	//if (phubM < 10) phubMS = "0" + toString(phubM);
	//else phubMS = toString(phubM);

	//if (phubS < 10) phubSS = "0" + toString(phubS);
	//else phubSS = toString(phubS);

	//phubString = phubHS + ":" + phubMS + ":" + phubSS;

	/////calculate talk string
	//int talkH = timeTalk_ / 3600;
	//int talkM = (timeTalk_ / 60) % 60;
	//int talkS = timeTalk_ % 60;

	//string talkHS, talkMS, talkSS, talkString;
	//if (talkH < 10) talkHS = "0" + toString(talkH);
	//else talkHS = toString(talkH);

	//if (talkM < 10) talkMS = "0" + toString(talkM);
	//else talkMS = toString(talkM);

	//if (talkS < 10) talkSS = "0" + toString(talkS);
	//else talkSS = toString(talkS);

	//talkString = talkHS + ":" + talkMS + ":" + talkSS;

	////draw red green rect
	//Rectf greenRect = Rectf(0.0f, 0.0f, getWindowWidth(), getWindowHeight()*0.15f);
	//Rectf redRect = Rectf(0.0f, 0.0f, (getWindowWidth()*currentRatio_), getWindowHeight()*0.15f);
	//gl::color(67.f/255.f, 193.f/255.f, 30.f/255.f);
	////drawSolidRect(greenRect);
	//gl::color(255.f/255.f, 54.f/255.f, 54.f/255.f);
	////drawSolidRect(redRect);
	//gl::color(1, 1, 1);
	
	
	//draw sticker
	for (int i = 0; i < persons_.size(); i++){
		if (persons_[i].unDetectFrame <= 180){
			if (!isDebugMode) gl::color(Color(CM_HSV, facesColor_[persons_[i].id], 0.77f, 0.96f));
			else gl::color(1, 1, 1, 0.5);
			//choose correct texture for each person
			Texture stickerTexture;

			if (persons_[i].getLook() == LOOKUP) {
				if (persons_[i].segtion == LEFT) {
					if (persons_[i].gender == MALE) stickerTexture = smileLeftMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = smileLeftFemaleTexture_;
					else stickerTexture = smileLeftTexture_;
				}
				else if (persons_[i].segtion == CENTER) {
					if (persons_[i].gender == MALE) stickerTexture = smileMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = smileFemaleTexture_;
					else stickerTexture = smileTexture_;
				}
				else if (persons_[i].segtion == RIGHT) {
					if (persons_[i].gender == MALE) stickerTexture = smileRightMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = smileRightFemaleTexture_;
					else stickerTexture = smileRightTexture_;
				}
			}
			else if (persons_[i].getLook() == LOOKDOWN) {
				if (persons_[i].segtion == LEFT) {
					if (persons_[i].gender == MALE) stickerTexture = seriousLeftMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = seriousLeftFemaleTexture_;
					else stickerTexture = seriousLeftTexture_;
				}
				else if (persons_[i].segtion == CENTER) {
					if (persons_[i].gender == MALE) stickerTexture = seriousMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = seriousFemaleTexture_;
					else stickerTexture = seriousTexture_;
				}
				else if (persons_[i].segtion == RIGHT) {
					if (persons_[i].gender == MALE) stickerTexture = seriousRightMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = seriousRightFemaleTexture_;
					else stickerTexture = seriousRightTexture_;
				}
			}
			else if (persons_[i].getLook() == TURNLEFT) {
				if (persons_[i].gender == MALE) stickerTexture = turnLeftMaleTexture_;
				else if (persons_[i].gender == FEMALE) stickerTexture = turnLeftFemaleTexture_;
				else stickerTexture = turnLeftTexture_;
			}
			else if (persons_[i].getLook() == TURNRIGHT) {
				if (persons_[i].gender == MALE) stickerTexture = turnRightMaleTexture_;
				else if (persons_[i].gender == FEMALE) stickerTexture = turnRightFemaleTexture_;
				else stickerTexture = turnRightTexture_;
			}

			//adjust position and size
			float frameSize = 120.f / (persons_[i].depth / 1000.f);
			float ratio = frameSize / 60.f;

			Vec2f shift(param_shiftX_, param_shiftY_);
			Vec2f scale(param_scale_ * ratio, param_scale_ * ratio);

			//calibrate position for each segment
			Vec2f calShift(0, 0);
			if (persons_[i].segtion == LEFT) calShift.x = -param_calShift_;
			else if (persons_[i].segtion == RIGHT) calShift.x = param_calShift_;
			else calShift.x = 0;

			Rectf stickerRect = Rectf(persons_[i].center - scale + shift + calShift,
				persons_[i].center + scale + shift + calShift);
			if (stickerTexture){
				glEnable(GL_BLEND);
				glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
				displayArea_.draw(stickerTexture, stickerRect);
				ci::gl::disableAlphaBlending();
				glDisable(GL_BLEND);
			}
		}
	}
	gl::color(1, 1, 1);

	//draw guage
	if (gaugeTexture_){
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		displayArea_.draw(gaugeTexture_, gaugeRect);
		//draw rect
		float gaugeRatio = gaugeValue_ / gaugeMax_;
		Rectf blackRect = Rectf(getWindowWidth()*0.287f, getWindowHeight()*0.1485f, (getWindowWidth()*0.287f) + (getWindowWidth()*0.475f*gaugeRatio), getWindowHeight()*0.171f);
		gl::color(0, 0, 0);
		drawSolidRect(blackRect);
		gl::color(1, 1, 1);

		float hurtRatio = hurtValue_ / hurtMax_;
		float fade = 0;
		float maxStage = 30.0;
		if (bloodStage_ > 100) bloodStage_ = 0;
		if (bloodStage_ < maxStage) fade = bloodStage_ * (100.f / maxStage);
		else {
			int diff = bloodStage_ - maxStage;
			fade = 100 - (diff * (100.f / (100.f - maxStage)));
		}
		bloodStage_++;

		gl::color(1, 1, 1, (fade / 100.f)*hurtRatio);

		int second = getElapsedSeconds();
		int result = second % 2;
		if (bloodTexture_ && status_ == PHUB){
			Rectf bloodRect = Rectf(0, 0, getWindowWidth(), getWindowHeight());
			displayArea_.draw(bloodTexture_, bloodRect);
			timeStamp_ = second;
		}

		glDisable(GL_BLEND);
	}

	gl::color(1, 1, 1);
}
Exemplo n.º 13
0
void MGMap::reInit(int w, int h, int tw, int th)
{
	init(w, h, tw, th, getWindowWidth(), getWindowHeight());
}
Exemplo n.º 14
0
void DOFFilter::createBuffers(int samples) {
  mSceneFBO = gl::Fbo::create(toPixels(getWindowWidth()), toPixels(getWindowHeight()), gl::Fbo::Format().depthTexture().samples(samples));
}
Exemplo n.º 15
0
	bool GenericSkin::init() {
		const char *dir = getenv("MOSYNCDIR");

		if(!dir) return false;

		if(!sSkinImage)
			sSkinImage        = loadPNGImage((std::string(dir)+"/skins/skinImage.png").c_str());
		if(!sSkinImage) return false;
		if(!sSelectedKeypad)
			sSelectedKeypad   = loadPNGImage((std::string(dir)+"/skins/keypadSelected.png").c_str());
		if(!sSelectedKeypad) return false;
		if(!sUnselectedKeypad)
			sUnselectedKeypad = loadPNGImage((std::string(dir)+"/skins/keypadUnselected.png").c_str());
		if(!sUnselectedKeypad) return false;
		if(!sMultiTouchImage)
			sMultiTouchImage = loadPNGImage((std::string(dir)+"/skins/multitouchMarker.png").c_str());
		if(!sMultiTouchImage) return false;

		int w = getWindowWidth();
		int h = getWindowHeight();

		unselectedPhone = createSurface(w, h);
		selectedPhone   = createSurface(w, h);

		generatePhone();

		int keysX=0, keysY=0;

		if(mProfile->mKeyboardType == DeviceProfile::DKT_KEYPAD) {
			keysX = w/2 - sUnselectedKeypad->w/2;
			keysY = h - sUnselectedKeypad->h - 24;
		} else if(mProfile->mKeyboardType == DeviceProfile::DKT_JOYSTICK) {
			keysX = w/2 - sUnselectedKeypad->w/2;
			keysY = h - 74 - 24;
		}

#define OFFSET_X (27-keysX)
#define OFFSET_Y (368-keysY)
		if(mProfile->mKeyboardType == DeviceProfile::DKT_JOYSTICK || mProfile->mKeyboardType == DeviceProfile::DKT_KEYPAD) {

			keyRects.push_back(KeyRect(MAK_UP, 132-OFFSET_X, 369-OFFSET_Y, 20, 20));
			keyRects.push_back(KeyRect(MAK_RIGHT, 159-OFFSET_X, 399-OFFSET_Y, 10, 20));
			keyRects.push_back(KeyRect(MAK_DOWN, 132-OFFSET_X, 426-OFFSET_Y, 12, 10));
			keyRects.push_back(KeyRect(MAK_LEFT, 107-OFFSET_X, 399-OFFSET_Y, 10, 20));

			keyRects.push_back(KeyRect(MAK_SOFTLEFT, 32-OFFSET_X, 378-OFFSET_Y, 80, 23));
			keyRects.push_back(KeyRect(MAK_SOFTRIGHT, 164-OFFSET_X, 378-OFFSET_Y, 80, 23));

			keyRects.push_back(KeyRect(MAK_FIRE, 120-OFFSET_X, 387-OFFSET_Y, 36, 36));
			keyRects.push_back(KeyRect(MAK_CLEAR, 222-OFFSET_X, 500-OFFSET_Y, 26, 60));
		}

		if(mProfile->mKeyboardType == DeviceProfile::DKT_KEYPAD) {
			keyRects.push_back(KeyRect(MAK_1, 54-OFFSET_X, 451-OFFSET_Y, 55, 23));
			keyRects.push_back(KeyRect(MAK_2, 110-OFFSET_X, 451-OFFSET_Y, 55, 23));
			keyRects.push_back(KeyRect(MAK_3, 166-OFFSET_X, 451-OFFSET_Y, 55, 23));
			keyRects.push_back(KeyRect(MAK_4, 54-OFFSET_X, 476-OFFSET_Y, 55, 23));
			keyRects.push_back(KeyRect(MAK_5, 110-OFFSET_X, 476-OFFSET_Y, 55, 23));
			keyRects.push_back(KeyRect(MAK_6, 166-OFFSET_X, 476-OFFSET_Y, 55, 23));
			keyRects.push_back(KeyRect(MAK_7, 54-OFFSET_X, 501-OFFSET_Y, 55, 23));
			keyRects.push_back(KeyRect(MAK_8, 110-OFFSET_X, 501-OFFSET_Y, 55, 23));
			keyRects.push_back(KeyRect(MAK_9, 166-OFFSET_X, 501-OFFSET_Y, 55, 23));
			keyRects.push_back(KeyRect(MAK_STAR, 54-OFFSET_X, 526-OFFSET_Y, 55, 23));
			keyRects.push_back(KeyRect(MAK_0, 110-OFFSET_X, 526-OFFSET_Y, 55, 23));
			keyRects.push_back(KeyRect(MAK_HASH, 166-OFFSET_X, 526-OFFSET_Y, 55, 23));
		}

		screenRect.x = w/2 - mProfile->mScreenWidth/2;
		screenRect.y = 24;
		screenRect.w = mProfile->mScreenWidth;
		screenRect.h = mProfile->mScreenHeight;

		windowRect.x = 0;
		windowRect.y = 0;
		windowRect.w = w;
		windowRect.h = h;

		return true;
	}
Exemplo n.º 16
0
	void GenericSkin::skinPhone(SDL_Surface* surface, SDL_Surface* keypad) const {
		//surface = getWindowSurface();

		SDL_Rect srcRect;
		SDL_Rect dstRect;

		int width  = getWindowWidth();
		int height = getWindowHeight();

		// topleft
		srcRect.x = 0;  srcRect.y = 0;
		srcRect.w = 24; srcRect.h = 24;
		dstRect.x = 0;  dstRect.y = 0;
		dstRect.w = 24; dstRect.h = 24;
		SDL_BlitSurface(sSkinImage, &srcRect, surface, &dstRect);

		// topright
		srcRect.x = 40;  srcRect.y = 0;
		srcRect.w = 24; srcRect.h = 24;
		dstRect.x = width - 24;  dstRect.y = 0;
		dstRect.w = 24; dstRect.h = 24;
		SDL_BlitSurface(sSkinImage, &srcRect, surface, &dstRect);

		// bottomleft
		srcRect.x = 0;  srcRect.y = 40;
		srcRect.w = 24; srcRect.h = 24;
		dstRect.x = 0;  dstRect.y = height-24;
		dstRect.w = 24; dstRect.h = 24;
		SDL_BlitSurface(sSkinImage, &srcRect, surface, &dstRect);

		// bottomright
		srcRect.x = 40;  srcRect.y = 40;
		srcRect.w = 24; srcRect.h = 24;
		dstRect.x = width - 24;  dstRect.y = height - 24;
		dstRect.w = 24; dstRect.h = 24;
		SDL_BlitSurface(sSkinImage, &srcRect, surface, &dstRect);

		// Fill top

		int steps = (width - 48) / 16;
		int remainder = (width - 48) % 16;

		srcRect.x = 24; srcRect.y = 0;
		srcRect.w = 16; srcRect.h = 24;
		dstRect.x = 24; dstRect.y = 0;

		for(int i = 0; i < steps; i++) {
			SDL_BlitSurface(sSkinImage, &srcRect, surface, &dstRect);
			dstRect.x += 16;
		}
		// remainder

		if(remainder != 0) {
			srcRect.w = remainder;
			SDL_BlitSurface(sSkinImage, &srcRect, surface, &dstRect);
		}

		// Fill bottom

		srcRect.x = 24; srcRect.y = 40;
		srcRect.w = 16; srcRect.h = 24;
		dstRect.x = 24; dstRect.y = height - 24;

		for(int i = 0; i < steps; i++) {
			SDL_BlitSurface(sSkinImage, &srcRect, surface, &dstRect);
			dstRect.x += 16;
		}
		// remainder

		if(remainder != 0) {
			srcRect.w = remainder;
			SDL_BlitSurface(sSkinImage, &srcRect, surface, &dstRect);
		}

		// Fill left

		steps = (height - 48) / 16;
		remainder = (height - 48) % 16;

		srcRect.x = 0; srcRect.y = 24;
		srcRect.w = 24; srcRect.h = 16;
		dstRect.x = 0; dstRect.y = 24;

		for(int i = 0; i < steps; i++) {
			SDL_BlitSurface(sSkinImage, &srcRect, surface, &dstRect);
			dstRect.y += 16;
		}
		// remainder

		if(remainder != 0) {
			srcRect.h = remainder;
			SDL_BlitSurface(sSkinImage, &srcRect, surface, &dstRect);
		}

		// Fill right

		srcRect.x = 40; srcRect.y = 24;
		srcRect.w = 24; srcRect.h = 16;
		dstRect.x = width - 24; dstRect.y = 24;

		for(int i = 0; i < steps; i++) {
			SDL_BlitSurface(sSkinImage, &srcRect, surface, &dstRect);
			dstRect.y += 16;
		}
		// remainder

		if(remainder != 0) {
			srcRect.h = remainder;
			SDL_BlitSurface(sSkinImage, &srcRect, surface, &dstRect);
		}

		// fill inside

		srcRect.x = 24; srcRect.y = 24;
		srcRect.w = 16; srcRect.h = 16;
		dstRect.x = 24; dstRect.y = 24;

		int xsteps = (width - 48) / 16;
		int xremainder = (width - 48) % 16;
		int ysteps = (height - 48) / 16;
		int yremainder = (height - 48) % 16;

		LOG("xsteps: %d\n", xsteps);
		LOG("ysteps: %d\n", ysteps);

		for(int i = 0; i < ysteps; i++) {
			for(int j = 0; j < xsteps; j++) {
				SDL_BlitSurface(sSkinImage, &srcRect, surface, &dstRect);
				dstRect.x += 16;
			}
			if(xremainder != 0) {
				srcRect.w = xremainder;
				SDL_BlitSurface(sSkinImage, &srcRect, surface, &dstRect);
			}
			dstRect.y += 16;
			dstRect.x = 24;
			srcRect.w = 16;
		}

		if(yremainder != 0) {
			srcRect.h = yremainder;
			for(int j = 0; j < xsteps; j++) {
				SDL_BlitSurface(sSkinImage, &srcRect, surface, &dstRect);
				dstRect.x += 16;
			}
			if(xremainder != 0) {
				srcRect.w = xremainder;
				SDL_BlitSurface(sSkinImage, &srcRect, surface, &dstRect);
			}
			dstRect.y += 16;
			dstRect.x = 24;
			srcRect.w = 16;
		}

		if(mProfile->mKeyboardType == DeviceProfile::DKT_KEYPAD) {
			SDL_Rect srcRect2, dstRect2;
			srcRect2.x = 0;
			srcRect2.y = 0;
			dstRect2.w = srcRect2.w = sUnselectedKeypad->w;
			dstRect2.h = srcRect2.h = sUnselectedKeypad->h;
			dstRect2.x = width/2 - sUnselectedKeypad->w/2;
			dstRect2.y = height - sUnselectedKeypad->h - 24;
			SDL_BlitSurface(keypad, &srcRect2, surface, &dstRect2);
		}
		else if(mProfile->mKeyboardType == DeviceProfile::DKT_JOYSTICK) {
			SDL_BlitSurface(keypad, &srcRect, surface, &dstRect);
		}

	}