Example #1
0
void ATheHUD::InitWidgets()
{
  if( Init ) return;
  Init = 1;
  LOG( "InitWidgets()" );

  // Initialize the widgets that show the player gold, lumber, stone counts.
  ResourcesPanel::GoldTexture = GoldIconTexture;
  ResourcesPanel::LumberTexture = LumberIconTexture;
  ResourcesPanel::StoneTexture = StoneIconTexture;
  Solid::SolidWhiteTexture = SolidWhiteTexture;
  SlotPanel::SlotPanelTexture = SlotPanelTexture;
  StackPanel::StackPanelTexture = VoronoiBackground;
  AbilitiesPanel::BuildButtonTexture = BuildButtonTexture;
  Image::NoTextureTexture = NoTextureTexture;
  GameCanvas::MouseCursorHand = MouseCursorHand;
  GameCanvas::MouseCursorCrossHairs = MouseCursorCrossHairs;
  ControlsPanel::PauseButtonTexture = PauseButtonTexture;
  ControlsPanel::ResumeButtonTexture = ResumeButtonTexture;
  SidePanel::RightPanelTexture = RightPanelTexture;
  Minimap::MinimapTexture = MinimapTexture;
  CostPanel::CostWidgetBackground = VoronoiBackground;
  Tooltip::TooltipBackgroundTexture = VoronoiBackground;

  FVector2D canvasSize( Canvas->SizeX, Canvas->SizeY );
  ui = new UserInterface( canvasSize );

  // Create the panel for containing items/inventory
  // Map selection screen
  MapSelectionScreen *mss = ui->mapSelectionScreen = 
    new MapSelectionScreen( TitleLogoTexture, SolidWhiteTexture,
      MapSlotEntryBackgroundTexture, PortraitTexture,
      canvasSize, FVector2D( 120, 24 ), largeFont );
  ui->titleScreen = new TitleScreen( TitleScreenTexture, canvasSize );
  ui->Add( mss );
  mss->OKButton->OnMouseDownLeft = [mss](FVector2D mouse) -> EventCode {
    // OK button clicked, so load the map if there is a selected widget
    // else display error message
    if( mss->Selected )
      Game->flycam->LoadLevel( FName( *mss->Selected->GetText() ) );
    else
      Game->hud->ui->statusBar->Set( "Select a map to load first" ) ;
    return NotConsumed;
  };

  /////
  // List the maps in the folder at the left side
  TArray<FAssetData> maps = ScanFolder( "/Game/Maps" );
  for( int i = 0; i < maps.Num(); i++ )
    ui->mapSelectionScreen->AddText( maps[i].AssetName.ToString(), CenterCenter );
  ui->missionObjectivesScreen = new MissionObjectivesScreen(
    MapSlotEntryBackgroundTexture, MapSlotEntryBackgroundTexture, canvasSize,
    FVector2D( 300, 100 ), FVector2D( 8, 8 ) );
  ui->Add( ui->missionObjectivesScreen );

  /// Set the screen's to correct one for the gamestate
  ui->SetScreen( Game->gm->state );
}
void WebViewBenchmarkSupportImpl::paintLayer(PaintClient* paintClient, GraphicsLayer& layer, const IntRect& clip)
{
    WebSize canvasSize(clip.width(), clip.height());
    WebCanvas* canvas = paintClient->willPaint(canvasSize);
    GraphicsContext context(canvas);

    layer.paintGraphicsLayerContents(context, clip);
    paintClient->didPaint(canvas);
}
Example #3
0
glm::vec2 ImageNode::toCanvasPos(const glm::vec2& pos)
{
    OffscreenCanvasPtr pCanvas = m_pGPUImage->getCanvas();
    AVG_ASSERT(pCanvas);
    glm::vec2 containerPos = getRelPos(pos);
    glm::vec2 nodeSize(getSize());
    glm::vec2 canvasSize(pCanvas->getSize());
    return glm::vec2(containerPos.x*(canvasSize.x/nodeSize.x),
            containerPos.y*(canvasSize.y/nodeSize.y));
}
Example #4
0
void ImageNode::getElementsByPos(const glm::vec2& pos, vector<NodePtr>& pElements)
{
    if (reactsToMouseEvents()) {
        OffscreenCanvasPtr pCanvas = m_pGPUImage->getCanvas();
        if (pCanvas && pCanvas->getHandleEvents()) {
            glm::vec2 nodeSize(getSize());
            glm::vec2 canvasSize(pCanvas->getSize());
            glm::vec2 localPos(pos.x*(canvasSize.x/nodeSize.x), 
                    pos.y*(canvasSize.y/nodeSize.y));
            pCanvas->getRootNode()->getElementsByPos(localPos, pElements);
        }
        RasterNode::getElementsByPos(pos, pElements);
    }
}
void WebViewBenchmarkSupportImpl::softwarePaint(PaintClient* paintClient, PaintMode paintMode)
{
    WebSize size = m_webViewImpl->size();
    WebRect paintSize;
    switch (paintMode) {
    case PaintModeEverything:
        if (m_webViewImpl->page() && m_webViewImpl->page()->mainFrame()) {
            FrameView* view = m_webViewImpl->page()->mainFrame()->view();
            IntSize contentsSize = view->contentsSize();
            paintSize = WebRect(0, 0, contentsSize.width(), contentsSize.height());
        } else
            paintSize = WebRect(0, 0, size.width, size.height);
        break;
    }

    WebSize canvasSize(paintSize.width, paintSize.height);
    WebCanvas* canvas = paintClient->willPaint(canvasSize);
    m_webViewImpl->paint(canvas, paintSize);
    paintClient->didPaint(canvas);
}
void FGHSensorPing::onRender(GFXSurface *sfc, Point2I offset, const Box2I& /*updateRect*/)
{
    Point2I canvasSize(sfc->getWidth(), sfc->getHeight());

    //check for lowres
    if (canvasSize.x < 512 || canvasSize.y < 384)
    {
        if (! mbLowRes)
        {
            mbLowRes = TRUE;
            extent.set(20, 15);
            snap();
        }
    }
    else
    {
        if (mbLowRes)
        {
            mbLowRes = FALSE;
            extent.set(32, 23);
            snap();
            return;
        }
    }

    //make sure the HUD can fit on the canvas
    if ((canvasSize.x < extent.x) || (canvasSize.y < extent.y))
        return;

    if (!cg.psc || !cg.player || (cg.player != cg.psc->getControlObject() && !(cg.psc->getControlObject()->getType() & VehicleObjectType)))
        return;

    //draw the base bmp
    sfc->drawBitmap2d((! mbLowRes ? mBmpBase : lrBmpBase), &offset);

    //first, check the status
    GFXBitmap *bmp = NULL;

    //get the ping status
    BYTE pingStatus = cg.psc->getControlObject()->getSensorPinged(); // cg.player->getSensorPinged();

    //set the bitmap
    if (pingStatus == GameBase::PingStatusSupressed)
    {
        bmp = mBmpSupressed;
        startBlinkTime = -1;
    }

    else if (pingStatus == GameBase::PingStatusOn)
    {
        //find out how much time has passed since the light blinked
        SimTime curTime = manager->getCurrentTime();
        if (startBlinkTime <= 0) startBlinkTime = curTime;

        int bmpValue = int((curTime - startBlinkTime) * 10) % 6;
        if (bmpValue == 0)
            bmp = (! mbLowRes ? mBmpPingedLo : lrBmpPingedLo);
        else if (bmpValue == 1)
            bmp = (! mbLowRes ? mBmpPingedMed : lrBmpPingedMed);
        else
            bmp = (! mbLowRes ? mBmpPingedHi : lrBmpPingedHi);

    }
    else
    {
        startBlinkTime = -1;
    }

    //now draw the bmp
    if (bmp)
    {
        sfc->drawBitmap2d(bmp, &Point2I(offset.x + (extent.x - bmp->getWidth()) / 2,
                                        offset.y + (extent.y - bmp->getHeight()) / 2));
    }
}
void CMMADisplay::SourceSizeChanged(const TSize& aSourceSize)
{
    LOG(EJavaMMAPI,EInfo,"CMMADisplay::SourceSizeChanged");

#ifdef RD_JAVA_NGA_ENABLED
    if (iWindow)
    {
        iWindow->SetVideoCropRegion(TRect(iUserRect.iTl, aSourceSize));
    }
#endif

    iSourceSize = aSourceSize;
    LOG1(EJavaMMAPI,EInfo,"MMA::CMMADisplay::SourceSizeChanged %d",
         aSourceSize.iWidth);
    LOG1(EJavaMMAPI,EInfo,"MMA::CMMADisplay::SourceSizeChanged %d",
         aSourceSize.iHeight);
    jmethodID getDisplayWidthID = iJni->GetMethodID(
                                      iJavaDisplayClass,
                                      "getDisplayWidth",
                                      "()I");

    jmethodID getDisplayHeightID = iJni->GetMethodID(
                                       iJavaDisplayClass,
                                       "getDisplayHeight",
                                       "()I");


    TInt x =  iJni->CallIntMethod(iJavaDisplayObject,getDisplayWidthID);
    TInt y = iJni->CallIntMethod(iJavaDisplayObject,getDisplayHeightID);
    LOG2(EJavaMMAPI,EInfo,"CMMADisplay.cpp : SourceSizeChanged () iFullScreenSize is x = %d ,y = %d ",x,y);
    // get the ScreenSize from canvas in java
    TSize canvasSize(x, y);
    iFullScreenSize = canvasSize;
    TBool sourceIsBigger = (aSourceSize.iWidth > iFullScreenSize.iWidth ||
                            aSourceSize.iHeight > iFullScreenSize.iHeight);

    if (sourceIsBigger)
    {
        // Source is larger than display area.
        // Shrink draw are to fit in display.
        iWindow->SetDrawRect(ScaleToFullScreen(iFullScreenSize, iSourceSize));
    }
    else
    {
        // source is smaller than display area
        iWindow->SetDrawRect(TRect(iUserRect.iTl, iSourceSize));
    }

    SetClippingRegion();

    if (iUserRect.IsEmpty())
    {
        // Java side hasn't set size.
        iUserRect = iWindow->DrawRect();

        if (!sourceIsBigger)
        {
            // Addjusting rect to top left corner.
            iUserRect = TRect(iUserRect.Size());
        }
    }
}
Example #8
0
SlideShowWindow::SlideShowWindow(QWidget *parent)
	: QWidget(parent)
	, m_group(0)
	, m_scene(0)
	, m_oldScene(0)
	, m_useGLWidget(true)
	, m_glWidget(0)
	, m_graphicsView(0)
	, m_xfadeSpeed(300)
{
	QVBoxLayout *layout = new QVBoxLayout(this);
	layout->setContentsMargins(0,0,0,0);
	
	bool verbose = true;
	QString configFile = "player.ini";
	
	if(verbose)
		qDebug() << "SlideShowWindow: Reading settings from "<<configFile;
		
	QSettings settings(configFile,QSettings::IniFormat);
	
	QString str;
	QStringList parts;
	QPoint point;
	
	QString activeGroup = settings.value("config").toString();
	
	str = settings.value("verbose").toString();
	if(!str.isEmpty())
		verbose = str == "true";
	
	if(verbose && !activeGroup.isEmpty())
		qDebug() << "SlideShowWindow: Using config:"<<activeGroup;
	
	#define READ_STRING(key,default) \
		(!activeGroup.isEmpty() ? \
			(!(str = settings.value(QString("%1/%2").arg(activeGroup).arg(key)).toString()).isEmpty() ?  str : \
				settings.value(key,default).toString()) : \
			settings.value(key,default).toString())
			
	#define READ_POINT(key,default) \
		str = READ_STRING(key,default); \
		parts = str.split("x"); \
		point = QPoint(parts[0].toInt(),parts[1].toInt()); \
		if(verbose) qDebug() << "SlideShowWindow: " key ": " << point; 
		
	m_useGLWidget = READ_STRING("compat","false") == "false";
	if(m_useGLWidget)
	{
		m_glWidget = new GLWidget(this);
		layout->addWidget(m_glWidget);
		qDebug() << "SlideShowWindow: Using OpenGL to provide high-quality graphics.";
		
		m_glWidget->setCursor(Qt::BlankCursor);
	}
	else
	{
		m_graphicsView = new ScaledGraphicsView();
		m_graphicsScene = new QGraphicsScene();
		m_graphicsView->setScene(m_graphicsScene);
		m_graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
		m_graphicsScene->setSceneRect(QRectF(0,0,1000.,750.));
		m_graphicsView->setBackgroundBrush(Qt::black);
		layout->addWidget(m_graphicsView);
		
		qDebug() << "SlideShowWindow: Using vendor-provided stock graphics engine for compatibility with older hardware.";
		
		m_graphicsView->setCursor(Qt::BlankCursor);
	}
	
	
	// Window position and size
	READ_POINT("window-pos","10x10");
	QPoint windowPos = point;
	
	READ_POINT("window-size","640x480");
	QPoint windowSize = point;
	//windowSize = QPoint(3120,1050);
	
	if(verbose)
		qDebug() << "SlideShowWindow: pos:"<<windowPos<<", size:"<<windowSize;
	
	resize(windowSize.x(),windowSize.y());
	move(windowPos.x(),windowPos.y());
	
	bool frameless = READ_STRING("frameless","true") == "true";
	if(frameless)
		setWindowFlags(Qt::FramelessWindowHint);// | Qt::ToolTip);
	
	if(m_useGLWidget)
	{
		
		// Keystoning / Corner Translations
		READ_POINT("key-tl","0x0");
		m_glWidget->setTopLeftTranslation(point);
		
		READ_POINT("key-tr","0x0");
		m_glWidget->setTopRightTranslation(point);
		
		READ_POINT("key-bl","0x0");
		m_glWidget->setBottomLeftTranslation(point);
		
		READ_POINT("key-br","0x0");
		m_glWidget->setBottomRightTranslation(point);
		
		// Brightness/Contrast, Hue/Sat
		m_glWidget->setBrightness(READ_STRING("brightness","0").toInt());
		m_glWidget->setContrast(READ_STRING("contrast","0").toInt());
		m_glWidget->setHue(READ_STRING("hue","0").toInt());
		m_glWidget->setSaturation(READ_STRING("saturation","0").toInt());
		
		// Flip H/V
		bool fliph = READ_STRING("flip-h","false") == "true";
		if(verbose)
			qDebug() << "SlideShowWindow: flip-h: "<<fliph;
		m_glWidget->setFlipHorizontal(fliph);
		
		bool flipv = READ_STRING("flip-v","false") == "true";
		if(verbose)
			qDebug() << "SlideShowWindow: flip-v: "<<flipv;
		m_glWidget->setFlipVertical(flipv);
		
		// Rotate
		int rv = READ_STRING("rotate","0").toInt();
		if(verbose)
			qDebug() << "SlideShowWindow: rotate: "<<rv;
		
		if(rv != 0)
			m_glWidget->setCornerRotation(rv == -1 ? GLRotateLeft  : 
						      rv ==  1 ? GLRotateRight : 
							         GLRotateNone);
		
		// Aspet Ratio Mode
		m_glWidget->setAspectRatioMode(READ_STRING("ignore-ar","false") == "true" ? Qt::IgnoreAspectRatio : Qt::KeepAspectRatio);
		
		// Alpha Mask
		QString alphaFile = READ_STRING("alphamask","");
		if(!alphaFile.isEmpty())
		{
			QImage alphamask(alphaFile);
			if(alphamask.isNull())
				qDebug() << "SlideShowWindow: Error loading alphamask "<<alphaFile;
			else
				m_glWidget->setAlphaMask(alphamask);
		}
		
// 		GLWidgetSubview *sub1 = m_glWidget->defaultSubview();
// 		sub1->setRight(1680./3120.);
// 		
// 		GLWidgetSubview *sub2 = new GLWidgetSubview();
// 		sub2->setLeft(sub1->right());
// 		sub2->setBrightness(75);
// 		sub2->setFlipVertical(true);
// 		sub2->setFlipHorizontal(true);
// 		
// 		m_glWidget->addSubview(sub2);
	}
	
	// Canvas Size
	READ_POINT("canvas-size","1000x750");
	QSizeF canvasSize((qreal)point.x(),(qreal)point.y());
	//canvasSize = QSizeF(2000,750);
	canvasSize = QSizeF(3120,1050);
	if(m_useGLWidget)
	{
		m_glWidget->setCanvasSize(canvasSize);
	}
	else
	{
		m_graphicsScene->setSceneRect(QRectF(QPointF(0,0),canvasSize));
	}
	
	m_xfadeSpeed = READ_STRING("xfade-speed",300).toInt();
	//qDebug() << "SlideShowWindow: Crossfade speed: "<<m_xfadeSpeed;
	
// 	QString loadGroup = READ_STRING("load-group","");
// 	if(!loadGroup.isEmpty())
// 	{
// 		QFile file(loadGroup);
// 		if (!file.open(QIODevice::ReadOnly)) 
// 		{
// 			qDebug() << "SlideShowWindow: Unable to read group file: "<<loadGroup;
// 		}
// 		else
// 		{
// 			QByteArray array = file.readAll();
// 			
// 			GLSceneGroup *group = new GLSceneGroup();
// 			group->fromByteArray(array);
// 			setGroup(group);
// 			
// 			GLScene *scene = group->at(0);
// 			if(scene)
// 			{
// 				//scene->setGLWidget(this);
// 				setScene(scene);
// 				qDebug() << "SlideShowWindow: [DEBUG]: Loaded File: "<<loadGroup<<", GroupID: "<<group->groupId()<<", SceneID: "<< scene->sceneId();
// 				
// 				if(m_outputEncoder && 
// 				  !m_outputEncoder->encodingStarted())
// 					m_outputEncoder->startEncoder();
// 
// 			}
// 			else
// 			{
// 				qDebug() << "SlideShowWindow: [DEBUG]: Loaded File: "<<loadGroup<<", GroupID: "<<group->groupId()<<" - no scenes found at index 0";
// 			}
// 		}	
// 	}
// 	else
// 	{
// 		QString loadGroup = READ_STRING("collection","");
// 		if(!loadGroup.isEmpty())
// 		{
// 			QFile file(loadGroup);
// 			if (!file.open(QIODevice::ReadOnly)) 
// 			{
// 				qDebug() << "SlideShowWindow: Unable to read group file: "<<loadGroup;
// 			}
// 			else
// 			{
// 				QByteArray array = file.readAll();
// 				
// 				GLSceneGroupCollection *collection = new GLSceneGroupCollection();
// 				collection->fromByteArray(array);
// 				setGroup(collection->at(0));
// 				
// 				if(m_group)
// 				{
// 					GLScene *scene = m_group->at(0);
// 					if(scene)
// 					{
// 						//scene->setGLWidget(this);
// 						setScene(scene);
// 						qDebug() << "SlideShowWindow: [DEBUG]: Loaded File: "<<loadGroup<<", GroupID: "<<m_group->groupId()<<", SceneID: "<< scene->sceneId();
// 						
// 						GLDrawableList list = scene->drawableList();
// 						foreach(GLDrawable *gld, list)
// 							if(gld->playlist()->size() > 0)
// 								gld->playlist()->play();	
// 						
// 						if(m_outputEncoder && 
// 						!m_outputEncoder->encodingStarted())
// 							m_outputEncoder->startEncoder();
// 		
// 					}
// 					else
// 					{
// 						qDebug() << "SlideShowWindow: [DEBUG]: Loaded File: "<<loadGroup<<", GroupID: "<<m_group->groupId()<<" - no scenes found at index 0";
// 					}
// 				}
// 			}	
// 		}
// 	}


	QStringList argList = qApp->arguments();
	if(argList.size() > 1)
	{
		QString dirName = argList.at(1);
		QDir dir(dirName);
		dir.setNameFilters(QStringList() << "*.jpg" << "*.JPG" << "*.jpeg" << "*.png" << "*.PNG");
		QFileInfoList list = dir.entryInfoList(QDir::Files, QDir::Name);
		
		if(m_glWidget)
			m_glWidget->setFboEnabled(false);
		
		int spinSize = 28;
			
			
		//QStringList list = dir.entryList();
		//foreach(QString file, list)
		foreach(QFileInfo info, list)
		{
			//QFileInfo info(QString("%1/%2").arg(dirName,file));
			//if(!info.isFile())
			//	continue;
			//QString ext = info.suffix().toLower();
			//if(ext != "jpg" || ext != "png" || ext != "jpeg")
			//	continue;
			
			bool flipText = true;
			
			QString fullFile = info.absoluteFilePath();
			qDebug() << "SlideShowWindow: Loading "<<fullFile;//<<" (ext:"<<ext<<")";
			GLScene *scene = new GLScene();
			{
				QString comment = "";
				QString datetime = "";
				try
				{
					Exiv2::Image::AutoPtr exiv = Exiv2::ImageFactory::open(fullFile.toStdString()); 
					if(exiv.get() != 0)
					{
						exiv->readMetadata();
						Exiv2::ExifData& exifData = exiv->exifData();
						if (exifData.empty()) 
						{
							qDebug() << fullFile << ": No Exif data found in the file";
						}
		
						comment = exifData["Exif.Image.ImageDescription"].toString().c_str();
						comment = GLTextDrawable::htmlToPlainText(comment);
						
						datetime = exifData["Exif.Photo.DateTimeOriginal"].toString().c_str();
			
						if(comment.trimmed().isEmpty())
						{
							Exiv2::IptcData& iptcData = exiv->iptcData();
							comment = iptcData["Iptc.Application2.Caption"].toString().c_str();
							comment = GLTextDrawable::htmlToPlainText(comment);
							
							if (exifData.empty()) 
							{
								qDebug() << fullFile << ": No IPTC data found in the file";
							}
							else
							{
								qDebug() << "SlideShowWindow: IPTC Caption:"<<comment;
							}
						}
						else
						{
							qDebug() << "SlideShowWindow: EXIF Caption:"<<comment;
						}
						
						
					}
				}
				catch (Exiv2::AnyError& e) 
				{
					std::cout << "Caught Exiv2 exception '" << e << "'\n";
					//return -1;
				}
				
				GLImageDrawable *image = new GLImageDrawable(fullFile);
				
				if(canvasSize.width() > 1000)
				{
					image->setRect(QRectF(QPointF(0,0),QSize(1680,canvasSize.height())));
				}
				else
				{
					image->setRect(QRectF(QPointF(0,0),canvasSize));
				}
				//image->setCrossFadeMode(GLVideoDrawable::JustFront);
				scene->addDrawable(image);
				
				if(!comment.isEmpty())
				{
					comment = comment.replace(QRegExp("^\\s*\"([^\"]+)\"\\s*-\\s*"), "<center>\"\\1\"</center><br>");
					 
					GLTextDrawable *text = new GLTextDrawable();
					QString ptSize = "36";
					QString html = 
						"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd\">"
						"<html><head><meta name=\"qrichtext\" content=\"1\"/>"
						"<style type=\"text/css\">p, li { white-space: pre-wrap; }</style>"
						"</head>"
						"<body style=\"font-family:'Sans Serif'; font-size:" + ptSize +"pt; font-weight:600; font-style:normal;\">"
						"<table style=\"-qt-table-type: root; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;\">"
						"<tr><td style=\"border: none;\">"
						"<p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">"
						"<span style=\"font-size:" + ptSize + "pt; font-weight:600; color:#ffffff;\">"
						+ comment +
						"</span></p></td></tr></table></body></html>";
						
					text->setText(html);
					
					//qDebug() << "File # text size:"<<size<<" @ width:"<<w<<", html:"<<html;
					if(canvasSize.width() > 1000)
					{
						QSize size = text->findNaturalSize(1400);
						
						QRectF targetRect = QRectF(0, 0, size.width(), size.height());
						targetRect.moveCenter(QRectF(1680,0,1440,900).center());
		
						text->setRect(targetRect);
						
						if(flipText)
						{
							text->setFlipVertical(true);
							text->setFlipHorizontal(true);
						}
					}
					else
					{
						int w = (int)canvasSize.width();
						QSize size = text->findNaturalSize(w);
						
						double x = (canvasSize.width() - size.width()) / 2;
						double y = canvasSize.height() - size.height() - 2;
						text->setRect(QRectF(QPointF(x,y),size));
					}
					text->setZIndex(5.);
					scene->addDrawable(text);
					
					qDebug() << "Loaded caption:"<<comment;
				}
				
				QFileInfo fileInfo(fullFile);
				QString fileName = fileInfo.baseName().toLower();
				fileName = fileName.replace(QRegExp("\\d{2,6}-\\{\\d\\}"),"");
				fileName = fileName.replace(QRegExp("(dsc_|sdc)"), "");
				
				if(!fileName.isEmpty())
				{
					GLTextDrawable *text = new GLTextDrawable();
					//QString html = QString("<span style='font-color:white;font-size:20px'>%1</font>").arg(fileName);
					
					QString ptSize = "24";
					QString html = 
						"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd\">"
						"<html><head><meta name=\"qrichtext\" content=\"1\"/>"
						"<style type=\"text/css\">p, li { white-space: pre-wrap; }</style>"
						"</head>"
						"<body style=\"font-family:'Sans Serif'; font-size:" + ptSize +"pt; font-weight:600; font-style:normal;\">"
						"<table style=\"-qt-table-type: root; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;\">"
						"<tr><td style=\"border: none;\">"
						"<p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">"
						"<span style=\"font-size:" + ptSize + "pt; font-weight:600; color:#ffffff;\">"
						"Photograph # "+ fileName +
						"</span></p></td></tr></table></body></html>";
						
					text->setText(html);
					int w = (int)canvasSize.width();
					QSize size = text->findNaturalSize(w);
					//qDebug() << "File # text size:"<<size<<" @ width:"<<w<<", html:"<<html;
					
					if(flipText)
					{
						if(canvasSize.width() > 1000)
						{
							int spinSpace = spinSize + 10;
							
							size = text->findNaturalSize(1440);
							
							//QRectF targetRect = QRectF(0, 0, size.width(), size.height());
							//targetRect.moveCenter(QRectF(1680,0,1440,900).center());
							double x = 1680 + 10 + spinSpace;
							double y =  900 - 10 - size.height();
							QRectF rect(QPointF(x,y),size);
							//qDebug() << "Rect: "<<rect;
							text->setRect(rect);
							
							text->setFlipVertical(true);
							text->setFlipHorizontal(true);
						}
						else
						{
							// TODO flip here too
							double x = canvasSize.width() - size.width() - 2;
							double y = 2;
							text->setRect(QRectF(QPointF(x,y),size));
						}
					}
					else
					{
						double x = canvasSize.width() - size.width() - 2;
						double y = 2;
						text->setRect(QRectF(QPointF(x,y),size));
					}
					text->setZIndex(5.);
					scene->addDrawable(text);
				}
				
				if(!datetime.isEmpty())
				{
					GLTextDrawable *text = new GLTextDrawable();
					//QString html = QString("<span style='font-color:white;font-size:20px'>%1</font>").arg(fileName);
					
					// 2009:10:25 12:13:34
					QDateTime parsedDate = QDateTime::fromString(datetime, "yyyy:MM:dd hh:mm:ss");
					QString dateString = "Photographed " + parsedDate.toString("dddd, MMMM d, yyyy");
					
					QString ptSize = "24";
					QString html = 
						"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd\">"
						"<html><head><meta name=\"qrichtext\" content=\"1\"/>"
						"<style type=\"text/css\">p, li { white-space: pre-wrap; }</style>"
						"</head>"
						"<body style=\"font-family:'Sans Serif'; font-size:" + ptSize +"pt; font-weight:600; font-style:normal;\">"
						"<table style=\"-qt-table-type: root; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;\">"
						"<tr><td style=\"border: none;\">"
						"<p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">"
						"<span style=\"font-size:" + ptSize + "pt; font-weight:600; color:#ffffff;\">"
						+ dateString +
						"</span></p></td></tr></table></body></html>";
						
					text->setText(html);
					int w = (int)canvasSize.width();
					QSize size = text->findNaturalSize(w);
					//qDebug() << "File # text size:"<<size<<" @ width:"<<w<<", html:"<<html;
					
					if(flipText)
					{
						if(canvasSize.width() > 1000)
						{
							//int spinSpace = spinSize + 10;
							
							size = text->findNaturalSize(1440);
							
							//QRectF targetRect = QRectF(0, 0, size.width(), size.height());
							//targetRect.moveCenter(QRectF(1680,0,1440,900).center());
							double x = 1680 + (1440 - size.width()) / 2;
							double y =  10; //900 - 10 - size.height();
							QRectF rect(QPointF(x,y),size);
							//qDebug() << "Rect: "<<rect;
							text->setRect(rect);
							
							text->setFlipVertical(true);
							text->setFlipHorizontal(true);
						}
						else
						{
							// TODO 
// 							double x = canvasSize.width() - size.width() - 2;
// 							double y = 2;
// 							text->setRect(QRectF(QPointF(x,y),size));
						}
					}
					else
					{
						// TODO
// 						double x = canvasSize.width() - size.width() - 2;
// 						double y = 2;
// 						text->setRect(QRectF(QPointF(x,y),size));
					}
					text->setZIndex(5.);
					scene->addDrawable(text);
				}
			}
			
			
			m_scenes << scene;
		}
Example #9
0
void Executer::executeCanvasSize(TreeNode* node) {
//	//qDebug() << "called";
	if (!checkParameterQuantity(node, 2, 20000+Token::CanvasSize*100+90) ||
		!checkParameterType(node, Value::Number, 20000+Token::CanvasSize*100+91)) return;
	emit canvasSize(node->child(0)->value()->number(), node->child(1)->value()->number());
}