Changeset 4348 in ntrip for trunk/BNC


Ignore:
Timestamp:
Jun 24, 2012, 4:48:14 PM (12 years ago)
Author:
mervart
Message:
 
Location:
trunk/BNC/src/rinex
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/rinex/graphwin.cpp

    r4347 r4348  
    6363  connect(_buttonClose, SIGNAL(clicked()), this, SLOT(slotClose()));
    6464
     65  _buttonPrint = new QPushButton(tr("Print"), this);
     66  _buttonPrint->setMaximumWidth(10*ww);
     67  connect(_buttonPrint, SIGNAL(clicked()), this, SLOT(slotPrint()));
     68
    6569  // Color Scale
    6670  // -----------
     
    9296  QHBoxLayout* buttonLayout = new QHBoxLayout;
    9397  buttonLayout->addWidget(_buttonClose);
     98  buttonLayout->addWidget(_buttonPrint);
    9499
    95100  QVBoxLayout* mainLayout = new QVBoxLayout(this);
     
    114119  QDialog::closeEvent(event);
    115120}
     121
     122// Print the widget
     123////////////////////////////////////////////////////////////////////////////
     124void t_graphWin::slotPrint() {
     125
     126  QPrinter printer;
     127  QPrintDialog* dialog = new QPrintDialog(&printer, this);
     128  dialog->setWindowTitle(tr("Print Plot"));
     129  if (dialog->exec() != QDialog::Accepted) {
     130    return;
     131  }
     132  else {
     133    QPainter painter;
     134    painter.begin(&printer);
     135    QWidget* prtWidget = this; // TODO: only a part of it?
     136    double xscale = printer.pageRect().width()/double(prtWidget->width());
     137    double yscale = printer.pageRect().height()/double(prtWidget->height());
     138    double scale  = qMin(xscale, yscale);
     139    painter.translate(printer.paperRect().x() + printer.pageRect().width()/2,
     140                      printer.paperRect().y() + printer.pageRect().height()/2);
     141    painter.scale(scale, scale);
     142    painter.translate(-width()/2, -height()/2);
     143    prtWidget->render(&painter);
     144  }
     145}
  • trunk/BNC/src/rinex/graphwin.h

    r4337 r4348  
    5858 private slots:
    5959  void slotClose();
     60  void slotPrint();
    6061
    6162 protected:
     
    6465 private:
    6566  QPushButton*    _buttonClose;
     67  QPushButton*    _buttonPrint;
    6668  QwtScaleWidget* _colorScale;
    6769};
Note: See TracChangeset for help on using the changeset viewer.