PreFlightMiscPage::PreFlightMiscPage(QWidget *parent) :
QWidget(parent)
{
setObjectName("PreFlightMiscPage");
setWindowFlags( Qt::Tool );
setWindowModality( Qt::WindowModal );
setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle( tr("PreFlight - Common") );
if( parent )
{
resize( parent->size() );
}
// Layout used by scroll area
QHBoxLayout *sal = new QHBoxLayout;
// new widget used as container for the dialog layout.
QWidget* sw = new QWidget;
// Scroll area
QScrollArea* sa = new QScrollArea;
sa->setWidgetResizable( true );
sa->setFrameStyle( QFrame::NoFrame );
sa->setWidget( sw );
#ifdef QSCROLLER
QScroller::grabGesture( sa->viewport(), QScroller::LeftMouseButtonGesture );
#endif
#ifdef QTSCROLLER
QtScroller::grabGesture( sa->viewport(), QtScroller::LeftMouseButtonGesture );
#endif
// Add scroll area to its own layout
sal->addWidget( sa );
QHBoxLayout *contentLayout = new QHBoxLayout(this);
// Pass scroll area layout to the content layout.
contentLayout->addLayout( sal, 10 );
// Top layout's parent is the scroll widget
QGridLayout *topLayout = new QGridLayout(sw);
int row = 0;
QLabel *lbl = new QLabel(tr("Minimal arrival altitude:"));
topLayout->addWidget(lbl, row, 0);
// get current set altitude unit. This unit must be considered during
// storage. The internal storage is always in meters.
m_altUnit = Altitude::getUnit();
// Input accept only feet and meters all other make no sense. Therefore all
// other (FL) is treated as feet.
m_edtMinimalArrival = new NumberEditor;
m_edtMinimalArrival->setDecimalVisible( false );
m_edtMinimalArrival->setPmVisible( false );
m_edtMinimalArrival->setRange( 0, 9999);
m_edtMinimalArrival->setMaxLength(4);
m_edtMinimalArrival->setSuffix(" " + Altitude::getUnitText());
QRegExpValidator* eValidator = new QRegExpValidator( QRegExp( "([0-9]{1,4})" ), this );
m_edtMinimalArrival->setValidator( eValidator );
int maw = QFontMetrics(font()).width("9999 ft") + 10;
m_edtMinimalArrival->setMinimumWidth( maw );
topLayout->addWidget(m_edtMinimalArrival, row, 1);
topLayout->setColumnStretch(2, 2);
row++;
lbl = new QLabel(tr("Arrival altitude display:"));
topLayout->addWidget(lbl, row, 0);
m_edtArrivalAltitude = new QComboBox;
m_edtArrivalAltitude->addItem( tr("Landing Target"), GeneralConfig::landingTarget );
m_edtArrivalAltitude->addItem( tr("Next Target"), GeneralConfig::nextTarget );
topLayout->addWidget(m_edtArrivalAltitude, row, 1);
row++;
lbl = new QLabel(tr("QNH:"));
topLayout->addWidget(lbl, row, 0);
m_edtQNH = new NumberEditor;
m_edtQNH->setDecimalVisible( false );
m_edtQNH->setPmVisible( false );
m_edtQNH->setRange( 0, 9999);
m_edtQNH->setMaxLength(4);
m_edtQNH->setSuffix(" hPa");
eValidator = new QRegExpValidator( QRegExp( "([0-9]{1,4})" ), this );
m_edtQNH->setValidator( eValidator );
int mqw = QFontMetrics(font()).width("9999 hPa") + 10;
m_edtQNH->setMinimumWidth( mqw );
topLayout->addWidget(m_edtQNH, row, 1);
row++;
//.........这里部分代码省略.........
void
MenuItem::drawLabel( QPainter* p )
{
RasterOp origRasterOp = p->rasterOp();
if( m_mouseOver )
{
// p->setRasterOp( OrROP );
}
// Prepare the title and desc
// This is the available width that we can print text. This is the place just next to the pixmap
uint availableWidth = geometry().width() - ( 2 * m_offset ) - pixmap()->width() - ( 4 * m_secOffset );
// If there's a sub menu we'll draw an arrow in this button, so texts area gets smaller
if( m_sub )
availableWidth -= KGlobal::iconLoader()->loadIcon( m_arrowIcon, KIcon::Toolbar ).width() - m_secOffset;
// Titles will be printed in one line definetely, so squeze it to fit
QString s_title = KStringHandler::rPixelSqueeze( title(), p->fontMetrics(), availableWidth );
// Draw the icon
p->drawPixmap( m_offset + m_secOffset,
m_offset + m_secOffset,
*pixmap() );
if( !description().isNull() )
{
// Write the description with smaller font
QFont smallerFont = p->font();
// Make the font smaller by m_descFontOffset points
smallerFont.setPointSize( smallerFont.pointSize() - m_descFontOffset );
////// MOVE LINE SPLICING CODE TO ABOVE
// Let's see if we can use more than one line, because descriptions
// are more likely to be longer
// Active area height = total widget height - 2 * primary offset
int activeAreaHeight = geometry().height() - 2 * m_offset;
// Available desc height = Active area height - title height
int availableDescHeight = activeAreaHeight - p->fontMetrics().height();
// One desc line height
int descLineHeight = QFontMetrics( smallerFont ).height();
// Let's see how many desc lines are available
int lineCount = availableDescHeight / descLineHeight;
// Prepare each line of text
QString desc = description().stripWhiteSpace();
QString line = desc;
QStringList lines;
if( lineCount > 1 )
{
for( int j = 0; j < lineCount; j++ )
{
uint size = QFontMetrics( smallerFont ).width( desc );
if( ( j + 1 ) != lineCount )
{
while( size > availableWidth )
{
// Remove the last word untill it fits in one line
line = line.section( " ", 0, -2 );
size = QFontMetrics( smallerFont ).width( line );
}
}
else
{
// This is the last available line, so squeze the rest
line = KStringHandler::rPixelSqueeze( desc,
p->fontMetrics(),
availableWidth
);
}
lines.push_back( line );
desc = desc.mid( line.length() ).stripWhiteSpace();
line = desc;
if( line.isEmpty() ) break;
}
}
else
{
lines.push_back( KStringHandler::rPixelSqueeze( desc,
p->fontMetrics(),
availableWidth ) );
}
uint totalTextHeight = p->fontMetrics().height() +
lines.count() * descLineHeight;
int offset = ( geometry().height() - totalTextHeight ) / 2;
// Write the title of the cell
p->drawText( QRect( m_offset + pixmap()->width() + 2 * m_secOffset,
offset,
availableWidth,
p->fontMetrics().height()
),
Qt::AlignLeft, s_title );
// Print each line of the comment
//.........这里部分代码省略.........
//.........这里部分代码省略.........
}
QGroupBox *groupbox_video = new QGroupBox(tr("Video"), this);
{
QLabel *label_video_codec = new QLabel(tr("Codec:"), groupbox_video);
m_combobox_video_codec = new QComboBox(groupbox_video);
for(unsigned int i = 0; i < VIDEO_CODEC_COUNT; ++i) {
m_combobox_video_codec->addItem(m_video_codecs[i].name);
}
m_combobox_video_codec->setToolTip(tr("The codec that will be used to compress the video stream.\n"
"- H.264 (libx264) is by far the best codec - high quality and very fast.\n"
"- VP8 (libvpx) is quite good but also quite slow.\n"
"- Theora (libtheora) isn't really recommended because the quality isn't very good."));
m_label_video_codec_av = new QLabel(tr("Codec name:"), groupbox_video);
m_combobox_video_codec_av = new QComboBox(groupbox_video);
for(unsigned int i = 0; i < m_video_codecs_av.size(); ++i) {
VideoCodecData &c = m_video_codecs_av[i];
m_combobox_video_codec_av->addItem(c.avname);
}
m_combobox_video_codec_av->setToolTip(tr("For advanced users. You can use any libav/ffmpeg video codec, but many of them are not useful or may not work."));
m_label_video_kbit_rate = new QLabel(tr("Bit rate (in kbps):"), groupbox_video);
m_lineedit_video_kbit_rate = new QLineEdit(groupbox_video);
m_lineedit_video_kbit_rate->setToolTip(tr("The video bit rate (in kilobit per second). A higher value means a higher quality."
"\nIf you have no idea where to start, try 5000 and change it if needed."));
m_label_h264_crf = new QLabel(tr("Constant rate factor:", "libx264 setting: don't translate this unless you can come up with something sensible"), groupbox_video);
m_slider_h264_crf = new QSlider(Qt::Horizontal, groupbox_video);
m_slider_h264_crf->setRange(0, 51);
m_slider_h264_crf->setSingleStep(1);
m_slider_h264_crf->setPageStep(5);
m_slider_h264_crf->setToolTip(tr("This setting changes the video quality. A lower value means a higher quality.\n"
"The allowed range is 0-51 (0 means lossless, the default is 23)."));
m_label_h264_crf_value = new QLabel(groupbox_video);
m_label_h264_crf_value->setNum(m_slider_h264_crf->value());
m_label_h264_crf_value->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
m_label_h264_crf_value->setMinimumWidth(QFontMetrics(m_label_h264_crf_value->font()).width("99") + 2);
m_label_h264_preset = new QLabel(tr("Preset:", "libx264 setting: don't translate this unless you can come up with something sensible"), groupbox_video);
m_combobox_h264_preset = new QComboBox(groupbox_video);
for(unsigned int i = 0; i < H264_PRESET_COUNT; ++i) {
m_combobox_h264_preset->addItem(EnumToString((enum_h264_preset) i));
}
m_combobox_h264_preset->setToolTip(tr("The encoding speed. A higher speed uses less CPU (making higher recording frame rates possible),\n"
"but results in larger files. The quality shouldn't be affected too much."));
m_label_vp8_cpu_used = new QLabel(tr("CPU used:", "libvpx setting: don't translate this unless you can come up with something sensible"), groupbox_video);
m_combobox_vp8_cpu_used = new QComboBox(groupbox_video);
m_combobox_vp8_cpu_used->addItem("5 (" + tr("fastest") + ")");
m_combobox_vp8_cpu_used->addItem("4");
m_combobox_vp8_cpu_used->addItem("3");
m_combobox_vp8_cpu_used->addItem("2");
m_combobox_vp8_cpu_used->addItem("1");
m_combobox_vp8_cpu_used->addItem("0 (" + tr("slowest") + ")");
m_combobox_vp8_cpu_used->setToolTip(tr("The encoding speed. A higher value uses *less* CPU time. (I didn't choose the name, this is the name\n"
"used by the VP8 encoder). Higher values result in lower quality video, unless you increase the bit rate too."));
m_label_video_options = new QLabel(tr("Custom options:"), groupbox_video);
m_lineedit_video_options = new QLineEdit(groupbox_video);
m_lineedit_video_options->setToolTip(tr("Custom codec options separated by commas (e.g. option1=value1,option2=value2,option3=value3)"));
m_checkbox_video_allow_frame_skipping = new QCheckBox(tr("Allow frame skipping"), groupbox_video);
m_checkbox_video_allow_frame_skipping->setToolTip(tr("If checked, the video encoder will be allowed to skip frames if the input frame rate is\n"
"lower than the output frame rate. If not checked, input frames will be duplicated to fill the holes.\n"
"This increases the file size and CPU usage, but reduces the latency for live streams in some cases.\n"
"It shouldn't affect the appearance of the video."));
connect(m_combobox_video_codec, SIGNAL(activated(int)), this, SLOT(OnUpdateVideoCodecFields()));
connect(m_slider_h264_crf, SIGNAL(valueChanged(int)), m_label_h264_crf_value, SLOT(setNum(int)));
QGridLayout *layout = new QGridLayout(groupbox_video);
layout->addWidget(label_video_codec, 0, 0);
layout->addWidget(m_combobox_video_codec, 0, 1, 1, 2);
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QImage PoleFigureImageUtilities::GenerateScalarBar(int imageWidth, int imageHeight, PoleFigureConfiguration_t& config)
{
int numColors = config.numColors;
QImage pImage(imageWidth, imageHeight, QImage::Format_ARGB32_Premultiplied);
pImage.fill(0xFFFFFFFF); // All white background
// Create a Painter backed by a QImage to draw into
QPainter painter;
painter.begin(&pImage);
painter.setRenderHint(QPainter::Antialiasing, true);
int penWidth = 1;
#if 0
// DRAW A BORDER AROUND THE IMAGE FOR DEBUGGING
QColor c(RgbColor::dRgb(255, 0, 0, 255));
painter.setPen(QPen(c, penWidth, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin));
painter.drawLine(0, 0, imageWidth, 0); // Top
painter.drawLine(0, 0, 0, imageHeight); // Left
painter.drawLine(imageWidth, 0, imageWidth, imageHeight); // Right
painter.drawLine(0, imageHeight, imageWidth, imageHeight); // Bottom
//-----------------
#endif
//Get all the colors that we will need
QVector<DREAM3D::Rgb> colorTable(numColors);
QVector<float> colors(3 * numColors, 0.0);
DREAM3DColorTable::GetColorTable(numColors, colors); // Generate the color table values
float r = 0.0, g = 0.0, b = 0.0;
for (int i = 0; i < numColors; i++) // Convert them to QRgbColor values
{
r = colors[3 * i];
g = colors[3 * i + 1];
b = colors[3 * i + 2];
colorTable[i] = RgbColor::dRgb(r * 255, g * 255, b * 255, 255);
}
// Now start from the bottom and draw colored lines up the scale bar
// A Slight Indentation for the scalar bar
float margin = 0.05f;
float scaleBarRelativeWidth = 0.10f;
float scaleBarRelativeHeight = 1.0f - (margin * 2);
int colorHeight = int( (imageHeight * scaleBarRelativeHeight) / numColors);
QPointF topLeft(imageWidth * margin, imageHeight * margin);
QSizeF size(imageWidth * scaleBarRelativeWidth, imageHeight * scaleBarRelativeHeight);
int yLinePos = topLeft.y();
QPointF start = topLeft;
QPointF end = topLeft;
for(int i = numColors - 1; i >= 0; i--)
{
QColor c(colorTable[i]);
painter.setPen(QPen(c, penWidth, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin));
for(int j = 0; j < colorHeight; j++)
{
start.setY(yLinePos);
end.setX(topLeft.x() + (imageWidth * scaleBarRelativeWidth));
end.setY(yLinePos);
painter.drawLine(start, end);
yLinePos++;
}
}
// Draw the border of the scale bar
size = QSizeF(imageWidth * scaleBarRelativeWidth, numColors * colorHeight); // Add two pixel to the height so we don't over write part of the scale bar
QRectF scaleBorder(topLeft, size);
penWidth = 2;
painter.setPen(QPen(QColor(0, 0, 0, 255), penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.drawRect(scaleBorder);
// Draw the Text Labels of the Scale Bar
int startFontPtSize = 10;
QFont font("Ariel", startFontPtSize, QFont::Bold);
QFontMetrics metrics(font);
int fontPixelsHeight = metrics.height();
while(fontPixelsHeight < colorHeight * 2)
{
startFontPtSize++;
font = QFont("Ariel", startFontPtSize, QFont::Bold);
metrics = QFontMetrics(font);
fontPixelsHeight = metrics.height();
}
painter.setFont(font);
// Draw some more information to the right of the Scale Bar
QString maxStr = QString::number(config.maxScale, 'f', 3);
painter.drawText(topLeft.x() + (imageWidth * scaleBarRelativeWidth) + 10, topLeft.y() + fontPixelsHeight, maxStr);
QString minStr = QString::number(config.minScale, 'f', 3);
painter.drawText(topLeft.x() + (imageWidth * scaleBarRelativeWidth) + 10, topLeft.y() + size.height(), minStr);
//.........这里部分代码省略.........
请发表评论