PlotTab( bool parametric, QWidget *parent ): QMainWindow( parent ) { Plot *plot = new Plot( parametric, this ); setCentralWidget( plot ); QToolBar *toolBar = new QToolBar( this ); #ifndef QT_NO_PRINTER ToolButton *btnPrint = new ToolButton( "Print", toolBar ); toolBar->addWidget( btnPrint ); QObject::connect( btnPrint, SIGNAL( clicked() ), plot, SLOT( printPlot() ) ); #endif ToolButton *btnOverlay = new ToolButton( "Overlay", toolBar ); btnOverlay->setCheckable( true ); toolBar->addWidget( btnOverlay ); QObject::connect( btnOverlay, SIGNAL( toggled( bool ) ), plot, SLOT( setOverlaying( bool ) ) ); if ( parametric ) { QComboBox *parameterBox = new QComboBox( toolBar ); parameterBox->addItem( "Uniform" ); parameterBox->addItem( "Centripetral" ); parameterBox->addItem( "Chordal" ); parameterBox->addItem( "Manhattan" ); toolBar->addWidget( parameterBox ); connect( parameterBox, SIGNAL( activated( const QString & ) ), plot, SLOT( setParametric( const QString & ) ) ); parameterBox->setCurrentIndex( 2 ); // chordal plot->setParametric( parameterBox->currentText() ); ToolButton *btnClosed = new ToolButton( "Closed", toolBar ); btnClosed->setCheckable( true ); toolBar->addWidget( btnClosed ); QObject::connect( btnClosed, SIGNAL( toggled( bool ) ), plot, SLOT( setClosed( bool ) ) ); } QComboBox *boundaryBox = new QComboBox( toolBar ); boundaryBox->addItem( "Natural" ); boundaryBox->addItem( "Linear Runout" ); boundaryBox->addItem( "Parabolic Runout" ); boundaryBox->addItem( "Cubic Runout" ); boundaryBox->addItem( "Not a Knot" ); toolBar->addWidget( boundaryBox ); connect( boundaryBox, SIGNAL( activated( const QString & ) ), plot, SLOT( setBoundaryCondition( const QString & ) ) ); addToolBar( toolBar ); }
QWidget *LeftToolBox::createButton(const QString &name,QButtonGroup *group,const int id) { ToolButton *carButton = new ToolButton; carButton->setCheckable(true); carButton->setIcon(QIcon(QPixmap(name).scaled(30,30,Qt::KeepAspectRatio))); carButton->setIconSize(QSize(50,50)); if (group != 0){ group->addButton(carButton, id); } QGridLayout *layout = new QGridLayout; layout->addWidget(carButton,0,0,Qt::AlignHCenter); QWidget *widget = new QWidget; widget->setLayout(layout); return widget; }
ToolButton* ToolBar::addToggleButton(const char* const* xpm, const QString& tooltip) { ToolButton* button = addButton(xpm, tooltip); button->setCheckable(true); return button; }
ToolButton* ToolBar::addToggleButton(const QIcon& icon, const QString& tooltip) { ToolButton* button = addButton(icon, tooltip); button->setCheckable(true); return button; }