11 #include "qwt_text_label.h"
12 #include "qwt_plot_layout.h"
13 #include "qwt_legend.h"
14 #include "qwt_scale_engine.h"
15 #include "qwt_scale_map.h"
16 #include "qwt_scale_widget.h"
17 #include "qwt_symbol.h"
21 : QwtPlotZoomer( xAxis, yAxis, canvas )
23 setSelectionFlags( QwtPicker::DragSelection | QwtPicker::CornerToCorner );
24 setTrackerMode ( QwtPicker::AlwaysOff );
25 setRubberBand ( QwtPicker::NoRubberBand );
30 setMousePattern( QwtEventPattern::MouseSelect2,
31 Qt::RightButton, Qt::ControlModifier );
33 setMousePattern( QwtEventPattern::MouseSelect3,
41 const QString& x_axis,
const QString& y_axis ) : QHBoxLayout()
50 QToolBar* toolBar =
new QToolBar;
51 toolBar->setAutoFillBackground(
true );
53 toolBar->setOrientation( Qt::Vertical );
55 btnZoom =
new QToolButton( toolBar );
59 btnZoom->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
61 connect(
btnZoom, SIGNAL( toggled(
bool ) ), SLOT(
zoom(
bool ) ) );
63 QToolButton* btnPrint =
new QToolButton( toolBar );
64 btnPrint->setText(
"Print" );
66 btnPrint->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
67 btnPrint->setFont( buttonFont );
68 connect( btnPrint, SIGNAL( clicked() ), SLOT(
print() ) );
70 QToolButton* btnSVG =
new QToolButton( toolBar );
71 btnSVG->setText(
"SVG" );
72 btnSVG->setIcon( QIcon(
vec_xpm ) );
73 btnSVG->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
74 btnSVG->setFont( buttonFont );
75 connect( btnSVG, SIGNAL( clicked() ), SLOT(
svg() ) );
77 QToolButton* btnPNG =
new QToolButton( toolBar );
78 btnPNG->setText(
"PNG" );
79 btnPNG->setIcon( QIcon(
ras_xpm ) );
80 btnPNG->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
81 btnPNG->setFont( buttonFont );
82 connect( btnPNG, SIGNAL( clicked() ), SLOT(
png() ) );
84 QToolButton* btnConfig =
new QToolButton( toolBar );
85 btnConfig->setText(
"Config" );
87 btnConfig->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
88 btnConfig->setFont( buttonFont );
89 connect( btnConfig, SIGNAL( clicked() ), SLOT(
config() ) );
92 toolBar->addWidget( btnPrint );
93 toolBar->addWidget( btnSVG );
94 toolBar->addWidget( btnPNG );
95 toolBar->addWidget( btnConfig );
100 QLabel* spacer =
new QLabel;
102 p.setColor( QPalette::Window, Qt::black );
103 spacer->setPalette( p );
104 spacer->setAutoFillBackground(
true );
105 spacer->setMaximumWidth( 1 );
114 plot->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
115 plot->setAutoReplot(
false );
123 QwtText qwtTitle( title );
124 qwtTitle.setFont( font );
125 plot->setTitle( qwtTitle );
130 qwtTitle.setFont( font );
131 qwtTitle.setText( x_axis );
132 plot->setAxisTitle( QwtPlot::xBottom, qwtTitle );
134 qwtTitle.setText( y_axis );
135 plot->setAxisTitle( QwtPlot::yLeft , qwtTitle );
137 font.setBold (
false );
139 plot->setAxisFont( QwtPlot::xBottom, font );
140 plot->setAxisFont( QwtPlot::yLeft, font );
141 plot->setAxisFont( QwtPlot::yRight, font );
142 if (
plot->legend() != NULL )
143 plot->legend()->setFont( font );
145 plot->setAutoFillBackground(
true );
160 zoomer->setRubberBand ( QwtPicker::RectRubberBand );
161 zoomer->setRubberBandPen( QColor( Qt::green ) );
162 zoomer->setTrackerMode ( QwtPicker::ActiveOnly );
163 zoomer->setTrackerPen ( QColor( Qt::white ) );
165 connect(
zoomer, SIGNAL ( zoomed( QwtDoubleRect ) ),
169 panner->setMouseButton( Qt::MidButton );
171 picker =
new QwtPlotPicker( QwtPlot::xBottom, QwtPlot::yLeft,
172 QwtPicker::PointSelection | QwtPicker::DragSelection,
173 QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn,
176 picker->setRubberBandPen( QColor( Qt::green ) );
177 picker->setRubberBand ( QwtPicker::CrossRubberBand );
178 picker->setTrackerPen ( QColor( Qt::white ) );
186 picker->setEnabled( ! on );
188 if ( ! on &&
zoomer != NULL )
201 if ( ! dir.exists( reportDir ) ) dir.mkpath( reportDir );
203 QString fileName = QFileDialog::getSaveFileName(
plot,
204 tr(
"Export File Name" ), reportDir,
205 tr(
"SVG Documents (*.svgz)" ) );
207 if ( ! fileName.isEmpty() )
209 if ( fileName.right( 5 ) !=
".svgz" ) fileName +=
".svgz";
219 if ( ! dir.exists( reportDir ) ) dir.mkpath( reportDir );
221 QString fileName = QFileDialog::getSaveFileName(
plot,
222 tr(
"Export File Name" ), reportDir,
223 tr(
"PNG Documents (*.png)" ) );
225 if ( ! fileName.isEmpty() )
227 if ( fileName.right( 4 ) !=
".png" ) fileName +=
".png";
237 if ( ! dir.exists( reportDir ) ) dir.mkpath( reportDir );
239 QPrinter printer( QPrinter::HighResolution );
241 printer.setOutputFileName( reportDir +
"/ultrascan-plot.pdf" );
244 QString docName =
plot->title().text();
246 if ( ! docName.isEmpty() )
248 docName.replace ( QRegExp( QString::fromLatin1(
"\n" ) ), tr (
" -- " ) );
249 printer.setDocName( docName );
252 printer.setCreator(
"UltraScan" );
253 printer.setOrientation( QPrinter::Landscape );
255 QPrintDialog dialog( &printer );
257 if ( dialog.exec() == QDialog::Accepted )
259 QwtPlotPrintFilter filter;
260 if ( printer.colorMode() == QPrinter::GrayScale )
262 int options = QwtPlotPrintFilter::PrintAll;
263 options &= ~QwtPlotPrintFilter::PrintBackground;
264 options |= QwtPlotPrintFilter::PrintFrameWithScales;
265 filter.setOptions( options );
267 plot->print( printer, filter );
283 qApp->processEvents();
305 QWidget* w,
int index ) : QPushButton( labelString.toAscii(), w )
312 setAutoDefault(
false );
335 setWindowTitle(
"Local Plot Configuration" );
348 QGridLayout*
main =
new QGridLayout(
this );
349 main->setContentsMargins( 2, 2, 2, 2 );
350 main->setSpacing( 2 );
353 QLabel* lb_elements =
us_banner( tr(
"----- Plot Elements -----" ) );
354 lb_elements->setFixedHeight( 40 );
355 main->addWidget( lb_elements, row++, 0, 1, 3 );
358 QLabel* lb_title =
us_label( tr(
"Title Text:" ) );
362 connect (
le_titleText, SIGNAL( textChanged (
const QString& ) ),
365 main->addWidget( lb_title, row, 0 );
369 QLabel* lb_titleFont =
us_label( tr(
"Title Font:" ) );
371 QFont titleFont =
plot->title().font();
374 + QString::number( titleFont.pointSize() ) + tr(
" points" ), 1 );
377 QPushButton* pb_titleFont =
us_pushbutton( tr(
"Update Font") );
378 connect( pb_titleFont, SIGNAL( clicked() ), SLOT(
updateTitleFont() ) );
380 main->addWidget( lb_titleFont, row, 0 );
382 main->addWidget( pb_titleFont, row++, 2 );
385 QLabel* lb_frameColor =
us_label( tr(
"Frame Color: " ) );
390 QPushButton* pb_showFrameColor =
us_pushbutton ( tr(
"Update Color" ) );
391 connect( pb_showFrameColor, SIGNAL( clicked() ), SLOT(
selectFrameColor() ) );
393 main->addWidget( lb_frameColor, row, 0 );
395 main->addWidget( pb_showFrameColor, row++, 2 );
398 QLabel* lb_canvasColor =
us_label( tr(
"Canvas Color: " ) );
403 QColor c =
plot->canvasBackground();
405 palette.setColor( QPalette::Active , QPalette::Window, c );
406 palette.setColor( QPalette::Inactive, QPalette::Window, c );
409 QPushButton* pb_showCanvasColor =
us_pushbutton( tr(
"Update Color" ) );
412 main->addWidget( lb_canvasColor, row, 0 );
414 main->addWidget( pb_showCanvasColor, row++, 2 );
417 QLabel* lb_margin =
us_label( tr(
"Border Margin:" ) );
420 for (
int i = 2; i <= 30; i += 2 )
422 cmbb_margin->addItem( QString::number( i ) +
" pixels" );
425 cmbb_margin->setCurrentIndex(
plot->margin() / 2 - 1 );
426 connect( cmbb_margin, SIGNAL( activated (
int ) ),
429 main->addWidget( lb_margin , row, 0 );
430 main->addWidget( cmbb_margin, row++, 1, 1, 2 );
433 QLabel* lb_legendPos =
us_label( tr(
"Legend Position:" ) );
445 switch (
plot->plotLayout()->legendPosition() )
447 case QwtPlot::LeftLegend : position = 1;
break;
448 case QwtPlot::RightLegend : position = 2;
break;
449 case QwtPlot::TopLegend : position = 3;
break;
450 case QwtPlot::BottomLegend : position = 4;
break;
451 case QwtPlot::ExternalLegend :
break;
455 if (
plot->legend() == NULL ) position = 0;
462 main->addWidget( lb_legendPos , row, 0 );
466 QLabel* lb_legendFont =
us_label( tr(
"Legend Font:" ) );
472 QPushButton* pb_legendFont =
us_pushbutton( tr(
"Update Font" ) );
473 connect( pb_legendFont, SIGNAL( clicked () ),
476 main->addWidget( lb_legendFont, row, 0 );
478 main->addWidget( pb_legendFont, row++, 2 );
493 connect( pb_leftAxis, SIGNAL( US_PlotPbPushed(
int ) ),
496 connect( pb_rightAxis, SIGNAL( US_PlotPbPushed(
int ) ),
499 connect( pb_topAxis, SIGNAL( US_PlotPbPushed(
int ) ),
502 connect( pb_bottomAxis, SIGNAL( US_PlotPbPushed(
int ) ),
505 QBoxLayout* axes =
new QHBoxLayout();
506 axes->addWidget( pb_leftAxis );
507 axes->addWidget( pb_rightAxis );
508 axes->addWidget( pb_topAxis );
509 axes->addWidget( pb_bottomAxis );
511 main->addLayout( axes, row++, 0, 1, 3 );
514 QPushButton* pb_grid =
us_pushbutton( tr(
"Update Gridlines" ) );
515 connect( pb_grid, SIGNAL( clicked() ), SLOT(
updateGrid() ) );
516 main->addWidget( pb_grid, row++, 0, 1, 3 );
519 QLabel* lb_curve =
us_banner( tr(
"----- Curve Elements -----" ) );
520 lb_curve->setFixedHeight( 40 );
522 main->addWidget( lb_curve, row++, 0, 1, 3 );
527 lw_curves->setSelectionMode( QAbstractItemView::ExtendedSelection );
530 QwtPlotItemList list =
plot->itemList();
534 for (
int i = 0; i < list.size(); i++ )
536 if ( list[ i ]->rtti() == QwtPlotItem::Rtti_PlotCurve )
538 QString label =
"(" + QString::number( j++ ) +
") ";
539 lw_curves->addItem( label + list[ i ]->title().text() );
543 main->addWidget(
lw_curves, row++, 0, 1, 3 );
546 QPushButton* pb_curve =
us_pushbutton( tr(
"Update Selected Curve(s)" ) );
547 connect( pb_curve, SIGNAL( clicked() ), SLOT(
updateCurve() ) );
549 main->addWidget( pb_curve, row++, 0, 1, 3 );
553 connect( pb_close, SIGNAL( clicked() ), SLOT( close() ) );
555 main->addWidget( pb_close, row++, 0, 1, 3 );
563 plot->setTitle( newText );
564 plot->updateLayout();
571 QFont currentFont =
plot->title().font();
572 QFont newFont = QFontDialog::getFont( &ok, currentFont,
this,
573 tr(
"Set Title Font" ), 0 );
577 QwtText title =
plot->title();
578 title.setFont( newFont );
579 plot->setTitle( title );
582 + QString::number( newFont.pointSize() ) + tr(
" points" ) );
590 QColor current = p.color( QPalette::Active, QPalette::Window );
591 QColor c = QColorDialog::getColor( current,
this, tr(
"Select canvas color" ) );
595 p.setColor( QPalette::Active , QPalette::Window, c );
596 p.setColor( QPalette::Inactive, QPalette::Window, c );
598 plot->setCanvasBackground( c );
606 QPalette
p =
plot->palette();
607 QColor current = p.color( QPalette::Active, QPalette::Window );
608 QColor c = QColorDialog::getColor( current,
this, tr(
"Select canvas color" ) );
612 p.setColor( QPalette::Active , QPalette::Window, c );
613 p.setColor( QPalette::Inactive, QPalette::Window, c );
615 plot->setPalette( p );
624 plot->setMargin( ( index + 1 ) * 2 );
632 QwtLegend* legend = NULL;
636 legend =
new QwtLegend;
637 legend->setFrameStyle( QFrame::Box | QFrame::Sunken );
640 plot->insertLegend( NULL, QwtPlot::BottomLegend );
644 case 1:
plot->insertLegend( legend, QwtPlot::LeftLegend );
break;
645 case 2:
plot->insertLegend( legend, QwtPlot::RightLegend );
break;
646 case 3:
plot->insertLegend( legend, QwtPlot::TopLegend );
break;
647 case 4:
plot->insertLegend( legend, QwtPlot::BottomLegend );
break;
656 QString legendFontString;
661 legendFontString = tr(
"No legend for this plot" );
665 QFont legendFont =
plot->legend()->font();
666 legendFontString = legendFont.family() +
", "
667 + QString::number( legendFont.pointSize() ) + tr(
" points" );
678 QMessageBox::warning(
this,
679 tr(
"Plog Config Warning" ),
680 tr(
"The layout does not exist. Set the legend position first." ) );
684 QFont font =
plot->legend()->font();
687 QFont newFont = QFontDialog::getFont( &ok, font,
this,
688 tr(
"Set Legend Font" ), 0 );
690 plot->legend()->setFont( newFont );
709 qApp->processEvents();
720 if (
lw_curves->selectedItems().count() == 0 )
722 QMessageBox::information(
this,
724 tr(
"No curves have been selected." ) );
734 QStringList selected;
735 QList< QListWidgetItem* > items =
lw_curves->selectedItems();
737 for (
int i = 0; i < items.count(); i++ )
738 selected << items[i]->text();
746 qApp->processEvents();
750 QMessageBox::information(
this, tr(
"Curve Config" ),
751 tr(
"Curve Update Complete" ) );
753 qApp->processEvents();
770 qApp->processEvents();
774 QMessageBox::information(
this, tr(
"Grid Config" ),
775 tr(
"Grid Update Complete" ) );
776 qApp->processEvents();
815 const QStringList& selected, QWidget* parent, Qt::WindowFlags f )
824 setWindowTitle( tr(
"Curve Configuration" ) );
828 QwtPlotItemList list =
plot->itemList();
831 QString firstSelectedText = selected[ 0 ];
832 firstSelectedText.replace( QRegExp(
"^\\(\\d+\\) " ),
"" );
836 for (
int i = 0; i < list.size(); i++ )
838 if ( list[ i ]->rtti() == QwtPlotItem::Rtti_PlotCurve &&
839 list[ i ]->title().text() == firstSelectedText )
848 qDebug() <<
"Could not find first selected curve";
855 QGridLayout*
main =
new QGridLayout(
this );
856 main->setContentsMargins( 2, 2, 2, 2 );
857 main->setSpacing( 2 );
860 QLabel* lb_sample1 =
us_label( tr(
"Sample:" ) );
864 p.setColor( QPalette::Window,
plot->canvasBackground() );
867 main->addWidget( lb_sample1, row , 0 );
868 main->addWidget(
lb_sample2, row++, 1, 1, 2 );
871 QLabel* lb_curve =
us_banner( tr(
"---- Update Curve Elements ----" ) );
872 main->addWidget( lb_curve, row++, 0, 1, 3 );
875 QLabel* lb_curveTitle =
us_label( tr(
"Title:" ) );
878 if ( selected.size() > 1 )
880 le_curveTitle->insert( tr(
"Multiple curves selected - not changeable" ) );
886 main->addWidget( lb_curveTitle, row , 0 );
890 QLabel* lb_curveStyle =
us_label( tr(
"Style:" ) );
898 QList< int > curveStyles;
899 curveStyles << QwtPlotCurve::NoCurve << QwtPlotCurve::Lines
900 << QwtPlotCurve::Sticks << QwtPlotCurve::Steps
901 << QwtPlotCurve::Dots;
905 for (
int i = 0; i < curveStyles.size(); i++ )
915 QBoxLayout* stylewidth =
new QHBoxLayout();
918 QLabel* lb_curveWidth =
us_label( tr(
"Width (pixels):" ) );
919 stylewidth->addWidget( lb_curveWidth );
929 main->addWidget( lb_curveStyle, row , 0 );
930 main->addLayout( stylewidth , row++, 1, 1, 2 );
932 QLabel* lb_curveColor =
us_label( tr(
"Color:" ) );
939 QPushButton* pb_showCurveColor =
us_pushbutton ( tr(
"Update Color" ) );
940 connect( pb_showCurveColor, SIGNAL( clicked () ),
943 main->addWidget( lb_curveColor , row , 0 );
945 main->addWidget( pb_showCurveColor, row++, 2 );
948 QLabel* lb_symbol =
us_banner( tr(
"---- Update Symbol Elements ----" ) );
949 main->addWidget( lb_symbol, row++, 0, 1, 3 );
952 QLabel* lb_symbolStyle =
us_label( tr(
"Style:" ) );
970 QList< int > symbolStyles;
972 << QwtSymbol::NoSymbol << QwtSymbol::Rect << QwtSymbol::Diamond
973 << QwtSymbol::Triangle << QwtSymbol::DTriangle << QwtSymbol::UTriangle
974 << QwtSymbol::LTriangle << QwtSymbol::RTriangle << QwtSymbol::Cross
975 << QwtSymbol::XCross << QwtSymbol::HLine << QwtSymbol::VLine
976 << QwtSymbol::Star1 << QwtSymbol::Star2 << QwtSymbol::Hexagon;
980 for (
int i = 0; i < symbolStyles.size(); i++ )
990 main->addWidget( lb_symbolStyle , row , 0 );
994 QLabel* lb_symbolWidth =
us_label( tr(
"Width (pixels):" ) );
1002 QLabel* lb_symbolHeight =
us_label( tr(
"Height (pixels):" ) );
1010 QBoxLayout* heightwidth =
new QHBoxLayout();
1012 heightwidth->addWidget( lb_symbolHeight );
1015 main->addWidget( lb_symbolWidth, row , 0 );
1016 main->addLayout( heightwidth , row++, 1, 1, 2 );
1019 QLabel* lb_symbolOutlineColor =
us_label( tr(
"Outline Color:" ) );
1026 QPushButton* pb_symOutlineColor =
us_pushbutton ( tr(
"Update Color" ) );
1027 connect( pb_symOutlineColor, SIGNAL( clicked () ),
1030 QLabel* lb_symbolInteriorColor =
us_label( tr(
"Interior Color:" ) );
1037 QPushButton* pb_symInteriorColor =
us_pushbutton ( tr(
"Update Color" ) );
1038 connect( pb_symInteriorColor, SIGNAL( clicked () ),
1041 QBoxLayout* symbolcolor =
new QHBoxLayout();
1043 symbolcolor->addWidget( pb_symOutlineColor );
1044 symbolcolor->addWidget( lb_symbolInteriorColor );
1046 symbolcolor->addWidget( pb_symInteriorColor );
1048 main->addWidget( lb_symbolOutlineColor, row , 0 );
1049 main->addLayout( symbolcolor , row++, 1, 1, 2 );
1053 connect( pb_apply, SIGNAL( clicked() ), SLOT(
apply() ) );
1056 connect( pb_close, SIGNAL( clicked() ), SLOT( close() ) );
1058 QBoxLayout* applyClose =
new QHBoxLayout();
1059 applyClose->addWidget( pb_apply );
1060 applyClose->addWidget( pb_close );
1062 main->addLayout( applyClose, row++, 0, 1, 3 );
1079 curveStyle =
static_cast< QwtPlotCurve::CurveStyle
> ( style );
1086 symbolStyle =
static_cast< QwtSymbol::Style
> ( style );
1093 QColor current = p.color( QPalette::Active, QPalette::Window );
1094 QColor c = QColorDialog::getColor( current,
this,
1095 tr(
"Select curve color" ) );
1099 p.setColor( QPalette::Window, c );
1108 QColor current = p.color( QPalette::Active, QPalette::Window );
1109 QColor c = QColorDialog::getColor( current,
this,
1110 tr(
"Select symbol interior color" ) );
1114 p.setColor( QPalette::Window, c );
1123 QColor current = p.color( QPalette::Active, QPalette::Window );
1124 QColor c = QColorDialog::getColor( current,
this,
1125 tr(
"Select symbol outline color" ) );
1129 p.setColor( QPalette::Window, c );
1138 QPen symbolPen = oldSymbol.pen();
1139 QBrush symbolBrush = oldSymbol.brush();
1142 symbolPen.setColor( palette.color( QPalette::Window ) );
1145 symbolBrush.setColor( palette.color( QPalette::Window ) );
1149 QwtSymbol newSymbol(
symbolStyle, symbolBrush, symbolPen, symbolSize );
1152 QPen curvePen( palette.color( QPalette::Window ) );
1156 QwtPlotItemList list =
plot->itemList();
1165 title.replace( QRegExp(
"^\\(\\d+\\) " ),
"" );
1171 for ( ; j < list.size(); j++ )
1173 if ( list[ j ]->rtti() != QwtPlotItem::Rtti_PlotCurve )
continue;
1174 if ( list[ j ]->title() == title )
1176 QwtPlotCurve* curve =
dynamic_cast< QwtPlotCurve*
> ( list[ j ] );
1180 curve->setSymbol( newSymbol);
1181 curve->setPen ( curvePen );
1194 QWidget*
p, Qt::WindowFlags f ) : QWidget( p, f )
1202 QRect r = e->rect();
1204 int height = r.y() + r.height() / 2;
1205 int first = r.x() + r.width() / 10;
1206 int last = r.x() + r.width() * 9 / 10;
1207 int length = last - first;
1209 QPoint p1 = QPoint( first , height );
1210 QPoint p2 = QPoint( first + length / 4, height );
1211 QPoint p3 = QPoint( first + length / 2, height );
1212 QPoint p4 = QPoint( last - length / 4, height );
1213 QPoint p5 = QPoint( last , height );
1222 QBrush brush(
data->
plot->canvasBackground() );
1223 p.fillRect( e->rect(), brush );
1227 pen.setColor( foreground.color( QPalette::Window ) );
1234 case QwtPlotCurve::NoCurve:
1237 case QwtPlotCurve::Lines:
1238 p.drawLine( p1, p5 );
1241 case QwtPlotCurve::Sticks:
1245 for(
int i = p1.x(); i < p5.x(); i += 8 )
1246 p.drawLine( i, y1, i, y2 );
1249 case QwtPlotCurve::Steps:
1253 for (
int i = p1.x(); i < p5.x(); i += 10 )
1255 p.drawLine( i , y1, i + 10, y2 );
1256 p.drawLine( i + 10, y2, i + 10, y1 );
1260 case QwtPlotCurve::Dots:
1261 for (
int i = p1.x(); i < p5.x() ; i += 6 )
1262 p.drawPoint( i, p1.y() );
1275 pen.setColor( palette.color( QPalette::Window ) );
1278 brush.setColor( palette.color( QPalette::Window ) );
1300 QWidget* parent, Qt::WindowFlags flags ) :
US_WidgetsDialog( parent, flags )
1308 QString axisLocation;
1312 case QwtPlot::yLeft : axisLocation = tr(
"Left" );
break;
1313 case QwtPlot::yRight : axisLocation = tr(
"Right" );
break;
1314 case QwtPlot::xTop : axisLocation = tr(
"Top" );
break;
1315 case QwtPlot::xBottom: axisLocation = tr(
"Bottom" );
break;
1318 setWindowTitle( axisLocation + tr(
" Axis Configuration" ) );
1323 QGridLayout*
main =
new QGridLayout(
this );
1324 main->setContentsMargins( 2, 2, 2, 2 );
1325 main->setSpacing( 2 );
1328 QLabel* lb_present =
us_label( axisLocation + tr(
" Axis Present:" ) );
1329 Qt::CheckState checked = (
plot->axisEnabled(
axis ) )
1330 ? Qt::Checked : Qt::Unchecked;
1334 main->addWidget( lb_present, row , 0 );
1335 main->addLayout( present , row++, 1 );
1338 QLabel* lb_title =
us_label( tr(
"Axis Title:" ) );
1343 main->addWidget( lb_title , row , 0 );
1347 QLabel* lb_axisTitleFont =
us_label( tr(
"Axis Title Font:" ) );
1352 + QString::number(
axisTitleFont.pointSize() ) + tr(
" points" ), 1 );
1355 QPushButton* pb_axisTitleFont =
us_pushbutton( tr(
"Update Font") );
1356 connect( pb_axisTitleFont, SIGNAL( clicked() ), SLOT(
selectTitleFont() ) );
1358 main->addWidget( lb_axisTitleFont, row, 0 );
1360 main->addWidget( pb_axisTitleFont, row++, 2 );
1364 QLabel* lb_axisTitleColor =
us_label( tr(
"Axis Title Color:" ) );
1368 QPalette
p =
plot->axisWidget(
axis )->palette();
1369 p.setColor( QPalette::Window, p.color( QPalette::Text ) );
1372 QPushButton* pb_axisTitleColor =
us_pushbutton ( tr(
"Update Color" ) );
1373 connect( pb_axisTitleColor, SIGNAL( clicked () ),
1376 main->addWidget( lb_axisTitleColor , row, 0 );
1378 main->addWidget( pb_axisTitleColor , row++, 2 );
1381 QLabel* lb_axisScaleFont =
us_label( tr(
"Axis Scale Font:" ) );
1386 + QString::number(
axisScaleFont.pointSize() ) + tr(
" points" ), 1 );
1389 QPushButton* pb_axisScaleFont =
us_pushbutton( tr(
"Update Font") );
1390 connect( pb_axisScaleFont, SIGNAL( clicked() ), SLOT(
selectScaleFont() ) );
1392 main->addWidget( lb_axisScaleFont, row, 0 );
1394 main->addWidget( pb_axisScaleFont, row++, 2 );
1397 QLabel* lb_scaleColor =
us_label( tr(
"Axis Scale Color:" ) );
1400 p =
plot->axisWidget(
axis )->palette();
1401 p.setColor( QPalette::Window, p.color( QPalette::WindowText ) );
1404 QPushButton* pb_scaleColor =
us_pushbutton ( tr(
"Update Color" ) );
1407 main->addWidget( lb_scaleColor , row, 0 );
1409 main->addWidget( pb_scaleColor , row++, 2 );
1412 QLabel* lb_tickColor =
us_label( tr(
"Axis Tick Color:" ) );
1415 p =
plot->axisWidget(
axis )->palette();
1416 p.setColor( QPalette::Window, p.color( QPalette::WindowText ) );
1419 QPushButton* pb_tickColor =
us_pushbutton ( tr(
"Update Color" ) );
1420 connect( pb_tickColor, SIGNAL( clicked() ), SLOT(
selectTickColor() ) );
1422 main->addWidget( lb_tickColor , row, 0 );
1424 main->addWidget( pb_tickColor , row++, 2 );
1427 QLabel* lb_scaleFrom =
us_label( tr(
"Scale From:" ) );
1428 QLabel* lb_scaleTo =
us_label( tr(
"To:" ) );
1429 QLabel* lb_scaleStep =
us_label( tr(
"Step:" ) );
1432 QString::number(
plot->axisScaleDiv(
axis )->lowerBound() ), 1 );
1435 QString::number(
plot->axisScaleDiv(
axis )->upperBound() ), 1 );
1438 QString::number(
plot->axisStepSize(
axis ) ), 1 );
1440 QBoxLayout* scale =
new QHBoxLayout;
1442 scale->addWidget( lb_scaleTo );
1444 scale->addWidget( lb_scaleStep );
1447 main->addWidget( lb_scaleFrom, row , 0 );
1448 main->addLayout( scale , row++, 1, 1, 2 );
1451 QLabel* lb_scaleType =
us_label( tr(
"Scale Type:" ) );
1453 QBoxLayout* scaleRadio =
new QHBoxLayout();
1454 scaleRadio->setSpacing( 0 );
1459 if (
plot->axisScaleEngine(
axis )->transformation()->type() ==
1460 QwtScaleTransformation::Log10 )
rb_log->setChecked(
true );
1462 scaleRadio->addLayout( rb1 );
1463 scaleRadio->addLayout( rb2 );
1465 main->addWidget( lb_scaleType, row, 0 );
1466 main->addLayout( scaleRadio , row++, 1, 1, 2 );
1469 QLabel* lb_reference =
us_label( tr(
"Scale Reference:" ) );
1472 QString::number(
plot->axisScaleEngine(
axis )->reference() ), 1 );
1477 QBoxLayout* reference =
new QHBoxLayout;
1479 reference->addLayout( refValue );
1480 reference->addLayout( symmetric );
1482 main->addWidget( lb_reference, row, 0 );
1483 main->addLayout( reference , row++, 1, 1, 2 );
1486 QLabel* lb_options =
us_label( tr(
"Scale Options:" ) );
1488 int attributes =
plot->axisScaleEngine(
axis )->attributes();
1490 checked = ( attributes & QwtScaleEngine::Floating )
1491 ? Qt::Checked : Qt::Unchecked;
1493 QGridLayout* floating
1496 checked = ( attributes & QwtScaleEngine::Inverted )
1497 ? Qt::Checked : Qt::Unchecked;
1499 QGridLayout* inverted
1502 checked = (
plot->axisAutoScale(
axis ) ) ? Qt::Checked : Qt::Unchecked;
1503 QGridLayout* autoscale
1506 QBoxLayout* options =
new QHBoxLayout;
1507 options->addLayout( floating );
1508 options->addLayout( inverted );
1509 options->addLayout( autoscale );
1511 main->addWidget( lb_options, row, 0 );
1512 main->addLayout( options , row++, 1, 1, 2 );
1516 connect( pb_apply, SIGNAL( clicked() ), SLOT(
apply() ) );
1519 connect( pb_close, SIGNAL( clicked() ), SLOT( close() ) );
1521 QBoxLayout* applyClose =
new QHBoxLayout();
1522 applyClose->addWidget( pb_apply );
1523 applyClose->addWidget( pb_close );
1525 main->addLayout( applyClose, row++, 0, 1, 3 );
1537 QFont currentFont =
plot->axisTitle(
axis ).font();
1538 QFont newFont = QFontDialog::getFont( &ok, currentFont,
this,
1539 tr(
"Set Axis Title Font" ), 0 );
1545 + QString::number( newFont.pointSize() ) + tr(
" points" ) );
1552 QColor current = p.color( QPalette::Window );
1553 QColor c = QColorDialog::getColor( current,
this,
1554 tr(
"Select Axis Title Color" ) );
1558 p.setColor( QPalette::Window, c );
1566 QFont currentFont =
plot->axisFont(
axis );
1567 QFont newFont = QFontDialog::getFont( &ok, currentFont,
this,
1568 tr(
"Set Axis Scale Font" ), 0 );
1574 + QString::number( newFont.pointSize() ) + tr(
" points" ) );
1581 QColor current = p.color( QPalette::Window );
1582 QColor c = QColorDialog::getColor( current,
this,
1583 tr(
"Select Scale Color" ) );
1587 p.setColor( QPalette::Window, c );
1595 QColor current = p.color( QPalette::Window );
1596 QColor c = QColorDialog::getColor( current,
this,
1597 tr(
"Select Tick Color" ) );
1601 p.setColor( QPalette::Window, c );
1616 QwtText title =
plot->axisTitle(
axis );
1621 title.setColor( p.color( QPalette::Window ) );
1630 QPalette axisPalette =
plot->axisWidget(
axis )->palette();
1631 axisPalette.setColor( QPalette::Text, p.color( QPalette::Window ) );
1634 axisPalette.setColor( QPalette::WindowText, p.color( QPalette::Window ) );
1636 plot->axisWidget(
axis )->setPalette( axisPalette );
1644 plot->setAxisScale(
axis, from, to, step );
1647 int plotType =
plot->axisScaleEngine(
axis )->transformation()->type();
1648 if ( ( plotType == QwtScaleTransformation::Log10 &&
rb_linear->isChecked() )
1649 || ( plotType == QwtScaleTransformation::Linear &&
rb_log ->isChecked() ) )
1652 plot->setAxisScaleEngine(
axis,
new QwtLinearScaleEngine );
1654 plot->setAxisScaleEngine(
axis,
new QwtLog10ScaleEngine );
1659 plot->axisScaleEngine(
axis )->setReference( reference );
1662 if (
cb_refValue ->isChecked() ) attributes |= QwtScaleEngine::IncludeReference;
1663 if (
cb_symmetric->isChecked() ) attributes |= QwtScaleEngine::Symmetric;
1667 if (
cb_floating->isChecked() ) attributes |= QwtScaleEngine::Floating;
1668 if (
cb_inverted->isChecked() ) attributes |= QwtScaleEngine::Inverted;
1669 plot->axisScaleEngine(
axis )->setAttributes( attributes );
1684 QWidget* parent, Qt::WindowFlags flags ) :
US_WidgetsDialog( parent, flags )
1686 setWindowTitle( tr(
"Grid Configuration" ) );
1697 QwtPlotItemList list =
plot->itemList();
1699 for (
int i = 0; i< list.size(); i++ )
1701 if ( list[i]->rtti() == QwtPlotItem::Rtti_PlotGrid )
1705 grid =
dynamic_cast<QwtPlotGrid*
>( list[ i ] );
1707 list[ i ]->detach();
1710 qDebug() <<
"GRID COUNT" << ngrid;
1715 grid =
new QwtPlotGrid;
1716 grid->enableX (
false );
1717 grid->enableY (
false );
1718 grid->enableXMin(
false );
1719 grid->enableYMin(
false );
1724 QGridLayout*
main =
new QGridLayout(
this );
1725 main->setContentsMargins( 2, 2, 2, 2 );
1726 main->setSpacing( 2 );
1730 QLabel* lb_major =
us_banner( tr(
" ---- Major Gridlines ----" ) );
1731 lb_major->setFixedHeight( 40 );
1733 main->addWidget( lb_major, row++, 0, 1, 3 );
1736 QLabel* lb_enableMajor =
us_label( tr(
"Enable:" ) );
1738 Qt::CheckState checked = (
grid->xEnabled() ) ? Qt::Checked : Qt::Unchecked;
1741 checked = (
grid->yEnabled() ) ? Qt::Checked : Qt::Unchecked;
1744 QBoxLayout* enableMajor =
new QHBoxLayout;
1745 enableMajor->addLayout( enableX );
1746 enableMajor->addLayout( enableY );
1748 main->addWidget( lb_enableMajor, row , 0 );
1749 main->addLayout( enableMajor , row++, 1, 1, 2 );
1752 QLabel* lb_majorColor =
us_label( tr(
"Color:" ) );
1756 QPen majorPen =
grid->majPen();
1758 p.setColor( QPalette::Window, majorPen.color() );
1761 QPushButton* pb_majorColor =
us_pushbutton ( tr(
"Update Color" ) );
1764 main->addWidget( lb_majorColor , row, 0 );
1766 main->addWidget( pb_majorColor , row++, 2 );
1769 QLabel* lb_majorStyle =
us_label( tr(
"Style:" ) );
1771 QBoxLayout* majorStyle =
new QHBoxLayout;
1774 styles << tr(
"Solid" ) << tr(
"Dash" ) << tr(
"Dot" ) << tr(
"DashDotDot" )
1775 << tr(
"DashDotDot" );
1777 QList< int > penStyle;
1778 penStyle << Qt::SolidLine << Qt::DashLine << Qt::DotLine << Qt::DashDotLine
1779 << Qt::DashDotDotLine;
1782 int currentStyle = majorPen.style();
1784 for (
int i = 0; i < styles.size(); i++ )
1788 if ( currentStyle == penStyle[ i ] )
1794 QLabel* lb_majorWidth =
us_label( tr(
"Width (pixels):" ) );
1795 majorStyle->addWidget( lb_majorWidth );
1803 main->addWidget( lb_majorStyle, row, 0 );
1804 main->addLayout( majorStyle , row++, 1, 1, 2 );
1808 QLabel* lb_minor =
us_banner( tr(
" ---- Minor Gridlines ----" ) );
1809 lb_minor->setFixedHeight( 40 );
1810 main->addWidget( lb_minor, row++, 0, 1, 3 );
1813 QLabel* lb_enableMinor =
us_label( tr(
"Enable:" ) );
1815 checked = (
grid->xMinEnabled() ) ? Qt::Checked : Qt::Unchecked;
1816 QGridLayout* enableXminor
1819 checked = (
grid->yMinEnabled() ) ? Qt::Checked : Qt::Unchecked;
1820 QGridLayout* enableYminor
1823 QBoxLayout* enableMinor =
new QHBoxLayout;
1824 enableMinor->addLayout( enableXminor );
1825 enableMinor->addLayout( enableYminor );
1827 main->addWidget( lb_enableMinor, row , 0 );
1828 main->addLayout( enableMinor , row++, 1, 1, 2 );
1831 QLabel* lb_minorColor =
us_label( tr(
"Color:" ) );
1835 QPen minorPen =
grid->minPen();
1836 p.setColor( QPalette::Window, minorPen.color() );
1839 QPushButton* pb_minorColor =
us_pushbutton ( tr(
"Update Color" ) );
1842 main->addWidget( lb_minorColor , row, 0 );
1844 main->addWidget( pb_minorColor , row++, 2 );
1847 QLabel* lb_minorStyle =
us_label( tr(
"Style:" ) );
1849 QBoxLayout* minorStyle =
new QHBoxLayout;
1852 currentStyle = minorPen.style();
1854 for (
int i = 0; i < styles.size(); i++ )
1857 if ( currentStyle == penStyle[ i ] )
1864 QLabel* lb_minorWidth =
us_label( tr(
"Width (pixels):" ) );
1865 minorStyle->addWidget( lb_minorWidth );
1873 main->addWidget( lb_minorStyle, row, 0 );
1874 main->addLayout( minorStyle , row++, 1, 1, 2 );
1878 connect( pb_apply, SIGNAL( clicked() ), SLOT(
apply() ) );
1881 connect( pb_close, SIGNAL( clicked() ), SLOT( close() ) );
1883 QBoxLayout* applyClose =
new QHBoxLayout();
1884 applyClose->addWidget( pb_apply );
1885 applyClose->addWidget( pb_close );
1887 main->addLayout( applyClose, row++, 0, 1, 3 );
1893 QColor current = p.color( QPalette::Window );
1894 QColor c = QColorDialog::getColor( current,
this,
1895 tr(
"Select major grid line color" ) );
1898 p.setColor( QPalette::Window, c );
1906 QColor current = p.color( QPalette::Window );
1907 QColor c = QColorDialog::getColor( current,
this,
1908 tr(
"Select minor grid line color" ) );
1911 p.setColor( QPalette::Window, c );
1919 QPen pen =
grid->majPen();
1926 pen.setStyle( static_cast< Qt::PenStyle >( style ) );
1928 grid->setMajPen( pen );
1931 pen =
grid->minPen();
1937 pen.setStyle( static_cast< Qt::PenStyle >( style ) );
1939 grid->setMinPen( pen );
1957 : QwtPlotPicker( QwtPlot::xBottom, QwtPlot::yLeft, plot->canvas() )
1959 setSelectionFlags( QwtPicker::PointSelection );
1960 setTrackerMode ( QwtPicker::AlwaysOn );
1961 setRubberBand ( QwtPicker::CrossRubberBand );
1964 setRubberBandPen ( c );
1965 setTrackerPen ( c );
1971 static QTime last_click;
1973 if ( last_click.isNull() || last_click.elapsed() > 300 )
1976 if ( e->button() == Qt::LeftButton )
1977 emit
mouseDown( invTransform( e->pos() ) );
1978 if ( e->button() == Qt::LeftButton && e->modifiers() == Qt::ControlModifier )
1980 emit
cMouseDown ( invTransform( e->pos() ) );
1985 QwtPlotPicker::widgetMousePressEvent( e );
1990 static QTime last_click;
1992 if ( last_click.isNull() || last_click.elapsed() > 300 )
1995 if ( e->button() == Qt::LeftButton )
1996 emit
mouseUp( invTransform( e->pos() ) );
1998 if ( e->button() == Qt::LeftButton && e->modifiers() == Qt::ControlModifier )
1999 emit
cMouseUp( invTransform( e->pos() ) );
2002 QwtPlotPicker::widgetMouseReleaseEvent( e );
2007 static QTime last_click;
2010 if ( last_click.isNull() || last_click.elapsed() > 100 )
2013 if ( e->button() == Qt::LeftButton )
2014 emit
mouseDrag( invTransform( e->pos() ) );
2016 if ( e->modifiers() == Qt::ControlModifier )
2022 QwtPlotPicker::widgetMouseMoveEvent( e );