void StoryCardScene::initCard(qreal x, qreal y, qreal width, qreal height) { QGraphicsTextItem *pItem; QFont aFont("Arial",8); // add static scene items addRect(theDescRect); //Description pItem = addText("Notes", aFont); pItem->setPos(theNotesRect.x(), theNotesRect.y()- 2*aFont.pointSize()-2); addRect(theNotesRect); //Notes pItem = addText("How To Demo", aFont); pItem->setPos(theHTDRect.x(), theHTDRect.y()- 2*aFont.pointSize()-2); addRect(theHTDRect); //Demo aFont.setPointSize(7); pItem = addText("Importance", aFont); pItem->setPos(theImpRect.x(), theImpRect.y()- 2*aFont.pointSize()-2); addRect(theImpRect); //Importance pItem = addText("Estimation", aFont); pItem->setPos(theEstRect.x(), theEstRect.y()- 2*aFont.pointSize()-2); addRect(theEstRect); //Estimation //add variable scene items theStoryID = addText(""); theStoryID->setPos(theIDRect.x(),theIDRect.y()); theStoryID->setTextWidth(theIDRect.width()); theStoryDesc = addText(""); theStoryDesc->setPos(theDescRect.x(),theDescRect.y()); theStoryDesc->setTextWidth(theDescRect.width()); theStoryNotes = addText(""); theStoryNotes->setPos(theNotesRect.x(),theNotesRect.y()); theStoryNotes->setTextWidth(theNotesRect.width()); theStoryHTD = addText(""); theStoryHTD->setPos(theHTDRect.x(),theHTDRect.y()); theStoryHTD->setTextWidth(theHTDRect.width()); theStoryImp = addText(""); theStoryImp->setPos(theImpRect.x(),theImpRect.y()); theStoryImp->setTextWidth(theImpRect.width()); theStoryEst = addText(""); theStoryEst->setPos(theEstRect.x(),theEstRect.y()); theStoryEst->setTextWidth(theEstRect.width()); theStoryUser = addText(""); theStoryUser->setPos(theUserRect.x(),theUserRect.y()); theStoryUser->setTextWidth(theUserRect.width()); theParentStory = addText(""); theParentStory->setPos(theParentRect.x(),theParentRect.y()); theParentStory->setTextWidth(theParentRect.width()); }
void PathBubble0::resizeFont(QString aText, QString fontType , int &fontSize, int style, int width, int height) { int newFontSize; QFont aFont(fontType, fontSize, style); QFontMetrics qfm(aFont); QSize size = qfm.size(0, aText); newFontSize=fontSize; if(size.width()>width*0.95||size.width()<width*0.85) fontSize= fontSize*width*0.9/size.width(); QFont aFont2(fontType, fontSize, style); QFontMetrics qfm2(aFont2); size = qfm2.size(0, aText); if(size.height()>height*0.95) { fontSize = fontSize*height*0.95/size.height(); } if(fontSize<1) fontSize=1; }
void PieMenuItem::paint( QPainter *painter, QPointF bubblePos) { //****************************************************** //painter->setPen( Qt::NoPen ); painter->setPen( Qt::black); painter->setBrush( QBrush( QColor( 166, 216, 84, 100 ) ) ); /*if (style == Qt::LinearGradientPattern) { QLinearGradient linearGradient(0, 0, 100, 100); linearGradient.setColorAt(0.0, Qt::white); linearGradient.setColorAt(0.2, Qt::green); linearGradient.setColorAt(1.0, Qt::black); renderArea->setBrush(linearGradient); } else if (style == Qt::RadialGradientPattern) { QRadialGradient radialGradient(50, 50, 50, 70, 70); radialGradient.setColorAt(0.0, Qt::white); radialGradient.setColorAt(0.2, Qt::green); radialGradient.setColorAt(1.0, Qt::black); renderArea->setBrush(radialGradient); } else if (style == Qt::ConicalGradientPattern) { QConicalGradient conicalGradient(50, 50, 150); conicalGradient.setColorAt(0.0, Qt::white); conicalGradient.setColorAt(0.2, Qt::green); conicalGradient.setColorAt(1.0, Qt::black); renderArea->setBrush(conicalGradient); } else if (style == Qt::TexturePattern) { renderArea->setBrush(QBrush(QPixmap(":/images/brick.png"))); } else { renderArea->setBrush(QBrush(Qt::green, style)); }*/ //****************************************************** //draw pie QFont aFont("Arial", 9, QFont::Normal); float angle=this->_startAngle; float spanAngle=this->_intervalAngle; float x=this->_pos.x()-bubblePos.x()-this->_R, y=this->_pos.y()-bubblePos.y()-this->_R, w=this->_R*2, h=this->_R*2; float h2=h*2, w2=w*2, x2=this->_pos.x()-bubblePos.x()-this->_R*2, y2=this->_pos.y()-bubblePos.y()-this->_R*2; for(int i=0; i<this->_sectorNum;i++) { //QRect myRect(x,y,w,h); //QLinearGradient gradient(myRect.topLeft(), myRect.bottomRight()); //gradient.setColorAt(0, Qt::white); //gradient.setColorAt(1, Qt::red); //myColor3 _color = TDHelper::getBoarderColorByType(i+1,0); QColor c = this->_color[i]; if(i==this->_currentSector&&!this->_disables[i]) { if(this->_text2[i].size()>0) { //myColor3 _color = TDHelper::getBoarderColorByType(i+1,0); QConicalGradient gradient(this->_pos.x()-bubblePos.x(), this->_pos.y()-bubblePos.y(), angle); float spanAngle2=spanAngle/this->_text2[i].size(); float angle2=angle; for(int j=0; j<this->_text2[i].size(); j++) { QColor c2 = this->_color2[i][j]; if(j==this->_currentSector2 && !this->_disables2[i][j]) c2.setAlpha(255); c.setAlpha(255); gradient.setColorAt(0.0, QColor(255,255,255,255)); gradient.setColorAt(0.3, c2); painter->setBrush(gradient); painter->setPen(QColor(80,80,80)); painter->drawPie(x2,y2,w2,h2,angle2*16,spanAngle2*16); angle2+=spanAngle2; } } //myColor3 _color = TDHelper::getBoarderColorByType(i+1,0); //highlight c.setAlpha(255); QConicalGradient gradient(this->_pos.x()-bubblePos.x(), this->_pos.y()-bubblePos.y(), angle); gradient.setColorAt(0.0, QColor(255,255,255, 255)); gradient.setColorAt(0.3, c); painter->setBrush(gradient); //painter->setBrush(QColor(_color.a,_color.b,_color.c, _color.o)); } else { c.setAlpha(255); QConicalGradient gradient(this->_pos.x()-bubblePos.x(), this->_pos.y()-bubblePos.y(), angle); gradient.setColorAt(0.0, QColor(200,200,200,255)); gradient.setColorAt(0.3, c); painter->setBrush(gradient); } painter->setPen(QColor(80,80,80)); painter->drawPie(x,y,w,h,angle*16,spanAngle*16); angle=angle+spanAngle; } angle=this->_startAngle; for(int i=0; i<this->_sectorNum;i++) { QFontMetrics fm(aFont); QSize size = fm.size(0,this->_text[i]); float cangle=(angle+spanAngle/2.0)/180.0*3.1415926; if(this->_disables[i]) { painter->setPen( QColor(128,128,128,250) ); } else painter->setPen( QColor(0,0,0,250) ); painter->setFont(aFont); /* float cx=this->_pos.x()+cos(cangle)*this->_R*0.2, cy=this->_pos.y()-sin(cangle)*this->_R*0.2; painter->save(); painter->translate(cx, cy); if(cangle>3.1415926*0.5 && cangle<3.1415926*1.5) painter->rotate(360 + cangle/3.1415926*180); else painter->rotate(-cangle/3.1415926*180); painter->drawText(0, 0, this->_text[i]); painter->restore();*/ float cx=this->_pos.x()-bubblePos.x()+cos(cangle)*this->_R*0.6, cy=this->_pos.y()-bubblePos.y()-sin(cangle)*this->_R*0.6; painter->drawText(cx-size.width()/2.0, cy-size.height()/2.0 + 10, this->_text[i]); if(i==this->_currentSector&&!this->_disables[i]) { if(this->_text2[i].size()>0) { float spanAngle2=spanAngle/this->_text2[i].size(); for(int j=0; j<this->_text2[i].size(); j++) { float cangle2=(angle+spanAngle2*j+spanAngle2/2.0)/180.0*3.1415926; float cx,cy; if(this->_disables2[i][j]) { painter->setPen( QColor(128,128,128,250) ); } else painter->setPen( QColor(0,0,0,250) ); painter->save(); if(cangle2>3.1415926*0.5 && cangle2<=3.1415926*1.0) { cx=this->_R*0.8, cy=this->_R*0.8; painter->translate(this->_pos.x()-bubblePos.x(), this->_pos.y()-bubblePos.y()); painter->rotate(180-cangle2/3.1415926*180); painter->drawText(-cx-size.width(), 0, this->_text2[i][j]); } else if(cangle2>3.1415926*1.0 && cangle2<=3.1415926*1.5) { cx=this->_R*1.3, cy=this->_R*1.3; painter->translate(this->_pos.x()-bubblePos.x(), this->_pos.y()-bubblePos.y()); painter->rotate(180-cangle2/3.1415926*180); painter->drawText(-cx-size.width(), 0, this->_text2[i][j]); } else { //if(cangle2<3.1415926*1.5) // cx=this->_pos.x()-bubblePos.x()+cos(cangle2)*this->_R*0.8, cy=this->_pos.y()-bubblePos.y()-sin(cangle2)*this->_R*0.8; //else cx=this->_pos.x()-bubblePos.x()+cos(cangle2)*this->_R*1.0, cy=this->_pos.y()-bubblePos.y()-sin(cangle2)*this->_R*1.0; painter->translate(cx, cy); painter->rotate(-cangle2/3.1415926*180); painter->drawText(0, 0, this->_text2[i][j]); } painter->restore(); } } } //painter->drawText(cx-size.width()/2.0, cy-size.height()/2.0, this->_text[i]); angle=angle+spanAngle; } //draw boundary shadow //draw text return; }