40 setMinimumSize(250,250);
120 item->setParent(
this);
127 return mItems.removeAll(item);
138 QPainter painter(
this);
139 painter.setRenderHint(QPainter::Antialiasing);
142 item->
draw(&painter);
191 float offset = r-(percentage*r)/100.0;
192 QRectF tmpRect =
mRect.adjusted(offset,offset,-offset,-offset);
199 if(tmpRect.width()<tmpRect.height())
200 r = tmpRect.width()/2.0;
202 r = tmpRect.height()/2.0;
210 mRect.setWidth(2.0*r);
211 mRect.setHeight(2.0*r);
219 float xx=cos(0.0174533*deg)*r;
220 float yy=sin(0.0174533*deg)*r;
222 xx=tmpRect.center().x()-xx;
223 yy=tmpRect.center().y()-yy;
233 float xx=tmpRect.center().x()-pt.x();
234 float yy=tmpRect.center().y()-pt.y();
235 return 0.0174533*( atan2(yy,xx));
253 if(!(minValue<maxValue))
262 if(!(minDegree<maxDegree))
328 painter->setBrush(Qt::NoBrush);
329 QLinearGradient linearGrad(tmpRect.topLeft(), tmpRect.bottomRight());
330 for(
int i = 0;i<
mColors.size();i++){
333 painter->setPen(
mPen);
334 painter->setBrush(linearGrad);
340 if(position<0||position>1)
342 QPair<float,QColor> pair;
368 QRectF tmpRect2 = tmpRect1;
370 tmpRect2.setHeight(r/2.0);
371 painter->setPen(Qt::NoPen);
373 QColor clr1 = Qt::gray ;
374 QColor clr2 = Qt::white;
378 QLinearGradient linearGrad1(tmpRect1.topLeft(), tmpRect1.bottomRight());
379 linearGrad1.setColorAt(0.1, clr1);
380 linearGrad1.setColorAt(0.5, clr2);
382 painter->setBrush(linearGrad1);
383 painter->drawPie(tmpRect1,0,16*180);
384 tmpRect2.moveCenter(
rect().center());
385 painter->drawPie(tmpRect2,0,-16*180);
405 QFont font(
"Meiryo UI", r/10.0, QFont::Bold);
406 painter->setFont(font);
407 painter->setPen(QPen(
mColor));
410 QFontMetrics fMetrics = painter->fontMetrics();
411 QSize sz = fMetrics.size( Qt::TextSingleLine,
mText );
412 QRectF txtRect(QPointF(0,0), sz );
413 txtRect.moveCenter(txtCenter);
415 painter->drawText( txtRect, Qt::TextSingleLine,
mText );
473 painter->setPen(pen);
489 tmpColor.setAlphaF(0.1);
490 QPair<QColor,float> pair;
492 pair.first = Qt::green;
496 pair.first = Qt::darkGreen;
500 pair.first = Qt::red;
511 path.arcMoveTo(tmpRect,180+from);
512 path.arcTo(tmpRect,180+from,-sweep);
521 pen.setCapStyle(Qt::FlatCap);
522 pen.setWidthF(r/20.0);
523 painter->setBrush(Qt::NoBrush);
535 painter->setPen(pen);
536 painter->drawPath(path);
571 path.lineTo(tmpRect.center());
572 pt = path.pointAtPercent(0.03);
573 QPointF newPt = path.pointAtPercent(0.13);
578 pen.setWidthF(r/25.0);
580 painter->setPen(pen);
581 painter->drawLine(pt,newPt);
622 painter->translate(tmpRect.center());
624 painter->rotate(deg+90.0);
625 painter->setBrush(QBrush(
mColor));
626 painter->setPen(Qt::NoPen);
628 QLinearGradient grad;
647 grad.setColorAt(0.9,Qt::red);
648 grad.setColorAt(1,Qt::blue);
649 painter->setBrush(grad);
728 QVector<QPointF> tmpPoints;
729 tmpPoints.append(QPointF(0.0, 0.0));
730 tmpPoints.append(QPointF(-r/20.0,r/20.0));
731 tmpPoints.append(QPointF(0.0, r));
732 tmpPoints.append(QPointF(r/20.0,r/20.0));
738 QVector<QPointF> tmpPoints;
739 tmpPoints.append(QPointF(0.0, r));
740 tmpPoints.append(QPointF(-r/40.0, 0.0));
741 tmpPoints.append(QPointF(r/40.0,0.0));
747 QVector<QPointF> tmpPoints;
748 tmpPoints.append(QPointF(0.0, r));
749 tmpPoints.append(QPointF(-r/40.0, 0.0));
750 tmpPoints.append(QPointF(-r/15.0, -r/5.0));
751 tmpPoints.append(QPointF(r/15.0,-r/5));
752 tmpPoints.append(QPointF(r/40.0,0.0));
758 QVector<QPointF> tmpPoints;
759 tmpPoints.append(QPointF(0.0, r));
760 tmpPoints.append(QPointF(-r/20.0, 0.85*r));
761 tmpPoints.append(QPointF(r/20.0,0.85*r));
767 QVector<QPointF> tmpPoints;
768 tmpPoints.append(QPointF(0.0, r));
769 tmpPoints.append(QPointF(-r/15.0, 0.0));
770 tmpPoints.append(QPointF(0.0, -r));
771 tmpPoints.append(QPointF(r/15.0,0.0));
792 QFont font(
"Meiryo UI",0, QFont::Bold);
793 font.setPointSizeF(0.08*r);
795 painter->setFont(font);
802 path.lineTo( tmpRect.center());
803 QString strVal = QString::number(val);
804 QFontMetrics fMetrics = painter->fontMetrics();
805 QSize sz = fMetrics.size( Qt::TextSingleLine, strVal );
806 QRectF txtRect(QPointF(0,0), sz );
807 QPointF textCenter = path.pointAtPercent(1.0-
position()/100.0);
808 txtRect.moveCenter(textCenter);
810 painter->drawText( txtRect, Qt::TextSingleLine, strVal );
853 float a = (pitchPoint.y()-pt.y())/(pitchPoint.x()-pt.x());
854 float b = pt.y()-a*pt.x();
855 return QPointF(0,a*0+b);
863 QPointF pitchPoint = QPointF(tmpRect.center().x(),tmpRect.center().y()-
mPitchOffset);
868 path1.moveTo(pitchPoint);
873 path2.addEllipse(tmpRect);
875 QPointF p = path1.intersected(path2).pointAtPercent(.5);
889 painter->setPen(Qt::NoPen);
909 pen.setColor(Qt::white);
910 painter->setPen(pen);
911 for(
int deg = 60;deg<=120;deg+=10){
917 pen.setWidthF(r/30.0);
918 painter->setPen(pen);
929 QPointF pt1 =
getPoint(deg,tmpRect);
930 QPointF pt2 = tmpRect.center();
934 QPointF pt = path.pointAtPercent(0.1);
935 painter->drawLine(pt1,pt);
942 QLinearGradient radialGrad1(tmpRect.topLeft(),tmpRect.bottomRight());
943 QColor clr1 = Qt::blue;
945 QColor clr2 = Qt::darkBlue;
947 radialGrad1.setColorAt(0, clr1);
948 radialGrad1.setColorAt(.8, clr2);
952 float startAngle = 180-offset;
953 float endAngle = offset-2*
mRoll;
954 float span =endAngle-startAngle;
956 painter->setBrush(radialGrad1);
957 painter->drawChord(tmpRect,16*startAngle,16*span);
964 QLinearGradient radialGrad2(tmpRect.topLeft(),tmpRect.bottomRight());
965 QColor clr1 = QColor(139,119,118);
966 QColor clr2 = QColor(139,119,101);
967 radialGrad2.setColorAt(0, clr1);
968 radialGrad2.setColorAt(.8, clr2);
971 float startAngle = 180+offset;
972 float endAngle = offset-2*
mRoll;
973 float span =endAngle+startAngle;
975 painter->setPen(Qt::NoPen);
976 painter->setBrush(radialGrad2);
977 painter->drawChord(tmpRect,-16*startAngle,16*span);
984 QPointF center = tmpRect.center();
987 painter->rotate(
mRoll);
989 pen.setColor(Qt::white);
990 pen.setWidthF(r/40.0);
992 painter->setPen(pen);
993 for (
int i = -30;i<=30;i+=10){
995 pt1.setX(-0.01*r*abs(i));
998 pt2.setX(0.01*r*abs(i));
1000 painter->drawLine(pt1,pt2);
1006 QFont font(
"Meiryo UI",0, QFont::Bold);
1007 font.setPointSizeF(0.08*r);
1008 painter->setFont(font);
1009 QString strVal = QString::number(abs(i));
1010 QFontMetrics fMetrics = painter->fontMetrics();
1011 QSize sz = fMetrics.size( Qt::TextSingleLine, strVal );
1012 QRectF leftTxtRect(QPointF(0,0), sz );
1013 QRectF rightTxtRect(QPointF(0,0), sz );
1014 leftTxtRect.moveCenter(pt1-QPointF(0.1*r,0));
1015 rightTxtRect.moveCenter(pt2+QPointF(0.1*r,0));
1016 painter->drawText( leftTxtRect, Qt::TextSingleLine, strVal );
1017 painter->drawText( rightTxtRect, Qt::TextSingleLine, strVal );
1027 pen.setColor(Qt::gray);
1028 pen.setWidthF(0.25*r);
1029 painter->setPen(pen);
1030 painter->drawArc(tmpRct,0,-16*180);
1032 QPointF center = tmpRct.center();
1033 QPointF leftPt1 = center;
1034 QPointF leftPt2 = center;
1035 QPointF rightPt1 = center;
1036 QPointF rightPt2 = center;
1037 leftPt1.setX(center.x()-2*r);
1038 leftPt2.setX(center.x()-r);
1039 rightPt1.setX(center.x()+2*r);
1040 rightPt2.setX(center.x()+r);
1041 painter->drawLine(leftPt1,leftPt2);
1042 painter->drawLine(rightPt1,rightPt2);
1046 QPointF pt1 = center;
1047 QPointF pt2 = center;
1049 pt1.setY(center.y()+r);
1050 pt2.setY(center.y()+4*r);
1051 pen.setColor(Qt::gray);
1052 painter->setPen(pen);
1053 painter->drawLine(pt1,pt2);
1056 painter->setPen(Qt::gray);
1057 painter->setBrush(Qt::gray);
1059 QPointF tmpPt = center;
1060 tmpPt.setX(center.x()-r);
1061 tmpPt.setY(center.y()+4*r);
1062 trapPoly.append(tmpPt);
1064 trapPoly.append(
getPoint(290,tmpRct));
1065 trapPoly.append(
getPoint(250,tmpRct));
1067 tmpPt.setX(center.x()+r);
1068 tmpPt.setY(center.y()+4*r);
1069 trapPoly.append(tmpPt);
1070 painter->drawPolygon(trapPoly);
1071 painter->drawChord(tmpRct,-16*70,-16*40);
float getDegFromValue(float)
QcGlassItem(QObject *parent=0)
float getRadius(const QRectF &)
void drawDegree(QPainter *painter, const QRectF &tmpRect, float deg)
QcAttitudeMeter(QObject *parent=0)
QcDegreesItem(QObject *parent=0)
QPointF getPoint(float deg, const QRectF &tmpRect)
void drawHandle(QPainter *)
QcValuesItem(QObject *parent=0)
virtual void draw(QPainter *)
void setMaxDegree(float maxDegree)
void drawUpperEllipse(QPainter *, const QRectF &)
QPainterPath createSubBand(float from, float sweep)
void setPosition(float percentage)
QList< QPair< QColor, float > > mBandColors
void drawDegrees(QPainter *)
void createDiamonNeedle(float r)
QcBackgroundItem(QObject *parent=0)
void drawLowerEllipse(QPainter *, const QRectF &)
void draw(QPainter *painter)
void setCurrentRoll(float roll)
void setText(const QString &text, bool repaint=true)
void setValueFormat(QString format)
void setCurrentValue(float value)
void createTriangleNeedle(float r)
void setDgereeRange(float minDegree, float maxDegree)
void setColor(const QColor &color)
void setMinDegree(float minDegree)
virtual void draw(QPainter *)=0
QcItem(QObject *parent=0)
QPointF getIntersection(float r, const QPointF &pitchPoint, const QPointF &pt)
void setValueRange(float minValue, float maxValue)
void setMaxValue(float maxValue)
void setCurrentPitch(float pitch)
QcScaleItem(QObject *parent=0)
void setLabel(QcLabelItem *)
QString currentValueFormat()
void setColor(const QColor &color)
void setNeedle(QcNeedleItem::NeedleType needleType)
void createCompassNeedle(float r)
void setMinValue(float minValue)
QList< QPair< float, QColor > > mColors
QcArcItem(QObject *parent=0)
void drawPitchSteps(QPainter *, const QRectF &)
void setColors(const QList< QPair< QColor, float > > &colors)
float getAngle(const QPointF &, const QRectF &tmpRect)
void setColor(const QColor &color)
QcNeedleItem(QObject *parent=0)
void createFeatherNeedle(float r)
void createAttitudeNeedle(float r)
void setColor(const QColor &color)
void setColor(const QColor &color)
void addColor(float position, const QColor &color)
QRectF adjustRect(float percentage)
QcLabelItem(QObject *parent=0)
QcColorBand(QObject *parent=0)
float getStartAngle(const QRectF &tmpRect)