39 setMinimumSize(250,250);
119 item->setParent(
this);
126 return mItems.removeAll(item);
137 QPainter painter(
this);
138 painter.setRenderHint(QPainter::Antialiasing);
141 item->
draw(&painter);
190 float offset = r-(percentage*r)/100.0;
191 QRectF tmpRect =
mRect.adjusted(offset,offset,-offset,-offset);
198 if(tmpRect.width()<tmpRect.height())
199 r = tmpRect.width()/2.0;
201 r = tmpRect.height()/2.0;
209 mRect.setWidth(2.0*r);
210 mRect.setHeight(2.0*r);
218 float xx=cos(0.0174533*deg)*r;
219 float yy=sin(0.0174533*deg)*r;
221 xx=tmpRect.center().x()-xx;
222 yy=tmpRect.center().y()-yy;
232 float xx=tmpRect.center().x()-pt.x();
233 float yy=tmpRect.center().y()-pt.y();
234 return 0.0174533*( atan2(yy,xx));
252 if(!(minValue<maxValue))
261 if(!(minDegree<maxDegree))
327 painter->setBrush(Qt::NoBrush);
328 QLinearGradient linearGrad(tmpRect.topLeft(), tmpRect.bottomRight());
329 for(
int i = 0;i<
mColors.size();i++){
332 painter->setPen(
mPen);
333 painter->setBrush(linearGrad);
339 if(position<0||position>1)
341 QPair<float,QColor> pair;
367 QRectF tmpRect2 = tmpRect1;
369 tmpRect2.setHeight(r/2.0);
370 painter->setPen(Qt::NoPen);
372 QColor clr1 = Qt::gray ;
373 QColor clr2 = Qt::white;
377 QLinearGradient linearGrad1(tmpRect1.topLeft(), tmpRect1.bottomRight());
378 linearGrad1.setColorAt(0.1, clr1);
379 linearGrad1.setColorAt(0.5, clr2);
381 painter->setBrush(linearGrad1);
382 painter->drawPie(tmpRect1,0,16*180);
383 tmpRect2.moveCenter(
rect().center());
384 painter->drawPie(tmpRect2,0,-16*180);
404 QFont font(
"Meiryo UI", r/10.0, QFont::Bold);
405 painter->setFont(font);
406 painter->setPen(QPen(
mColor));
409 QFontMetrics fMetrics = painter->fontMetrics();
410 QSize sz = fMetrics.size( Qt::TextSingleLine,
mText );
411 QRectF txtRect(QPointF(0,0), sz );
412 txtRect.moveCenter(txtCenter);
414 painter->drawText( txtRect, Qt::TextSingleLine,
mText );
472 painter->setPen(pen);
488 tmpColor.setAlphaF(0.1);
489 QPair<QColor,float> pair;
491 pair.first = Qt::green;
495 pair.first = Qt::darkGreen;
499 pair.first = Qt::red;
510 path.arcMoveTo(tmpRect,180+from);
511 path.arcTo(tmpRect,180+from,-sweep);
520 pen.setCapStyle(Qt::FlatCap);
521 pen.setWidthF(r/20.0);
522 painter->setBrush(Qt::NoBrush);
534 painter->setPen(pen);
535 painter->drawPath(path);
570 path.lineTo(tmpRect.center());
571 pt = path.pointAtPercent(0.03);
572 QPointF newPt = path.pointAtPercent(0.13);
577 pen.setWidthF(r/25.0);
579 painter->setPen(pen);
580 painter->drawLine(pt,newPt);
621 painter->translate(tmpRect.center());
623 painter->rotate(deg+90.0);
624 painter->setBrush(QBrush(
mColor));
625 painter->setPen(Qt::NoPen);
627 QLinearGradient grad;
646 grad.setColorAt(0.9,Qt::red);
647 grad.setColorAt(1,Qt::blue);
648 painter->setBrush(grad);
727 QVector<QPointF> tmpPoints;
728 tmpPoints.append(QPointF(0.0, 0.0));
729 tmpPoints.append(QPointF(-r/20.0,r/20.0));
730 tmpPoints.append(QPointF(0.0, r));
731 tmpPoints.append(QPointF(r/20.0,r/20.0));
737 QVector<QPointF> tmpPoints;
738 tmpPoints.append(QPointF(0.0, r));
739 tmpPoints.append(QPointF(-r/40.0, 0.0));
740 tmpPoints.append(QPointF(r/40.0,0.0));
746 QVector<QPointF> tmpPoints;
747 tmpPoints.append(QPointF(0.0, r));
748 tmpPoints.append(QPointF(-r/40.0, 0.0));
749 tmpPoints.append(QPointF(-r/15.0, -r/5.0));
750 tmpPoints.append(QPointF(r/15.0,-r/5));
751 tmpPoints.append(QPointF(r/40.0,0.0));
757 QVector<QPointF> tmpPoints;
758 tmpPoints.append(QPointF(0.0, r));
759 tmpPoints.append(QPointF(-r/20.0, 0.85*r));
760 tmpPoints.append(QPointF(r/20.0,0.85*r));
766 QVector<QPointF> tmpPoints;
767 tmpPoints.append(QPointF(0.0, r));
768 tmpPoints.append(QPointF(-r/15.0, 0.0));
769 tmpPoints.append(QPointF(0.0, -r));
770 tmpPoints.append(QPointF(r/15.0,0.0));
791 QFont font(
"Meiryo UI",0, QFont::Bold);
792 font.setPointSizeF(0.08*r);
794 painter->setFont(font);
801 path.lineTo( tmpRect.center());
802 QString strVal = QString::number(val);
803 QFontMetrics fMetrics = painter->fontMetrics();
804 QSize sz = fMetrics.size( Qt::TextSingleLine, strVal );
805 QRectF txtRect(QPointF(0,0), sz );
806 QPointF textCenter = path.pointAtPercent(1.0-
position()/100.0);
807 txtRect.moveCenter(textCenter);
809 painter->drawText( txtRect, Qt::TextSingleLine, strVal );
852 float a = (pitchPoint.y()-pt.y())/(pitchPoint.x()-pt.x());
853 float b = pt.y()-a*pt.x();
854 return QPointF(0,a*0+b);
862 QPointF pitchPoint = QPointF(tmpRect.center().x(),tmpRect.center().y()-
mPitchOffset);
867 path1.moveTo(pitchPoint);
872 path2.addEllipse(tmpRect);
874 QPointF p = path1.intersected(path2).pointAtPercent(.5);
888 painter->setPen(Qt::NoPen);
908 pen.setColor(Qt::white);
909 painter->setPen(pen);
910 for(
int deg = 60;deg<=120;deg+=10){
916 pen.setWidthF(r/30.0);
917 painter->setPen(pen);
928 QPointF pt1 =
getPoint(deg,tmpRect);
929 QPointF pt2 = tmpRect.center();
933 QPointF pt = path.pointAtPercent(0.1);
934 painter->drawLine(pt1,pt);
941 QLinearGradient radialGrad1(tmpRect.topLeft(),tmpRect.bottomRight());
942 QColor clr1 = Qt::blue;
944 QColor clr2 = Qt::darkBlue;
946 radialGrad1.setColorAt(0, clr1);
947 radialGrad1.setColorAt(.8, clr2);
951 float startAngle = 180-offset;
952 float endAngle = offset-2*
mRoll;
953 float span =endAngle-startAngle;
955 painter->setBrush(radialGrad1);
956 painter->drawChord(tmpRect,16*startAngle,16*span);
963 QLinearGradient radialGrad2(tmpRect.topLeft(),tmpRect.bottomRight());
964 QColor clr1 = QColor(139,119,118);
965 QColor clr2 = QColor(139,119,101);
966 radialGrad2.setColorAt(0, clr1);
967 radialGrad2.setColorAt(.8, clr2);
970 float startAngle = 180+offset;
971 float endAngle = offset-2*
mRoll;
972 float span =endAngle+startAngle;
974 painter->setPen(Qt::NoPen);
975 painter->setBrush(radialGrad2);
976 painter->drawChord(tmpRect,-16*startAngle,16*span);
983 QPointF center = tmpRect.center();
986 painter->rotate(
mRoll);
988 pen.setColor(Qt::white);
989 pen.setWidthF(r/40.0);
991 painter->setPen(pen);
992 for (
int i = -30;i<=30;i+=10){
994 pt1.setX(-0.01*r*abs(i));
997 pt2.setX(0.01*r*abs(i));
999 painter->drawLine(pt1,pt2);
1005 QFont font(
"Meiryo UI",0, QFont::Bold);
1006 font.setPointSizeF(0.08*r);
1007 painter->setFont(font);
1008 QString strVal = QString::number(abs(i));
1009 QFontMetrics fMetrics = painter->fontMetrics();
1010 QSize sz = fMetrics.size( Qt::TextSingleLine, strVal );
1011 QRectF leftTxtRect(QPointF(0,0), sz );
1012 QRectF rightTxtRect(QPointF(0,0), sz );
1013 leftTxtRect.moveCenter(pt1-QPointF(0.1*r,0));
1014 rightTxtRect.moveCenter(pt2+QPointF(0.1*r,0));
1015 painter->drawText( leftTxtRect, Qt::TextSingleLine, strVal );
1016 painter->drawText( rightTxtRect, Qt::TextSingleLine, strVal );
1026 pen.setColor(Qt::gray);
1027 pen.setWidthF(0.25*r);
1028 painter->setPen(pen);
1029 painter->drawArc(tmpRct,0,-16*180);
1031 QPointF center = tmpRct.center();
1032 QPointF leftPt1 = center;
1033 QPointF leftPt2 = center;
1034 QPointF rightPt1 = center;
1035 QPointF rightPt2 = center;
1036 leftPt1.setX(center.x()-2*r);
1037 leftPt2.setX(center.x()-r);
1038 rightPt1.setX(center.x()+2*r);
1039 rightPt2.setX(center.x()+r);
1040 painter->drawLine(leftPt1,leftPt2);
1041 painter->drawLine(rightPt1,rightPt2);
1045 QPointF pt1 = center;
1046 QPointF pt2 = center;
1048 pt1.setY(center.y()+r);
1049 pt2.setY(center.y()+4*r);
1050 pen.setColor(Qt::gray);
1051 painter->setPen(pen);
1052 painter->drawLine(pt1,pt2);
1055 painter->setPen(Qt::gray);
1056 painter->setBrush(Qt::gray);
1058 QPointF tmpPt = center;
1059 tmpPt.setX(center.x()-r);
1060 tmpPt.setY(center.y()+4*r);
1061 trapPoly.append(tmpPt);
1063 trapPoly.append(
getPoint(290,tmpRct));
1064 trapPoly.append(
getPoint(250,tmpRct));
1066 tmpPt.setX(center.x()+r);
1067 tmpPt.setY(center.y()+4*r);
1068 trapPoly.append(tmpPt);
1069 painter->drawPolygon(trapPoly);
1070 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)