MCPcopy Create free account
hub / github.com/analogdevicesinc/scopy / printPlots

Method printPlots

gui/src/printplotmanager.cpp:36–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34{}
35
36void PrintPlotManager::printPlots(QList<PlotWidget *> plotList, QString toolName)
37{
38 // select folder where to save
39 bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool();
40 QString folderPath = QFileDialog::getExistingDirectory(nullptr, "Select Folder", "",
41 (useNativeDialogs ? QFileDialog::Options()
42 : QFileDialog::ShowDirsOnly |
43 QFileDialog::DontResolveSymlinks |
44 QFileDialog::DontUseNativeDialog));
45
46 if(!folderPath.isEmpty()) {
47 // use current date and tool name to crete the file name
48 QString date = QDateTime::currentDateTime().toString("yyyy-MM-dd-hh-mm-ss");
49 QString fileName = QString(folderPath + "/Scopy-" + toolName + "-" + date + ".pdf");
50
51 if(!fileName.isEmpty()) {
52 QPdfWriter pdfWriter(fileName);
53 pdfWriter.setResolution(85);
54
55 int widthInPixels = 500;
56 int heightInPixels = 400;
57 pdfWriter.setPageSize(QPageSize(QSize(widthInPixels / 3.78, heightInPixels / 3.78),
58 QPageSize::Millimeter)); // 1 inch = 25.4mm
59
60 QPainter painter(&pdfWriter);
61 painter.setRenderHint(QPainter::Antialiasing);
62
63 if(!plotList.isEmpty()) {
64 plotList.first()->printPlot(&painter, m_printWithSymbols);
65 // if there is more than one plot save it to same file
66 for(int i = 1; i < plotList.length(); i++) {
67 pdfWriter.newPage();
68 plotList.at(i)->printPlot(&painter, m_printWithSymbols);
69 }
70 }
71 }
72 }
73}
74
75void PrintPlotManager::setPrintWithSymbols(bool printWithSymbols) { m_printWithSymbols = printWithSymbols; }
76

Callers 3

initMethod · 0.80
initMethod · 0.80
DatamonitorToolMethod · 0.80

Calls 3

QStringClass · 0.50
toStringMethod · 0.45
printPlotMethod · 0.45

Tested by

no test coverage detected